{"openapi":"3.1.0","info":{"title":"PostForAI API","version":"1.0.0","summary":"Developer-first Social Publishing REST API & MCP Server (11 official platforms)","description":"PostForAI is a unified REST API (`/v1`) and Model Context Protocol server (`/mcp`, spec `2025-11-25`) for publishing, scheduling, media hosting, and signed webhooks across 11 official social platforms.\n\n### Authentication\n- **API Keys (`/v1/*` and `/mcp`):** send `X-API-Key: sp_live_...` (or `Authorization: Bearer sp_live_...`). Keys are organization-scoped, fine-grained by permissions, and support sandbox keys (`sp_test_...`) that simulate publishing without hitting external networks.\n- **OAuth 2.1 + DCR (`/mcp`):** AI clients (Claude, ChatGPT, Cursor) discover OAuth via `/.well-known/oauth-protected-resource` (RFC 9728) and register dynamically with PKCE.\n\n### Conventions\n- All timestamps are strict **ISO-8601 UTC** (e.g. `2026-12-01T18:00:00Z`).\n- `POST /v1/posts` supports `Idempotency-Key` (1–128 printable ASCII chars) for safe retries.\n- Outbound webhooks are signed with HMAC-SHA256 in `X-PostForAI-Signature: t=<unix>,v1=<hex>`.","contact":{"name":"PostForAI","url":"https://postforai.com/docs"}},"servers":[{"url":"https://postforai.com","description":"Production"},{"url":"/","description":"Current host"}],"tags":[{"name":"Organization","description":"Inspect the authenticated organization, API key permissions, plan, and members."},{"name":"Platforms & BYO OAuth","description":"Discover supported platforms and configure Bring-Your-Own (BYO) OAuth app credentials encrypted at rest."},{"name":"Social Accounts","description":"Generate stateless B2B OAuth links for end users, connect direct platforms (Discord, Telegram, Bluesky), inspect capabilities, and disconnect accounts."},{"name":"Media","description":"Streaming upload to R2 (<=100 MB), S3 SigV4 Presigned PUT (>100 MB up to 4 GiB), magic-byte confirmation, and public delivery."},{"name":"Posts","description":"Create, schedule (UTC ISO-8601), draft, update, publish immediately, and delete multi-account social posts."},{"name":"Post Results","description":"Inspect per-account delivery status, external URLs, retries, and manually resolve ambiguous (`uncertain`) outcomes."},{"name":"Webhooks","description":"Manage HMAC-signed outbound webhook endpoints, rotate secrets, send test pings, inspect logs, and replay deliveries."},{"name":"MCP & Discovery","description":"Model Context Protocol Streamable HTTP endpoint (`2025-11-25`) and OAuth 2.1 discovery metadata (RFC 9728 / RFC 8414)."}],"paths":{"/v1/me":{"get":{"tags":["Organization"],"operationId":"getMe","summary":"Get authenticated organization and API key metadata","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"responses":{"200":{"description":"Organization, plan, environment, and key permissions","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/OrganizationMe"}}}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Key lacks organization:read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/members":{"get":{"tags":["Organization"],"operationId":"listMembers","summary":"List organization members","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"responses":{"200":{"description":"Organization members","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/OrgMember"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Key lacks members:read","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/platforms":{"get":{"tags":["Platforms & BYO OAuth"],"operationId":"listPlatforms","summary":"List all 11 supported social platforms and base limits","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"responses":{"200":{"description":"Supported platforms catalog","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PlatformCatalogItem"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/oauth-apps":{"get":{"tags":["Platforms & BYO OAuth"],"operationId":"listOAuthApps","summary":"List BYO OAuth apps configured for the organization","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"responses":{"200":{"description":"Configured BYO OAuth apps (secrets omitted)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ByoOAuthApp"}}}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/oauth-apps/{platform}":{"get":{"tags":["Platforms & BYO OAuth"],"operationId":"getOAuthApp","summary":"Get BYO OAuth app for a platform","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"platform","in":"path","required":true,"description":"Social platform identifier","schema":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]}}],"responses":{"200":{"description":"BYO OAuth app details","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/ByoOAuthApp"}}}}}},"400":{"description":"Unsupported platform","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"No BYO app configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"tags":["Platforms & BYO OAuth"],"operationId":"upsertOAuthApp","summary":"Create or update a BYO OAuth app for a platform","description":"Client secrets are encrypted at rest with AES-256-GCM. Omitting `clientSecret` on update preserves the stored ciphertext.","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"platform","in":"path","required":true,"description":"Social platform identifier","schema":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpsertByoOAuthAppRequest"}}}},"responses":{"200":{"description":"BYO OAuth app saved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpsertByoOAuthAppResponse"}}}},"400":{"description":"Invalid payload or platform does not accept BYO","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Key lacks accounts:write","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Platforms & BYO OAuth"],"operationId":"deleteOAuthApp","summary":"Delete BYO OAuth app for a platform","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"platform","in":"path","required":true,"description":"Social platform identifier","schema":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]}}],"responses":{"200":{"description":"BYO OAuth app removed","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","properties":{"deleted":{"type":"boolean"},"accounts_to_reconnect":{"type":"integer"}}}}}}}},"404":{"description":"No BYO app configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/social-accounts/auth-url":{"post":{"tags":["Social Accounts"],"operationId":"createSocialAccountAuthUrl","summary":"Create stateless B2B OAuth URL for an end user","description":"Generates a single-use OAuth authorization link (15-minute TTL) that connects an end user’s social account without requiring a PostForAI dashboard session.","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAuthUrlRequest"}}}},"responses":{"201":{"description":"Authorization URL created","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/CreateAuthUrlResponse"}}}}}},"400":{"description":"Invalid payload, invalid redirect_url_override, or direct-connect platform","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"BYO OAuth credentials required (e.g. X)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/social-accounts/connect":{"post":{"tags":["Social Accounts"],"operationId":"connectDirectSocialAccount","summary":"Connect Discord, Telegram, or Bluesky directly","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DirectConnectRequest"}}}},"responses":{"200":{"description":"Existing account updated","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/SocialAccount"}}}}}},"201":{"description":"Account connected","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/SocialAccount"}}}}}},"400":{"description":"Invalid credentials or OAuth-only platform","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Plan account limit reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/social-accounts":{"get":{"tags":["Social Accounts"],"operationId":"listSocialAccounts","summary":"List connected social accounts","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"platform","in":"query","required":false,"description":"Filter by platform","schema":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]}},{"name":"external_id","in":"query","required":false,"description":"Filter by B2B end-user external_id","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"Filter by status","schema":{"type":"string","enum":["connected","needs_reauth","disconnected"]}},{"name":"limit","in":"query","required":false,"description":"Max accounts (1–50, default 50)","schema":{"type":"integer","minimum":1,"maximum":50}}],"responses":{"200":{"description":"Social accounts list","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SocialAccount"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"}}}}}}}},"400":{"description":"Unsupported platform filter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/social-accounts/{id}":{"get":{"tags":["Social Accounts"],"operationId":"getSocialAccount","summary":"Get social account by ID","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Social account ID (`sa_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Social account details","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/SocialAccount"}}}}}},"404":{"description":"Social account not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Social Accounts"],"operationId":"disconnectSocialAccount","summary":"Disconnect social account and wipe encrypted tokens","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Social account ID (`sa_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Social account disconnected","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/SocialAccount"}}}}}},"404":{"description":"Social account not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/social-accounts/{id}/capabilities":{"get":{"tags":["Social Accounts"],"operationId":"getSocialAccountCapabilities","summary":"Get static and dynamic capabilities for a social account","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Social account ID (`sa_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Merged static + dynamic capabilities","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"404":{"description":"Social account not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/oauth/{platform}/callback":{"get":{"tags":["Social Accounts"],"operationId":"oauthCallback","summary":"Public stateless B2B OAuth callback","description":"Provider redirect endpoint. Atomically consumes the single-use `state` from `oauth_states` and redirects to `redirect_url_override` if configured, or returns JSON.","security":[],"parameters":[{"name":"platform","in":"path","required":true,"description":"OAuth platform identifier","schema":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]}},{"name":"state","in":"query","required":false,"description":"Opaque single-use state token","schema":{"type":"string"}},{"name":"code","in":"query","required":false,"description":"Provider authorization code","schema":{"type":"string"}},{"name":"error","in":"query","required":false,"description":"Provider error code (if denied)","schema":{"type":"string"}}],"responses":{"200":{"description":"Connected accounts JSON (when no redirect_url_override was given)"},"302":{"description":"Redirect to validated `redirect_url_override`"},"400":{"description":"Invalid, used, or expired state","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/media":{"get":{"tags":["Media"],"operationId":"listMedia","summary":"List organization media assets","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"limit","in":"query","required":false,"description":"Max items (1–50, default 25)","schema":{"type":"integer","minimum":1,"maximum":50}}],"responses":{"200":{"description":"Media assets list","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MediaAsset"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"}}}}}}}}}},"put":{"tags":["Media"],"operationId":"uploadMediaStreaming","summary":"Streaming binary upload to R2 (<=100 MB)","description":"Streams raw binary directly to R2 while verifying magic bytes and exact `Content-Length`. For videos >100 MB (up to 4 GiB), use `POST /v1/media/upload-url`.","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"Content-Type","in":"header","required":true,"description":"Supported MIME type (image/jpeg, image/png, image/webp, image/gif, video/mp4, video/quicktime, application/pdf, etc.)","schema":{"type":"string"}},{"name":"Content-Length","in":"header","required":true,"description":"Exact binary size in bytes","schema":{"type":"integer"}},{"name":"X-Duration-Ms","in":"header","required":false,"description":"Optional video duration in milliseconds","schema":{"type":"integer"}}],"requestBody":{"required":true,"content":{"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/png":{"schema":{"type":"string","format":"binary"}},"video/mp4":{"schema":{"type":"string","format":"binary"}},"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"responses":{"201":{"description":"Media uploaded and verified ready","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/MediaAsset"}}}}}},"411":{"description":"Missing or invalid Content-Length","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"413":{"description":"File exceeds streaming limit or org quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"415":{"description":"Unsupported MIME type or magic-byte mismatch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/media/upload-url":{"post":{"tags":["Media"],"operationId":"createMediaUploadUrl","summary":"Create SigV4 S3 Presigned PUT URL for large files (>100 MB up to 4 GiB)","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUploadUrlRequest"}}}},"responses":{"201":{"description":"Presigned PUT URL and pending media asset","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/CreateUploadUrlResponse"}}}}}},"400":{"description":"Invalid payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"413":{"description":"Exceeds size limit or org media quota","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"415":{"description":"Unsupported contentType","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Presigned R2 upload credentials not configured","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/media/{id}":{"get":{"tags":["Media"],"operationId":"getMedia","summary":"Get media asset by ID","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Media asset ID (`med_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Media asset details","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/MediaAsset"}}}}}},"404":{"description":"Media asset not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Media"],"operationId":"deleteMedia","summary":"Delete media asset (D1-first + durable R2 GC)","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Media asset ID (`med_...`)","schema":{"type":"string"}}],"responses":{"204":{"description":"Media asset deleted"},"404":{"description":"Media asset not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/media/{id}/confirm":{"post":{"tags":["Media"],"operationId":"confirmMediaUpload","summary":"Confirm a presigned R2 upload (verifies magic bytes + size)","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Media asset ID (`med_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Media verified and marked ready","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/MediaAsset"}}}}}},"404":{"description":"Media asset or uploaded R2 object not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"415":{"description":"Uploaded bytes do not match declared Content-Type","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/m/{publicId}":{"get":{"tags":["Media"],"operationId":"servePublicMedia","summary":"Public media delivery (images and videos only, HTTP Range 206)","description":"Used by Instagram, TikTok, and other platforms that pull media by URL. Documents (PDF/DOC/PPT) are never served publicly and return 404.","security":[],"parameters":[{"name":"publicId","in":"path","required":true,"description":"Opaque 32-hex public media identifier","schema":{"type":"string"}}],"responses":{"200":{"description":"Full media binary"},"206":{"description":"Partial byte range"},"404":{"description":"Not found or non-public document"}}}},"/v1/posts":{"post":{"tags":["Posts"],"operationId":"createPost","summary":"Create, schedule, draft, or immediately publish a post","description":"Validates captions, media, and per-platform rules across all target accounts before persisting. Send `Idempotency-Key` to guarantee safe retries.","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"1–128 printable ASCII chars. Replays exact 201 response on retry; returns 409 on payload mismatch.","schema":{"type":"string","minLength":1,"maxLength":128}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePostRequest"}}}},"responses":{"201":{"description":"Post created with per-account targets","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Post"}}}}}},"400":{"description":"Invalid body, non-UTC timestamp, or platform validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"One or more social_accounts or media_ids not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Idempotency conflict / in-progress or monthly post quota reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"get":{"tags":["Posts"],"operationId":"listPosts","summary":"List posts in the active organization and key environment","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"status","in":"query","required":false,"description":"Filter by status","schema":{"type":"string","enum":["draft","scheduled","processing","published","partial","failed"]}},{"name":"external_id","in":"query","required":false,"description":"Filter by external correlation ID","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Max items (1–50, default 25)","schema":{"type":"integer","minimum":1,"maximum":50}}],"responses":{"200":{"description":"Posts list","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Post"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"}}}}}}}}}}},"/v1/posts/{id}":{"get":{"tags":["Posts"],"operationId":"getPost","summary":"Get a post and all per-account targets","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Post ID (`pst_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Post with targets","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Post"}}}}}},"404":{"description":"Post not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Posts"],"operationId":"updatePost","summary":"Update a draft or future-scheduled post","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Post ID (`pst_...`)","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdatePostRequest"}}}},"responses":{"200":{"description":"Post updated","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Post"}}}}}},"400":{"description":"Invalid update payload","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Post not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Post is already processing or published","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Posts"],"operationId":"deletePost","summary":"Delete or cancel a post","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Post ID (`pst_...`)","schema":{"type":"string"}}],"responses":{"204":{"description":"Post deleted"},"404":{"description":"Post not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Cannot delete while target holds an active publish lease","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/posts/{id}/publish-now":{"post":{"tags":["Posts"],"operationId":"publishPostNow","summary":"Promote a draft or scheduled post for immediate publication","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Post ID (`pst_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Post enqueued for immediate publication","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Post"}}}}}},"404":{"description":"Post not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Post is not editable/schedulable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/post-results":{"get":{"tags":["Post Results"],"operationId":"listPostResults","summary":"List per-account publish results","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"post_id","in":"query","required":false,"description":"Filter by post ID","schema":{"type":"string"}},{"name":"social_account_id","in":"query","required":false,"description":"Filter by social account ID","schema":{"type":"string"}},{"name":"platform","in":"query","required":false,"description":"Filter by platform","schema":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]}},{"name":"status","in":"query","required":false,"description":"Filter by target status","schema":{"type":"string","enum":["pending","processing","published","failed","uncertain"]}},{"name":"limit","in":"query","required":false,"description":"Max items (1–50, default 25)","schema":{"type":"integer","minimum":1,"maximum":50}}],"responses":{"200":{"description":"Per-account publish results","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PostTarget"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"}}}}}}}},"400":{"description":"Unsupported platform filter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/post-results/{id}":{"get":{"tags":["Post Results"],"operationId":"getPostResult","summary":"Get a single per-account publish result","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Post target/result ID (`pt_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Post result details","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/PostTarget"}}}}}},"404":{"description":"Post result not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/post-results/{id}/resolve-uncertain":{"post":{"tags":["Post Results"],"operationId":"resolveUncertainPostResult","summary":"Conservatively resolve an uncertain publish result as published","description":"When a social platform times out after a publish checkpoint, PostForAI never blind-retries (at-most-once). After verifying the post on the network, call this endpoint to mark it `published`.","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Post target/result ID (`pt_...`)","schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveUncertainRequest"}}}},"responses":{"200":{"description":"Uncertain target resolved as published","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/PostTarget"}}}}}},"404":{"description":"Post result not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Target is not in uncertain state","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/webhooks":{"get":{"tags":["Webhooks"],"operationId":"listWebhooks","summary":"List outbound webhooks","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"responses":{"200":{"description":"Configured webhooks (secrets omitted)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}}}}}}}}},"post":{"tags":["Webhooks"],"operationId":"createWebhook","summary":"Create an HMAC-signed outbound webhook endpoint","description":"URL must be a public `https://` domain on standard port 443. The `whsec_...` signing secret is returned ONCE in the 201 response.","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWebhookRequest"}}}},"responses":{"201":{"description":"Webhook created (includes one-time secret)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/WebhookWithSecret"}}}}}},"400":{"description":"Invalid/blocked URL or unknown event type","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Duplicate URL or plan webhook quota reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/webhooks/{id}":{"get":{"tags":["Webhooks"],"operationId":"getWebhook","summary":"Get webhook endpoint by ID","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook ID (`wh_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Webhook details","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Webhook"}}}}}},"404":{"description":"Webhook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"tags":["Webhooks"],"operationId":"updateWebhook","summary":"Update webhook URL, events, or enabled flag","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook ID (`wh_...`)","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateWebhookRequest"}}}},"responses":{"200":{"description":"Webhook updated","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/Webhook"}}}}}},"400":{"description":"Invalid payload or URL","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Webhook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Duplicate webhook URL","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"tags":["Webhooks"],"operationId":"deleteWebhook","summary":"Delete webhook endpoint and its delivery history","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook ID (`wh_...`)","schema":{"type":"string"}}],"responses":{"204":{"description":"Webhook deleted"},"404":{"description":"Webhook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/webhooks/{id}/rotate-secret":{"post":{"tags":["Webhooks"],"operationId":"rotateWebhookSecret","summary":"Rotate webhook signing secret (`whsec_...`)","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook ID (`wh_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"New signing secret generated (shown once)","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/WebhookWithSecret"}}}}}},"404":{"description":"Webhook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/webhooks/{id}/test":{"post":{"tags":["Webhooks"],"operationId":"testWebhook","summary":"Send immediate signed `webhook.test` delivery (10s cooldown)","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook ID (`wh_...`)","schema":{"type":"string"}}],"responses":{"200":{"description":"Test delivery outcome","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/WebhookTestResult"}}}}}},"404":{"description":"Webhook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Wait 10 seconds between test deliveries","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/webhooks/{id}/deliveries":{"get":{"tags":["Webhooks"],"operationId":"listWebhookDeliveries","summary":"List recent delivery attempts for a webhook","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook ID (`wh_...`)","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Max deliveries (1–50, default 25)","schema":{"type":"integer","minimum":1,"maximum":50}}],"responses":{"200":{"description":"Webhook deliveries","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookDelivery"}},"meta":{"type":"object","properties":{"count":{"type":"integer"},"limit":{"type":"integer"}}}}}}}},"404":{"description":"Webhook not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/webhooks/{id}/deliveries/{deliveryId}/replay":{"post":{"tags":["Webhooks"],"operationId":"replayWebhookDelivery","summary":"Clone and re-enqueue a webhook delivery","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Webhook ID (`wh_...`)","schema":{"type":"string"}},{"name":"deliveryId","in":"path","required":true,"description":"Delivery ID (`whd_...`)","schema":{"type":"string"}}],"responses":{"202":{"description":"Replay delivery enqueued","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/WebhookDelivery"}}}}}},"404":{"description":"Webhook delivery not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/mcp":{"post":{"tags":["MCP & Discovery"],"operationId":"mcpJsonRpc","summary":"Model Context Protocol Streamable HTTP endpoint (`2025-11-25`)","description":"Stateless JSON-RPC 2.0 endpoint supporting anonymous discovery (`initialize`, `ping`, `tools/list`) and dual-auth tool execution via API Key (`X-API-Key` / `Bearer sp_live_…`) or OAuth 2.1 DCR (`Authorization: Bearer <at+jwt>`).","security":[{"apiKeyHeader":[]},{"bearerApiKey":[]},{"oauth2Mcp":["openid","profile","email","offline_access"]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["jsonrpc","method"],"properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"oneOf":[{"type":"string"},{"type":"integer"},{"type":"null"}]},"method":{"type":"string","examples":["initialize","ping","tools/list","tools/call"]},"params":{"type":"object"}}}}}},"responses":{"200":{"description":"JSON-RPC 2.0 response"},"202":{"description":"Notification acknowledged"},"400":{"description":"Malformed JSON-RPC or unsupported batch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Missing/invalid token (includes RFC 9728 WWW-Authenticate)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/.well-known/oauth-protected-resource":{"get":{"tags":["MCP & Discovery"],"operationId":"getOAuthProtectedResourceMetadata","summary":"RFC 9728 OAuth Protected Resource Metadata for `/mcp`","security":[],"responses":{"200":{"description":"Protected resource metadata","content":{"application/json":{"schema":{"type":"object","required":["resource","authorization_servers"],"properties":{"resource":{"type":"string","format":"uri"},"authorization_servers":{"type":"array","items":{"type":"string","format":"uri"}},"bearer_methods_supported":{"type":"array","items":{"type":"string"}},"scopes_supported":{"type":"array","items":{"type":"string"}}}}}}}}}}},"components":{"securitySchemes":{"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Organization API key (`sp_live_...` or `sp_test_...`)."},"bearerApiKey":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"Same organization API key passed as `Authorization: Bearer sp_live_...`."},"oauth2Mcp":{"type":"oauth2","description":"OAuth 2.1 Authorization Code + PKCE (with Dynamic Client Registration) for `/mcp`.","flows":{"authorizationCode":{"authorizationUrl":"https://postforai.com/api/auth/oauth2/authorize","tokenUrl":"https://postforai.com/api/auth/oauth2/token","scopes":{"openid":"OpenID identity","profile":"User profile","email":"User email","offline_access":"Refresh tokens"}}}}},"schemas":{"ErrorResponse":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{}}}}},"OrganizationMe":{"type":"object","required":["organization","accessLevel","permissions","plan","environment"],"properties":{"organization":{"type":"object","required":["id","name"],"properties":{"id":{"type":"string"},"name":{"type":"string"}}},"accessLevel":{"type":"string","enum":["read","operate","admin","custom"]},"permissions":{"type":"array","items":{"type":"string"}},"plan":{"type":"string","enum":["none","trial","starter","pro","scale"]},"environment":{"type":"string","enum":["live","test"]}}},"OrgMember":{"type":"object","properties":{"id":{"type":"string"},"role":{"type":"string","enum":["owner","admin","member","viewer"]},"createdAt":{"type":"string","format":"date-time"},"user":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":["string","null"]},"email":{"type":"string","format":"email"},"image":{"type":["string","null"]}}}}},"PlatformCatalogItem":{"type":"object","properties":{"platform":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]},"displayName":{"type":"string"},"authType":{"type":"string","enum":["oauth","webhook","bot_token","app_password"]},"byoPolicy":{"type":"string","enum":["required","optional","none"]},"formats":{"type":"array","items":{"type":"string"}},"refreshLeadMs":{"type":"integer"},"rotatingRefreshToken":{"type":"boolean"}}},"ByoOAuthApp":{"type":"object","properties":{"id":{"type":"string"},"platform":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]},"ambiente":{"type":"string","enum":["live","test"]},"clientId":{"type":"string"},"hasClientSecret":{"type":"boolean"},"scopes":{"type":"array","items":{"type":"string"}},"redirectUri":{"type":"string"},"extra":{"type":"object","additionalProperties":{"type":"string"}},"ativo":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"UpsertByoOAuthAppRequest":{"type":"object","required":["clientId"],"properties":{"clientId":{"type":"string"},"clientSecret":{"type":"string","description":"Optional on update to preserve stored secret."},"scopes":{"type":"array","items":{"type":"string"}},"redirectUri":{"type":"string"},"extra":{"type":"object","additionalProperties":{"type":"string"},"description":"Provider extras, e.g. `{\"configId\":\"...\"}` for Meta Login for Business."},"ativo":{"type":"boolean","default":true}}},"UpsertByoOAuthAppResponse":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ByoOAuthApp"},"meta":{"type":"object","properties":{"accounts_to_reconnect":{"type":"integer"}}}}},"CreateAuthUrlRequest":{"type":"object","required":["platform"],"properties":{"platform":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]},"external_id":{"type":"string","maxLength":128},"permissions":{"type":"array","items":{"type":"string"}},"connection_type":{"type":"string","enum":["auto","byo","managed"],"default":"auto"},"redirect_url_override":{"type":"string","format":"uri","maxLength":500},"mode":{"type":"string"},"reauthenticate":{"type":"boolean"}}},"CreateAuthUrlResponse":{"type":"object","properties":{"auth_url":{"type":"string","format":"uri"},"expires_at":{"type":"string","format":"date-time"},"auth_mode":{"type":"string","enum":["byo","managed"]},"platform":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]}}},"DirectConnectRequest":{"type":"object","required":["platform","credentials"],"properties":{"platform":{"type":"string","enum":["discord","telegram","bluesky"]},"external_id":{"type":"string","maxLength":128},"credentials":{"type":"object","description":"Discord `{webhookUrl}`, Telegram `{botToken, chatId}`, Bluesky `{identifier, appPassword}`."}}},"SocialAccount":{"type":"object","properties":{"id":{"type":"string"},"platform":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]},"external_id":{"type":["string","null"]},"platform_account_id":{"type":"string"},"username":{"type":"string"},"display_name":{"type":"string"},"avatar_url":{"type":["string","null"]},"auth_mode":{"type":"string"},"status":{"type":"string","enum":["connected","needs_reauth","disconnected"]},"refresh_state":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"token_expires_at":{"type":["string","null"],"format":"date-time"},"last_probe_at":{"type":["string","null"],"format":"date-time"},"last_error":{"type":["string","null"]},"disconnected_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"MediaAsset":{"type":"object","properties":{"id":{"type":"string"},"publicId":{"type":"string"},"kind":{"type":"string","enum":["image","video","document"]},"status":{"type":"string","enum":["pending","ready","deleted"]},"contentType":{"type":"string"},"sizeBytes":{"type":"integer"},"width":{"type":["integer","null"]},"height":{"type":["integer","null"]},"durationMs":{"type":["integer","null"]},"sourceKind":{"type":"string","enum":["stream","presigned"]},"url":{"type":["string","null"],"format":"uri"},"expiresAt":{"type":["string","null"],"format":"date-time"},"createdAt":{"type":"string","format":"date-time"}}},"CreateUploadUrlRequest":{"type":"object","required":["contentType","sizeBytes"],"properties":{"contentType":{"type":"string"},"sizeBytes":{"type":"integer","minimum":1},"width":{"type":"integer","minimum":1},"height":{"type":"integer","minimum":1},"durationMs":{"type":"integer","minimum":1}}},"CreateUploadUrlResponse":{"type":"object","properties":{"asset":{"$ref":"#/components/schemas/MediaAsset"},"uploadUrl":{"type":"string","format":"uri"},"expiresAt":{"type":"string","format":"date-time"},"requiredHeaders":{"type":"object","properties":{"content-type":{"type":"string"},"content-length":{"type":"string"}}}}},"CreatePostRequest":{"type":"object","required":["social_accounts"],"properties":{"caption":{"type":"string","maxLength":65000},"title":{"type":"string","maxLength":300},"social_accounts":{"type":"array","items":{"type":"string"},"minItems":1,"maxItems":50},"media":{"type":"array","items":{"oneOf":[{"type":"object","required":["media_id"],"properties":{"media_id":{"type":"string"},"alt_text":{"type":"string"}}},{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri"},"kind":{"type":"string","enum":["image","video","document"]},"content_type":{"type":"string"},"alt_text":{"type":"string"}}}]}},"scheduled_at":{"type":["string","null"],"format":"date-time","description":"Strict ISO-8601 UTC timestamp with timezone offset (e.g. 2026-12-01T18:00:00Z)."},"is_draft":{"type":"boolean","default":false},"external_id":{"type":"string","maxLength":128},"platform_configurations":{"type":"object"},"account_configurations":{"type":"array","items":{"type":"object","required":["social_account_id","configuration"],"properties":{"social_account_id":{"type":"string"},"configuration":{"type":"object"}}}}}},"UpdatePostRequest":{"type":"object","properties":{"caption":{"type":"string","maxLength":65000},"title":{"type":"string","maxLength":300},"scheduled_at":{"type":["string","null"],"format":"date-time"},"is_draft":{"type":"boolean"},"platform_configurations":{"type":"object"}}},"Post":{"type":"object","properties":{"id":{"type":"string"},"external_id":{"type":["string","null"]},"caption":{"type":"string"},"title":{"type":["string","null"]},"media":{"type":"array","items":{"type":"object"}},"platform_configurations":{"type":"object"},"status":{"type":"string","enum":["draft","scheduled","processing","published","partial","failed"]},"environment":{"type":"string","enum":["live","test"]},"scheduled_at":{"type":["string","null"],"format":"date-time"},"published_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"targets":{"type":"array","items":{"$ref":"#/components/schemas/PostTarget"}}}},"PostTarget":{"type":"object","properties":{"id":{"type":"string"},"post_id":{"type":"string"},"social_account_id":{"type":["string","null"]},"target_account_key":{"type":"string"},"platform":{"type":"string","enum":["instagram","facebook","tiktok","youtube","linkedin","x","threads","pinterest","discord","telegram","bluesky"]},"status":{"type":"string","enum":["pending","processing","published","failed","uncertain"]},"attempts":{"type":"integer"},"max_attempts":{"type":"integer"},"poll_count":{"type":"integer"},"external_post_id":{"type":["string","null"]},"external_post_url":{"type":["string","null"],"format":"uri"},"error_code":{"type":["string","null"]},"error_message":{"type":["string","null"]},"next_attempt_at":{"type":["string","null"],"format":"date-time"},"published_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"ResolveUncertainRequest":{"type":"object","properties":{"external_post_id":{"type":["string","null"],"maxLength":200},"external_post_url":{"type":["string","null"],"format":"uri","maxLength":2048}}},"Webhook":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string","enum":["social.post.result.created","social.post.updated","social.account.created","social.account.updated","social.account.disconnected"]}},"secret_prefix":{"type":"string"},"enabled":{"type":"boolean"},"consecutive_failures":{"type":"integer"},"last_delivered_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"WebhookWithSecret":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string","enum":["social.post.result.created","social.post.updated","social.account.created","social.account.updated","social.account.disconnected"]}},"secret_prefix":{"type":"string"},"secret":{"type":"string","description":"One-time HMAC signing secret (`whsec_...`)."},"enabled":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"}}},"CreateWebhookRequest":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri","maxLength":500},"events":{"type":"array","items":{"type":"string","enum":["social.post.result.created","social.post.updated","social.account.created","social.account.updated","social.account.disconnected","*"]}},"enabled":{"type":"boolean","default":true}}},"UpdateWebhookRequest":{"type":"object","properties":{"url":{"type":"string","format":"uri","maxLength":500},"events":{"type":"array","items":{"type":"string","enum":["social.post.result.created","social.post.updated","social.account.created","social.account.updated","social.account.disconnected","*"]}},"enabled":{"type":"boolean"}}},"WebhookTestResult":{"type":"object","properties":{"delivery_id":{"type":"string"},"delivered":{"type":"boolean"},"http_status":{"type":["integer","null"]},"error":{"type":["string","null"]}}},"WebhookDelivery":{"type":"object","properties":{"id":{"type":"string"},"webhook_id":{"type":"string"},"event_id":{"type":"string"},"event_type":{"type":"string"},"status":{"type":"string","enum":["pending","delivering","delivered","failed"]},"attempts":{"type":"integer"},"http_status":{"type":["integer","null"]},"response_snippet":{"type":["string","null"]},"next_attempt_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}}}}}