# API reference

The REST API is at `https://app.postaki.io/api/v1/`. It speaks JSON, and the OpenAPI 3.1 document is at
`https://app.postaki.io/api/v1/openapi.json` (a copy is at [/docs/openapi.json](https://postaki.io/docs/openapi.json)). Send
`Authorization: Bearer <key or token>` on every request, see [Authentication](https://postaki.io/docs/authentication/). Times are RFC
3339 with an offset. Lists use cursors: `limit` up to 100 and `next_cursor`.

A post made through the API is never published without a person's approval. Every `POST`, `PATCH` and `DELETE` takes an
`Idempotency-Key` header, see [Idempotency](https://postaki.io/docs/idempotency/). Limits are in [Rate limits](https://postaki.io/docs/rate-limits/) and
errors in [Errors](https://postaki.io/docs/errors/).

## Endpoints

| Method | Path | What it does | Operation |
|---|---|---|---|
| `GET` | `/api/v1/brands` | The workspace's brands | `list_brands` |
| `GET` | `/api/v1/brands/{brand_id}/channels` | A brand's channels with their capabilities and the shared caps left today | `list_channels` |
| `GET` | `/api/v1/channels/{channel_id}/options` | The options of a channel (TikTok: the account's own settings, read now) | `channel_options` |
| `GET` | `/api/v1/me` | The workspace, user, role, scopes and plan limits of this credential | `me` |
| `POST` | `/api/v1/media` | Add media from a public https URL (fetched by a worker; poll get_media) | `add_media_from_url` |
| `GET` | `/api/v1/media/{media_id}` | Processing status and facts of one media item | `get_media` |
| `POST` | `/api/v1/media/uploads` | Announce a file and get a single-use URL to PUT its bytes to | `create_media_upload` |
| `POST` | `/api/v1/media/uploads/{upload_id}/complete` | Say the bytes are uploaded; processing starts (poll get_media) | `complete_media_upload` |
| `GET` | `/api/v1/posts` | Posts, newest first, with cursor pagination | `list_posts` |
| `POST` | `/api/v1/posts` | Create a post: a draft, or with submit true waiting for a person's approval | `create_post` |
| `GET` | `/api/v1/posts/{post_id}` | One post with its variants, their status, errors and approval | `get_post` |
| `PATCH` | `/api/v1/posts/{post_id}` | Change a draft or a post waiting for approval | `update_post` |
| `DELETE` | `/api/v1/posts/{post_id}` | Delete a post that was never sent or approved | `delete_post` |
| `POST` | `/api/v1/posts/{post_id}/delete-published` | Take sent copies down from their channels, where the platform allows | `delete_published_post` |
| `POST` | `/api/v1/posts/{post_id}/submit` | Send the draft copies of a post for a person's approval | `submit_post` |
| `POST` | `/api/v1/posts/validate` | Check a post without saving it: the issues per channel and field | `validate_post` |
| `GET` | `/api/v1/webhooks` | The workspace's webhook endpoints (never the secret) | `list_webhooks` |
| `POST` | `/api/v1/webhooks` | Register an https endpoint for events | `create_webhook` |
| `DELETE` | `/api/v1/webhooks/{webhook_id}` | Remove a webhook endpoint | `delete_webhook` |

## Interactive reference

The reference below is drawn from the OpenAPI document by a script served from this site. It loads nothing from other
sites.
