Launch offer: service fee 10% 4% until 31 Dec, just enough to cover card processing. See pricing

Developers

Pagination, idempotency and limits

Three rules every call follows: lists page with a cursor, retries are safe with an Idempotency-Key, and each connection has a limit per minute.

View as Markdown

Pagination

Lists come back like this. Any summary fields go in meta.

{
  "data": [ { … }, { … } ],
  "nextCursor": "eyJvIjoyMH0",
  "hasMore": true
}
  • ?limit= runs from 1 to 50. The default is 20.
  • Every list pages this way, to the end. GET /creators and GET /marketplace/campaigns are ranked afresh on each call, so a creator can move between pages while you read: dedupe on id.
  • ?cursor= takes the nextCursor from the page before. Treat it as opaque: don't build or change one.
  • Stop when hasMore is false. Then nextCursor is null.
let cursor = null;
do {
  const url = new URL("https://yapfactory.com/api/v1/deals");
  url.searchParams.set("limit", "50");
  if (cursor) url.searchParams.set("cursor", cursor);
  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.YAP_API_KEY}` } });
  const page = await res.json();
  for (const deal of page.data) console.log(deal.id);
  cursor = page.hasMore ? page.nextCursor : null;
} while (cursor);

Idempotency

Networks drop answers. An Idempotency-Key lets you retry without doing the thing twice.

  • Send an Idempotency-Key header, 8 to 200 characters, on any POST, PATCH or DELETE. A UUID is ideal.
  • It's required on outbound operations, the ones that tell other people (publishing, inviting, answering, messaging, scheduling a post). Without one they return 400.
  • A success is stored for 24 hours. The same key with the same body returns that stored response, with the header Idempotent-Replayed: true, and nothing runs again.
  • A failure isn't stored. Send the same key again once whatever stopped it has changed, and it runs then.
  • The same key with a different body returns 409 idempotency_conflict.
  • The same key while the first request is still running returns 409 conflict. Wait a moment and send it again.
  • Keys belong to the connection (the OAuth grant or the API key), so two apps can't collide.
curl -X POST "https://yapfactory.com/api/v1/campaigns/$CAMPAIGN_ID/publish" \
  -H "Authorization: Bearer $YAP_API_KEY" \
  -H "Idempotency-Key: 4f1c2b0e-7d4a-4f43-9a51-0c6a1b9e2d7f"

Rate limits

Limits are counted every minute, per connection and per person. The REST API and the MCP server share them.

WhatEach connectionAll of a person's connections
Reads120 a minute300 a minute
Changes (write and outbound)20 a minute40 a minute
outbound alone10 a minute15 a minute

Every response from an operation carries these, counted for the connection:

HeaderMeans
RateLimit-LimitThe limit for this kind of call.
RateLimit-RemainingCalls left in this window.
RateLimit-ResetSeconds until the window resets.
Retry-AfterOn a 429 only: seconds to wait before trying again.

Some things have their own limits, the same as on the site, such as 8 hand-picked creators per campaign. Past one, the call returns 409 conflict with a sentence that says so.

Versions

  • The version is in the path: /api/v1. Within v1 we only add: new operations, new optional inputs, new fields in a response, new webhook event types and new values for a status. Write code that ignores what it doesn't know.
  • Anything that would break working code (removing or renaming a field, changing a type, tightening an input) waits for /api/v2. We'd run v1 beside it for at least 12 months and email everyone with a live key or connection.
  • Every change is in the changelog.

Keys belong on a server

Never put an API key in a web page or a mobile app: anyone can read it there. The API answers browsers (CORS is open) so that apps using OAuth can call it with a person's own token; keys are for your server and your scripts. If a key gets out, revoke it in Settings → AI agents and make a new one.

Formats

  • Money is { "minor": 1500, "currency": "USD", "formatted": "$15.00" }. Integer minor units (pence or cents) everywhere, never decimals.
  • Times are ISO 8601 strings in UTC.
  • Ids are UUIDs.