{
  "openapi": "3.1.0",
  "info": {
    "title": "Treechat App Connect API",
    "version": "v1",
    "summary": "Post, reply, branch, upload and read on Treechat for a member who connected your app.",
    "description": "Treechat is a tree-structured social network: a thread is a conversation, a post is one message in it, and any post can start a branch (a thread growing out of that post). Apps act for a member after the member approves them through OAuth 2.0 (authorization code + PKCE S256). Apps cannot spend the member's money.\n\nRead responses reuse Treechat's existing JSON, where a thread is named `quest` and a post `answer`.\n\nHuman docs: https://docs.treechat.com/developers/overview/ — all docs as Markdown: https://docs.treechat.com/llms-full.txt",
    "contact": {
      "url": "https://docs.treechat.com/developers/overview/"
    }
  },
  "externalDocs": {
    "description": "App Connect developer docs",
    "url": "https://docs.treechat.com/developers/overview/"
  },
  "servers": [
    {
      "url": "https://api.treechat.com/api/apps/v1"
    }
  ],
  "security": [
    {
      "treechat_oauth": []
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "summary": "The connected member",
        "security": [
          {
            "treechat_oauth": [
              "account:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "The member this token acts for.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, or `app_suspended` when Treechat suspended the app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/posts": {
      "post": {
        "operationId": "createPost",
        "summary": "Start a thread, reply in a thread, or reply in a post's branch",
        "description": "No `thread_id` or `branch_from_post_id`: a new thread (private unless `public: true`). `thread_id`: a reply in that thread (`reply_to_post_id` answers a specific post). `branch_from_post_id`: a reply in that post's branch, starting the branch if needed. Reuse the same Idempotency-Key when retrying; on 202 poll getOperation instead of retrying with a new key. Apps post only in public places (public:write: a new public thread with public: true, or a reply in a public thread) or in channels the person picked for the app (channels: a new thread with channel_id, or a reply in that channel's threads). Private threads and DMs are refused with 403 forbidden.",
        "security": [
          {
            "treechat_oauth": [
              "public:write"
            ]
          },
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PostRequest"
              },
              "examples": {
                "newThread": {
                  "summary": "New public thread with an image",
                  "value": {
                    "content": "Episode 1 is live",
                    "files": [
                      "SIGNED_ID"
                    ],
                    "public": true
                  }
                },
                "reply": {
                  "summary": "Reply in a thread",
                  "value": {
                    "content": "Shot on a phone.",
                    "thread_id": "72db5fc4-36bb-5c1e-b13e-9e68ec760d35"
                  }
                },
                "branch": {
                  "summary": "Reply in a post's branch",
                  "value": {
                    "content": "Behind the scenes",
                    "branch_from_post_id": "1b9e5a50-0c1e-4c55-a2a8-6f1f8a1f2e10"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Posted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteResult"
                }
              }
            }
          },
          "202": {
            "description": "Not confirmed yet; poll getOperation with operation_id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteResult"
                }
              }
            }
          },
          "409": {
            "description": "`idempotency_conflict`: the key was used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "`invalid_arguments`, or `rejected` with the reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limit_exceeded` or `daily_limit_reached`: wait and retry with the same key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, `app_suspended`, or `forbidden` when the app may not post there: it posts only in public threads (public:write) or in channels the person picked (channels).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/operations/{id}": {
      "get": {
        "operationId": "getOperation",
        "summary": "Status of a post that returned 202",
        "security": [
          {
            "treechat_oauth": [
              "public:write"
            ]
          },
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "operation_id from createPost."
          }
        ],
        "responses": {
          "200": {
            "description": "Completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteResult"
                }
              }
            }
          },
          "202": {
            "description": "Still pending.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WriteResult"
                }
              }
            }
          },
          "404": {
            "description": "Not found, or made by another app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, or `app_suspended` when Treechat suspended the app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/uploads": {
      "post": {
        "operationId": "createUpload",
        "summary": "Get an upload URL for a file to attach to a post",
        "description": "Then PUT the raw bytes to `upload.url` with exactly `upload.headers` (no access token), and pass `signed_id` in createPost `files`. Up to 2 GB per file, 10 GB a day per member.",
        "security": [
          {
            "treechat_oauth": [
              "uploads:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Upload URL issued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadResult"
                }
              }
            }
          },
          "422": {
            "description": "Missing or invalid fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, or `app_suspended` when Treechat suspended the app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/threads": {
      "get": {
        "operationId": "listThreads",
        "summary": "List threads",
        "description": "Without parameters: threads the connected member started. `user`: threads another person started. `public=true`: the public feed.",
        "security": [
          {
            "treechat_oauth": [
              "treechat:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "user",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Username (with or without @), user ID, or `me`."
          },
          {
            "name": "public",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "`true` for the public feed."
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "time",
                "upvalue",
                "upvalueTrending"
              ]
            },
            "description": "Only with public=true. Default `time`."
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Only with public=true and order=time: `pagination.next_cursor` from the previous page."
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "Page size (default 20)."
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Page number for member listings and ranked public orders."
          },
          {
            "name": "space_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Limit to one community."
          }
        ],
        "responses": {
          "200": {
            "description": "Threads.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadList"
                }
              }
            }
          },
          "422": {
            "description": "Invalid combination of parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, or `app_suspended` when Treechat suspended the app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/threads/{id}": {
      "get": {
        "operationId": "getThread",
        "summary": "One thread with its posts",
        "security": [
          {
            "treechat_oauth": [
              "treechat:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Treechat thread ID (UUID)."
          }
        ],
        "responses": {
          "200": {
            "description": "The thread.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not found or not visible to the member.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, or `app_suspended` when Treechat suspended the app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/posts/{id}": {
      "get": {
        "operationId": "getPost",
        "summary": "One post",
        "security": [
          {
            "treechat_oauth": [
              "treechat:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Treechat post ID (UUID)."
          }
        ],
        "responses": {
          "200": {
            "description": "The post.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not found or not visible to the member.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, or `app_suspended` when Treechat suspended the app.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "summary": "List this app's webhooks for the connected person",
        "security": [
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Webhooks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookList"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, `app_suspended`, or `not_enabled` while webhooks are not enabled for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWebhook",
        "summary": "Subscribe to new posts in channels",
        "description": "Treechat POSTs a signed `post.created` event to `url` for each new post in the listed channels (`team_ids`), which must be channels the person picked for the app (channels scope). Posts made through this same app are not sent. The `secret` is returned only here and by rotateWebhookSecret. Verify each delivery: `X-Treechat-Signature` is `sha256=` + hex HMAC-SHA256(secret, `<X-Treechat-Timestamp>.<raw body>`); reject timestamps more than 5 minutes old and dedupe on `X-Treechat-Delivery-Id`. Up to 10 webhooks per person.",
        "security": [
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created. Store the secret now.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookWithSecret"
                }
              }
            }
          },
          "422": {
            "description": "Invalid fields, unsafe URL, a channel this person can't see, or the limit reached.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, `app_suspended`, or `not_enabled` while webhooks are not enabled for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}": {
      "patch": {
        "operationId": "updateWebhook",
        "summary": "Change a webhook's URL, targets or settings",
        "description": "Setting `enabled` to true also clears the failure count of a webhook Treechat switched off.",
        "security": [
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "No such webhook for this app and person.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Invalid fields, unsafe URL, or a channel this person can't see.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, `app_suspended`, or `not_enabled` while webhooks are not enabled for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteWebhook",
        "summary": "Delete a webhook",
        "security": [
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "404": {
            "description": "No such webhook for this app and person.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, `app_suspended`, or `not_enabled` while webhooks are not enabled for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}/rotate_secret": {
      "post": {
        "operationId": "rotateWebhookSecret",
        "summary": "Replace a webhook's signing secret",
        "security": [
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "New secret. The old one stops working now.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookWithSecret"
                }
              }
            }
          },
          "404": {
            "description": "No such webhook for this app and person.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, `app_suspended`, or `not_enabled` while webhooks are not enabled for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}/ping": {
      "post": {
        "operationId": "pingWebhook",
        "summary": "Send a signed `ping` event now",
        "description": "Reports what the receiver answered. Not retried.",
        "security": [
          {
            "treechat_oauth": [
              "channels"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result of the ping.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookPingResult"
                }
              }
            }
          },
          "404": {
            "description": "No such webhook for this app and person.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token missing, expired or revoked (`invalid_token`). Refresh it.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "`insufficient_scope`, `app_suspended`, or `not_enabled` while webhooks are not enabled for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "treechat_oauth": {
        "type": "oauth2",
        "description": "Authorization code with PKCE (S256 required). Send `resource=https://api.treechat.com/mcp` on the authorize and token requests. Access tokens last 15 minutes; refresh tokens are single-use; connections unused for 30 days expire.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://api.treechat.com/mcp/oauth/authorize",
            "tokenUrl": "https://api.treechat.com/mcp/oauth/token",
            "refreshUrl": "https://api.treechat.com/mcp/oauth/token",
            "scopes": {
              "treechat:read": "Read threads and posts the member can see, including private ones",
              "public:write": "Post and reply publicly as you.",
              "channels": "Get new posts from, and post in, the channels you choose.",
              "uploads:write": "Upload images, audio and video",
              "account:read": "Read the member's ID and username"
            }
          }
        }
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "One key per post you mean to make. Same key + same body returns the original result instead of posting twice.",
        "schema": {
          "type": "string",
          "pattern": "^[a-zA-Z0-9._:-]{1,64}$"
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine code, e.g. invalid_token, insufficient_scope, app_suspended, not_found, invalid_arguments, idempotency_conflict, rate_limit_exceeded, daily_limit_reached, rejected, request_failed."
              },
              "message": {
                "type": "string",
                "description": "Human-readable; may change."
              }
            }
          }
        }
      },
      "Me": {
        "type": "object",
        "required": [
          "id",
          "username"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "username": {
            "type": "string"
          },
          "space_id": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PostRequest": {
        "type": "object",
        "additionalProperties": false,
        "description": "At least one of content, delta_json or files. branch_from_post_id excludes thread_id and reply_to_post_id. public, private and space_id are only for new threads.",
        "properties": {
          "content": {
            "type": "string",
            "description": "Plain text."
          },
          "delta_json": {
            "type": "object",
            "description": "Rich text as a Quill Delta, instead of content."
          },
          "files": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "signed_id values from createUpload."
          },
          "thread_id": {
            "type": "string",
            "description": "Reply in this thread."
          },
          "reply_to_post_id": {
            "type": "string",
            "description": "With thread_id: reply to this post."
          },
          "branch_from_post_id": {
            "type": "string",
            "description": "Reply in this post's branch, starting it if needed."
          },
          "public": {
            "type": "boolean",
            "description": "New threads: true for public. Default private."
          },
          "private": {
            "type": "boolean",
            "description": "New threads: the opposite of public."
          },
          "space_id": {
            "type": "string",
            "description": "New threads: the community to post in."
          },
          "channel_id": {
            "type": "string",
            "format": "uuid",
            "description": "New threads only: post in this channel. Needs the channels scope and the channel picked by the person."
          }
        }
      },
      "WriteResult": {
        "type": "object",
        "properties": {
          "operation_id": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "completed",
              "dispatching",
              "uncertain",
              "rejected"
            ]
          },
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The new thread, or the thread/branch the reply landed in."
          },
          "post_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The post that was made."
          }
        }
      },
      "UploadRequest": {
        "type": "object",
        "required": [
          "filename",
          "content_type",
          "byte_size",
          "checksum"
        ],
        "properties": {
          "filename": {
            "type": "string"
          },
          "content_type": {
            "type": "string",
            "description": "MIME type, e.g. image/png."
          },
          "byte_size": {
            "type": "integer",
            "minimum": 1
          },
          "checksum": {
            "type": "string",
            "description": "Base64 MD5 digest of the bytes."
          }
        }
      },
      "UploadResult": {
        "type": "object",
        "required": [
          "signed_id",
          "upload"
        ],
        "properties": {
          "signed_id": {
            "type": "string"
          },
          "upload": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "headers": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Thread": {
        "type": "object",
        "additionalProperties": true,
        "description": "Treechat thread JSON (\"quest\"). Posts are under `answers`. More fields may appear.",
        "properties": {
          "id": {
            "type": "string"
          },
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Post"
            }
          }
        }
      },
      "Post": {
        "type": "object",
        "additionalProperties": true,
        "description": "Treechat post JSON (\"answer\"). More fields may appear.",
        "properties": {
          "id": {
            "type": "string"
          },
          "quest_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The thread it is in."
          },
          "delta_json": {
            "description": "Rich text as a Quill Delta."
          },
          "child_quests": {
            "type": "array",
            "description": "Branches growing out of this post.",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "ThreadEnvelope": {
        "type": "object",
        "required": [
          "quest"
        ],
        "properties": {
          "quest": {
            "$ref": "#/components/schemas/Thread"
          }
        }
      },
      "PostEnvelope": {
        "type": "object",
        "required": [
          "answer"
        ],
        "properties": {
          "answer": {
            "$ref": "#/components/schemas/Post"
          }
        }
      },
      "ThreadList": {
        "type": "object",
        "properties": {
          "threads": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Thread"
            }
          },
          "pagination": {
            "type": "object",
            "description": "Member listings: page, has_more (next: page + 1). Public order=time: limit, next_cursor, has_more (next: before=next_cursor). Public ranked orders: page, limit, next_page, has_more (next: page=next_page).",
            "additionalProperties": true
          }
        }
      },
      "WebhookRequest": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "https only; no private or local hosts."
          },
          "team_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 50,
            "description": "Channels to hear, 1 to 50. Each must be a channel the person picked for the app."
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "post.created"
              ]
            },
            "default": [
              "post.created"
            ]
          },
          "replies_only": {
            "type": "boolean",
            "default": false,
            "description": "Skip posts that start a new thread."
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "Webhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "team_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "replies_only": {
            "type": "boolean"
          },
          "enabled": {
            "type": "boolean"
          },
          "disabled_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "`too_many_failures` after 20 failed deliveries in a row, `gone` after a 410."
          },
          "last_delivered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookEnvelope": {
        "type": "object",
        "properties": {
          "webhook": {
            "$ref": "#/components/schemas/Webhook"
          }
        }
      },
      "WebhookWithSecret": {
        "type": "object",
        "properties": {
          "webhook": {
            "$ref": "#/components/schemas/Webhook"
          },
          "secret": {
            "type": "string"
          }
        }
      },
      "WebhookList": {
        "type": "object",
        "properties": {
          "webhooks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Webhook"
            }
          }
        }
      },
      "WebhookPingResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "error": {
            "type": "string"
          },
          "delivery_id": {
            "type": "string",
            "format": "uuid"
          }
        }
      }
    }
  }
}
