The Kickline API
v1 · bearer keys · 60 requests a minute
Keys are made in Workspace, under API. Download the agent skill.
# The kickline API, v1
Everything the screens do, a script can do: list posts, generate one from a source, schedule it,
cancel it. Base URL is your deployment's origin; every path below is under `/api/v1`.
## Authentication
```
Authorization: Bearer kk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```
Keys are made in **Workspace › API** by an owner, and are shown **once**. kickline stores a
SHA-256 of the key and its first twelve characters, so a lost key cannot be recovered — revoke it
and make another.
A key is **per workspace**. It can read and write that workspace's posts and nothing else. Keys
are `kk_test_…` on a test-mode deployment and `kk_live_…` otherwise.
Every failure to authenticate is the same:
```
401 WWW-Authenticate: Bearer realm="kickline"
{ "error": { "code": "unauthorized", "message": "A valid API key is required." } }
```
Missing, malformed, unknown and revoked keys all answer that. Telling them apart would tell
whoever found a key whether it is real.
API keys require **Growth or Pro** when the deployment enforces billing. A deployment with
billing switched off has an open API.
## Rate limits
**60 requests a minute per key**, as a continuously refilling token bucket — so 60 in one second
is allowed once, and the bucket refills at one request per second rather than resetting on a
clock edge.
Every response carries:
```
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
```
Over the limit:
```
429 Retry-After: 4
{ "error": { "code": "rate_limited", "message": "More than 60 requests a minute. Slow down and retry." } }
```
## Errors
One shape, always:
```json
{ "error": { "code": "not_found", "message": "No such post." } }
```
| code | status | meaning |
|---|---|---|
| `unauthorized` | 401 | no usable key |
| `plan_required` | 403 | the plan does not include API keys |
| `plan_inactive` | 403 | the workspace has no live plan |
| `not_found` | 404 | no such post, in this workspace |
| `invalid_body`, `invalid_time`, `invalid_platform`, `invalid_source`, `invalid_status` | 400 | the request is wrong |
| `time_in_past` | 400 | a schedule must be in the future |
| `idempotency_key_required` | 400 | generate needs the header |
| `insufficient_credits` | 402 | `{ needed, available }` alongside the error |
| `post_limit` | 402 | `{ limit, used }` alongside the error |
| `not_schedulable`, `not_cancellable`, `not_connected`, `in_flight`, `busy` | 409 | the state does not allow it |
| `rate_limited` | 429 | see above |
| `internal`, `generation_failed` | 500 | ours |
| `unavailable` | 503 | the API is not configured on this deployment |
A post id from another workspace answers **404, not 403** — "exists but is not yours" and "does
not exist" are deliberately the same answer.
## Idempotency
`POST /posts/generate` **requires** an `Idempotency-Key` header: 8–200 printable characters, a
uuid being the obvious choice. Generating costs credits and about six image calls, and a client
that retries on a timeout must not be charged twice.
The first response for a key is stored for **24 hours** and replayed verbatim, with
`Idempotent-Replay: true`. A retry that arrives while the first request is still running gets
`409 in_flight`. A generation that *failed* releases its key, so retrying after a 500 really
retries.
No other endpoint takes the header. Scheduling the same post to the same time twice leaves it
scheduled to that time, so it is idempotent already.
## Pagination
`GET /posts` takes `?cursor=` and `?limit=` (default 25, max 100). The cursor is opaque; pass
back the `next_cursor` from the previous page, and stop when it is `null`.
Keyset, not offset: an offset re-reads earlier pages on every request and silently skips or
repeats rows when a post is created mid-walk.
---
# Endpoints
## `GET /workspace`
Who the key is for, what the plan allows, what is left. The first call any client should make.
```bash
curl -s https://YOUR_HOST/api/v1/workspace \
-H "Authorization: Bearer $KICKLINE_KEY"
```
```json
{
"id": "…", "slug": "nirra", "name": "Nirra",
"timezone": "Europe/London", "language": "en",
"plan": "growth", "status": "active",
"limits": { "posts_per_month": 100, "credits_per_month": 600, "workspaces": 3,
"connections": 10, "seats": 3 },
"usage": { "posts_this_month": 14 },
"credits": { "monthly": 480, "addon": 250, "available": 730 },
"billing_enforced": true
}
```
`credits` and `limits` are `null` when the deployment enforces no billing — `billing_enforced`
says which, so a null reads as "nothing is metered here" rather than as a gap.
## `GET /posts`
`?status=` one of `saved · scheduled · publishing · published · failed · cancelled`.
`?cursor=`, `?limit=`.
```bash
curl -s "https://YOUR_HOST/api/v1/posts?status=scheduled&limit=50" \
-H "Authorization: Bearer $KICKLINE_KEY"
```
```json
{
"data": [
{ "id": "…", "status": "scheduled", "caption": "…",
"media": ["https://…/1.png"], "platforms": ["instagram"],
"scheduled_for": "2026-09-20T09:00:00Z", "published_at": null,
"cancelled_at": null, "failure_code": null,
"source_id": "…", "format": "slideshow", "created_at": "2026-09-18T11:02:00Z" }
],
"next_cursor": "MjAyNi0wOS0xOC4uLg"
}
```
`failure_code` is kickline's own taxonomy — `not_connected`, `token_expired`, `media_rejected`,
`caption_rejected`, `platform_rate_limited`, `provider_rate_limited`, `provider_unavailable`,
`duplicate`, `profile_suspended`, `plan_inactive`, `unknown` — never the platform's own message.
## `GET /posts/{id}`
```bash
curl -s https://YOUR_HOST/api/v1/posts/POST_ID \
-H "Authorization: Bearer $KICKLINE_KEY"
```
Returns one post in the shape above.
## `POST /posts/generate`
Makes one post from a source. **The only endpoint that costs credits** (10).
It creates a **`saved`** post — in the library, going nowhere. Nothing in kickline publishes as a
side effect of generating; sending it out is the separate `/schedule` call below. That is a
product rule, not an API limitation.
```bash
curl -s -X POST https://YOUR_HOST/api/v1/posts/generate \
-H "Authorization: Bearer $KICKLINE_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"source_id":"SOURCE_ID","prompt":"lead with the price"}'
```
| field | required | notes |
|---|---|---|
| `source_id` | yes | from `GET /sources` |
| `prompt` | no | ≤400 characters, this generation only, never stored |
| `mention_product` | no | default `true` |
`201` with `{ "post": { … } }`. Takes up to a few minutes — one completion plus about six image
calls. Only one generation runs per workspace at a time; a second gets `409 busy`, and retrying
with the same `Idempotency-Key` is safe.
## `POST /posts/{id}/schedule`
```bash
curl -s -X POST https://YOUR_HOST/api/v1/posts/POST_ID/schedule \
-H "Authorization: Bearer $KICKLINE_KEY" \
-H "Content-Type: application/json" \
-d '{"at":"2026-09-20T09:00:00Z","platform":"instagram"}'
```
| field | required | notes |
|---|---|---|
| `at` | yes | ISO 8601, **in the future**. A past time is publish-now to the provider, so it is refused. |
| `platform` | no | must be one this workspace has connected. Omit for all of them. |
| `caption` | no | ≤2,200 characters, replaces the post's caption |
`{ "post": { … }, "warning": "…" }`. **Read `warning`.** It is present only when the row was
written but nothing will actually publish it — publishing not configured, or the provider refused
the hand-off. The schedule is real either way; the warning is the difference between a schedule
and a hope.
Only `saved`, `failed`, `cancelled` and `scheduled` posts can be scheduled. Rescheduling a failed
post clears its old failure code.
## `POST /posts/{id}/cancel`
```bash
curl -s -X POST https://YOUR_HOST/api/v1/posts/POST_ID/cancel \
-H "Authorization: Bearer $KICKLINE_KEY"
```
Only a `scheduled` post can be cancelled. Cancelling an already-cancelled one is a `200`.
A published post answers `409` — Instagram has no delete API, so a "cancel" that pretended to
unsend would be a lie with a 200 on it. A post that started publishing while the request was in
flight also answers `409`; read it back to see where it landed.
## `GET /sources`
What `source_id` will accept.
```bash
curl -s https://YOUR_HOST/api/v1/sources -H "Authorization: Bearer $KICKLINE_KEY"
```
```json
{ "data": [ { "id": "…", "format": "slideshow", "summary": "3 things nobody tells you about…",
"audiences": ["skincare"], "provenance": "captured" } ] }
```
`summary` is the first line of the original caption, capped. The full corpus text is not an API
product.
## `GET /accounts`
```bash
curl -s https://YOUR_HOST/api/v1/accounts -H "Authorization: Bearer $KICKLINE_KEY"
```
```json
{ "data": [ { "platform": "instagram", "handle": "hellonirra", "status": "linked" } ] }
```
Only connections a post could actually go to. An expired or suspended one is not listed, because
listing it would have a script schedule against a destination that silently fails.
---
## MCP server and Claude Code plugin
`POST /api/mcp` is an MCP server (streamable HTTP, stateless) over these same endpoints, with the same
`Authorization: Bearer kk_live_…` key. Tools: `get_workspace`, `list_accounts`, `list_sources`, `list_posts`,
`get_post`, `generate_post` and `schedule_post` (both need `userConfirmed: true`: credits and publishing are the user's
call), `cancel_post`. Code: `lib/mcp.ts`, protocol in `@saas/core/mcp` (shared with PostClock).
The Claude Code plugin in `claude-plugin/` wraps it and asks for the key once (stored in the user's credential
store). Install: `/plugin marketplace add https://usekickline.com/claude-plugin.git`, then
`/plugin install kickline@kickline`. Every deploy republishes it (`scripts/publish-plugin.sh`); after a change, also
run `scripts/push-plugin-github.sh` for the public GitHub copy.
## A whole run, in four calls
```bash
export KICKLINE_KEY=kk_live_…
export HOST=https://YOUR_HOST
SRC=$(curl -s $HOST/api/v1/sources -H "Authorization: Bearer $KICKLINE_KEY" \
| jq -r '.data[0].id')
POST=$(curl -s -X POST $HOST/api/v1/posts/generate \
-H "Authorization: Bearer $KICKLINE_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d "{\"source_id\":\"$SRC\"}" | jq -r '.post.id')
curl -s -X POST $HOST/api/v1/posts/$POST/schedule \
-H "Authorization: Bearer $KICKLINE_KEY" -H "Content-Type: application/json" \
-d '{"at":"2026-09-20T09:00:00Z"}' | jq '.warning'
curl -s $HOST/api/v1/posts/$POST -H "Authorization: Bearer $KICKLINE_KEY" | jq '.status'
```
## Notes for whoever maintains this
- `lib/api/auth.ts` is the single door. Authentication, the rate limit and the plan gate are one
decision there, not three middlewares, because splitting them is how a route ends up
rate-limited but unauthenticated.
- A bearer key is not a Supabase session, so there is **no RLS context**. Every query in
`lib/api/reads.ts` filters on the `workspaceId` that came from the key's own row, by hand. That
is the trade a bearer API makes; be boring about it.
- The rate-limit buckets are **per process** (`// ponytail:` in `lib/api/auth.ts`). Behind two
instances a caller gets up to 2× the limit. Move them to Postgres or Redis when there is more
than one instance — not before.
- `generateOne` lives in `lib/media/generate-one.ts`, shared with the deck route. Do not copy it.
- Migration `kicker_0022`.