REST API
This page covers the conventions that apply to every REST endpoint. Individual endpoints are documented on their own pages — see the endpoint map.
Requests
- All request bodies are
application/json(the one exception:POST /v1/media/upload, which ismultipart/form-data). - Query parameters are used for filtering and pagination on
GETrequests. - Path parameters (e.g.
{id}) identify a specific resource. - Every request needs an
Authorization: Bearer sx_live_...header — see Authentication.
The OpenAPI spec
GET /api/openapi.json returns the full OpenAPI 3.1.0 specification
(server base /api) with request and response schemas for every route. It is
the most reliable way to introspect the API programmatically.
curl https://<your-api-origin>/api/openapi.json
Responses
All responses are application/json.
-
Success envelope. Successful responses wrap the payload:
{ "data": { "id": "pst_abc123", "status": "scheduled" } }List endpoints return the array plus their paging echo inside
datasiblings — e.g.GET /v1/postsreturns{ "data": [...], "limit": 25, "offset": 0 }, andGET /v1/mediaandGET /v1/inboxreturn{ "data": { "items": [...], "total": 42 } }. -
Status depends on the operation.
POST /v1/postsreturns201 Created. Starting a clipping job returns202 Accepted; processing continues asynchronously. Other documented successful mutations normally return200 OK. Check the endpoint reference. -
Deletes return
{ "data": { "success": true } }.
Pagination
Most list endpoints accept two query parameters:
| Parameter | Type | Default | Range |
|---|---|---|---|
limit | integer | 25 | 1–100 (media defaults to 24) |
offset | integer | 0 | ≥ 0 |
curl "https://<your-api-origin>/api/v1/posts?limit=10&offset=20" \
-H "Authorization: Bearer sx_live_YOUR_API_KEY"
{
"data": [{ "id": "pst_abc123", "...": "..." }],
"limit": 10,
"offset": 20
}
Endpoints that don't paginate: GET /v1/accounts and GET /v1/comments
return plain arrays inside data.
Validation
Each route validates its input (query, body, or path params) against a schema
before the handler runs. Invalid input short-circuits with 400 carrying a
Zod-style error listing exactly which fields failed.
Handler-level validation errors use the structured shape:
{
"error": {
"code": "validation_error",
"message": "Provide a `file` form field"
}
}
Creating a post runs an additional layer of validation against
platform limits — a 400 (constraint violation) or
403 (ownership/forbidden) is returned if the post would break a platform
rule. See Errors for the complete catalog.
Versioning
The API is versioned in the path (/v1/...). Breaking changes will ship under
a new version; non-breaking additions (new fields, new endpoints) happen within
v1.
Next
- Authentication — if you skipped it.
- Posts — the core endpoints.
- Errors — status codes and error shapes.
- Examples — ready-to-run recipes.