Developers
Quickstart
Make a key, check who you are, list your campaigns and draft a new one. About five minutes, in cURL, Node or Python.
View as Markdown1. Make an API key
- Sign in to yapfactory.com with your brand account.
- Open Settings → AI agents → Make an API key, turn on Let it act for me and make the key.
- Copy it. It's shown once, and starts with
yf_live_.
export YAP_API_KEY="yf_live_..."Trying things out? Leave Let it act for me off for a read-only key, and see Testing safely for what reaches other people.
2. Check who you are
GET /me returns your account: brand, creator or both, your country and currency, and what this key is allowed to do.
curl "https://yapfactory.com/api/v1/me" \
-H "Authorization: Bearer $YAP_API_KEY"{
"data": {
"name": "Dana Lee",
"email": "dana@sleepwell.app",
"country": "US",
"currency": "USD",
"sides": [
"brand"
],
"brand": {
"company": "Sleepwell",
"country": "US",
"paused": false,
"home": "https://yapfactory.com/brand"
},
"creator": null,
"canAct": true,
"gettingStarted": {
"step": "review_draft",
"say": "Maya R.'s draft is ready to review.",
"url": "https://yapfactory.com/deals/3b2f6c1e-7a54-4d0b-9f1a-6e5d4c3b2a19"
},
"environment": "live",
"connection": {
"app": "API key",
"kind": "api_key",
"scopes": [
"read",
"write"
],
"manage": "https://yapfactory.com/brand/settings#agents"
}
}
}gettingStarted is the one next thing worth doing on this account, or null when nothing is waiting (every step). connection.scopes says what this key may do. canAct is about the account, not the key: it's false until the email is confirmed.
3. List your campaigns
Lists come back as { data, nextCursor, hasMore }. Pass nextCursor back as ?cursor= for the next page, until hasMore is false.
curl "https://yapfactory.com/api/v1/campaigns?status=live" \
-H "Authorization: Bearer $YAP_API_KEY"4. Draft a campaign
A draft is private: nobody sees it until you publish. Give productId from GET /products, or product to add a new one, as here. Send an Idempotency-Key, so a retry never makes two drafts.
curl -X POST "https://yapfactory.com/api/v1/campaigns" \
-H "Authorization: Bearer $YAP_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"product": {
"name": "Sleepwell",
"platform": "ios",
"url": "https://apps.apple.com/app/id0000000000"
},
"title": "Morning routine with Sleepwell",
"brief": {
"keyMessage": "Sleepwell helps you fall asleep in 10 minutes without your phone.",
"hooks": [
"I used to scroll until 2am."
],
"cta": "Try it free tonight."
}
}'You get 201 with the new draft's id and the page to review it on:
{
"data": {
"campaignId": "8f14e45f-ceea-4e7a-9b1d-2c3b4a5d6e7f",
"status": "draft",
"review": "https://yapfactory.com/brand/campaigns/8f14e45f-ceea-4e7a-9b1d-2c3b4a5d6e7f/edit",
"next": "Show the person the draft (get_campaign), then publish_campaign when they're happy."
}
}When it reads well, POST /campaigns/{campaignId}/publish makes it live and matching creators can ask to join. Publishing tells other people, so it needs an Idempotency-Key.
Next
- Webhooks: hear about asks, yeses and drafts as they happen, instead of polling.
- REST API reference: every operation, with what it needs.
- Errors: what each code means and what to do.
- OAuth: when your app acts for other brands.