Test mode
Build and test your integration with test keys, the Sandbox Network and test conversions.
Each workspace has live data and test data. The two are fully separate. A test key (sk_test_...) reads and writes test data only. A live key (sk_live_...) reads and writes live data only. Each object has the field livemode. It is false for test data.
What is different in test mode
- The Sandbox Network. This network makes fake programs, conversions, clicks, payouts and deals. It needs no credentials. It works with a test key only. A live key gets
network_unavailable. See Connect Sandbox Network. - Test helpers.
POST /v1/test/conversionsandPOST /v1/test/conversions/{id}/statuswork with a test key only. A live key getstest_mode_only. - Webhooks. A test endpoint can use
http. A live endpoint must usehttps. - Limits and billing. Test mode has no plan limits. The API never counts or bills test data.
- Redirects. Links work in test mode. The clicks are test data.
- Real networks. You can also connect a real network with a test key. The data stays in test mode.
A live ID does not work with a test key, and a test ID does not work with a live key. The API answers resource_not_found.
Make a test conversion
You need a test connection. Use the Sandbox Network (see the quickstart). You need the scope conversions:write.
curl -X POST https://api.afffast.com/v1/test/conversions \
-H "Authorization: Bearer $AFFFAST_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"connection": "conn_...",
"amount": "100.00",
"click_id": "..."
}'amountandcommissionare decimal text. The default amount is100.00. The default commission is 10 % of the amount.click_idis the click ID of a click on a test link. The API puts it in the SubID slot of the network, like the redirector does. The conversion then getsclick_id,user_subidsandclick_context. A click ID that no click has gives a conversion with no click context.
Change the status
curl -X POST https://api.afffast.com/v1/test/conversions/conv_.../status \
-H "Authorization: Bearer $AFFFAST_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{ "status": "rejected" }'The status is pending, approved, rejected, paid or unknown. The change goes through the same write as a sync. A new status writes the event conversion.status_changed, and your webhook endpoints get it. Use this to test how your code handles a late rejection.
Test the Sandbox scenarios
Set the field scenario of the Sandbox connection to test errors and large volumes:
default: normal data.high_volume: 12 times more conversions and clicks.failing_auth: the credentials check fails.rate_limited: the first fetch in each window of 60 seconds fails with a rate limit error.
Go live
- Make a live key in the dashboard.
- Connect your real networks with the live key.
- Make new webhook endpoints, destinations and links with the live key. Test objects do not move to live mode.
- Replace the test key in your code with the live key.