# Testing safely

> A public sandbox with test data is on the way. Until then you build against yapfactory.com, and these rules keep testing from reaching anyone.

## Start read-only

1. Make a key in **Settings → AI agents → Make an API key** and leave **Let it act for me** off. A read-only key can list and read everything you can see, and can't change anything.
2. Explore with `GET` calls: `/me`, `/campaigns`, `/creators`, `/deals`. Nothing you read tells anyone.
3. When you're ready to act, make a second key that can. Revoke either one at any time.

## What stays private

- **Campaign drafts.** `POST /campaigns` makes a draft that only you can see, and you can change the brief as often as you like. Nobody is told until you publish it.
- **Uploads.** A file from `POST /posts/uploads` sits unused until you schedule it.
- **Money never moves through the API.** Starting a deal and approving a draft return a link to the deal page, where the person finishes the step.

## What reaches other people

These calls tell someone straight away. They need an `Idempotency-Key`, and agents should get a clear yes from the person first:

- Publishing, pausing or closing a campaign, and inviting creators.
- Passing on a creator, asking for changes to a draft, and messaging on a deal.
- Asking to join a campaign and answering an invite (creators).
- Scheduling a post: it goes out publicly on your account at its time. Cancel it before then with `POST /posts/{postId}/cancel`.

Want to try webhooks? **Send test event** in Settings → Webhooks delivers a signed `ping` to your endpoint without anything else happening.

## Sandbox: coming soon

A separate sandbox with demo brands, creators and campaigns, where nothing reaches anyone and payments use Stripe test mode. Its keys will start with `yf_test_`. It will be listed in the [changelog](https://yapfactory.com/developers/changelog.md) when it opens.

## Before you go live

1. Use the base URL `https://yapfactory.com/api/v1`.
2. Make a `yf_live_` key on yapfactory.com, with only the access you need (read-only if you never act). Keep it in a secret store, never in code.
3. OAuth apps: point your redirect URIs at your production app. Loopback addresses are for development.
4. Send an `Idempotency-Key` on every `POST`, `PATCH` and `DELETE`, and reuse it when you retry.
5. Branch on `error.code`, never on `message`. Log the `requestId`.
6. Handle `429`: wait `Retry-After` seconds. Stay under 20 changes a minute per connection.
7. Page through lists with `cursor` until `hasMore` is false.
8. Add your production webhook endpoint in Settings → Webhooks. Each endpoint has its own `whsec_` secret. Check signatures, and dedupe on `Yap-Event-Id`.
9. Show people the handoff link for starting a deal and approving a draft. Never try to take payment yourself.
10. Confirm with the person before anything that reaches other people: publishing, pausing or closing a campaign, inviting or passing on a creator, asking for changes to a draft, asking to join a campaign, answering an invite, sending a message and scheduling a post.

---

HTML version: https://yapfactory.com/developers/sandbox
