Developer guides
Production Checklist
Timeouts, retries, idempotency, pagination, caching, key isolation, billing controls, and logging before release
Use one server-side request wrapper for authentication, timeouts, retries, and request tracing. Keep endpoint policy outside the wrapper so each call can use its own timeout and retry budget.
The API Explorer writes a smaller version of this wrapper for the endpoint you pick. Its cURL, TypeScript and Python tabs carry the endpoint's price, its measured timeout, the error.type branch, retries that honor Retry-After, an Idempotency-Key where the endpoint honors one, and the cursor loop on list endpoints. The same panel exports the call as an n8n workflow and as a prompt for a coding agent.
Start with one request wrapper
The example calls the active TikTok profile endpoint with its documented handle parameter. It reads the API key only from the server environment. It also keeps request_id, charge, and cache state available to your application logs. See Authentication and the full response schema.
Set timeouts by endpoint
Require an attemptTimeoutMs value on every wrapper call. It caps each HTTP attempt, not the total logical request. Choose it from the endpoint's documented behavior and measurements from your own uncached requests. Add enough margin for network latency, then monitor timeout rates after release.
The total retry wall time can be longer than attemptTimeoutMs. It is bounded by the maximum attempt count plus the scheduled backoff and any honored Retry-After waits. The example's value is illustrative, not a universal timeout. A profile lookup, a paginated feed, and a multi-source search have different latency profiles. Review the selected endpoint page and set a separate per-attempt timeout for each production route.
When an endpoint's latency is longer than your client or platform can hold a connection, do not raise the timeout past it: send Prefer: respond-async (or ?async=true) and poll the job instead. The call is the same call at the same price, and the 202 answers at once. See Async requests.
Retry only transient failures
Retry only the failures marked retryable, honor Retry-After, and back off with jitter. Handle errors and retries has the retryable list, the withdrawn-endpoint exception and the loops.
Make retries safe
Generate one unique Idempotency-Key for each logical request and reuse it only for an identical retry. Retry safely covers the replay, the 24-hour window, streamed GET calls and the calls that ignore a key.
Drain every page
For a list response, read the root pagination.next_cursor value and send it back unchanged as the next request's cursor parameter. Stop when root pagination.has_more is false.
Pages are sequential because the next cursor comes from the preceding response. Give each page a new idempotency key, but keep that page's key unchanged across its retries. Never infer completion from item count, total, or an empty page. See Pagination for the full contract.
Control request rate and concurrency
Each API key currently has two separate controls: 600 requests per minute and 50 simultaneous requests. A rate limiter controls starts within a time window. A concurrency limiter controls requests still in flight. Track their separate response headers and branch on RATE_LIMITED versus CONCURRENCY_LIMIT so you reduce the correct pressure.
Set both a worker-pool bound and a request-rate bound below the published ceilings. Apply backpressure before adding retries, since retries consume request capacity too. See Rate limits for the headers and current behavior.
Decide when cached data is acceptable
Use caching only where the endpoint documentation declares it. Read both body cached and header X-Cache when freshness affects a decision. A reported cache hit uses 0 credits, but a hit is an optimization, not an availability guarantee. An entry can be absent or expired.
Send Cache-Control: no-cache only when your application requires a source refresh. On a cache-enabled endpoint, it bypasses the lookup and makes a successful call a billable miss at the endpoint's normal cost. Check Caching and the selected endpoint page instead of copying a cache window into application code.
Separate keys by environment
Create different keys for production, staging, CI, and local development. Keep every key in a server-side secret store and rotate one environment without affecting another.
API keys are not endpoint-scoped permissions. Separate keys provide revocation, usage, rate-limit, and budget isolation, but they do not restrict a key to an endpoint set. Review Authentication before release.
Cap non-production spend
Set a credit limit on every non-production key. Key limits are cumulative until you reset them, and a key with no configured limit is unscoped by spend. A capped key that reaches its limit returns KEY_BUDGET_EXCEEDED without deducting the request cost or stopping other keys on the account.
Inventory every production endpoint and its expected call volume against Endpoint pricing. Poll GET /v1/credits/balance when you need an explicit balance check; the endpoint requires authentication and costs 0 credits. Use Credits for ledger semantics rather than assuming a refund or free response before inspecting credits_used.
Configure billing alerts and webhooks
Configure the low-credit email threshold in Billing > Payments. In the same screen, configure billing webhooks for credit and payment events that your infrastructure needs to handle.
Webhook URLs must use HTTPS on a public host. Verify every delivery signature against the raw request body before processing it, and make the handler safe for duplicate delivery. If you also use scheduled Monitor delivery, apply the corresponding webhook contract.
Log the fields support needs
Record these fields for every attempt:
request_idfrom the response body orX-Request-Idheader- Endpoint and HTTP status
error.typeon failurescredits_used- Cache state from
cachedorX-Cache - Your measured latency
- Your attempt count
Do not log the API key, idempotency key, webhook secret, or full sensitive request payload. Check Status during an incident, and include the affected request_id values in a support report so the requests can be traced.
Deployment checklist
- Freeze the exact production endpoint set and required parameters.
- Assign and test a timeout budget for each endpoint.
- Retry only the documented transient
error.typevalues with bounded attempts,Retry-After, exponential backoff, and full jitter. - Reuse an idempotency key only for an identical retry, and generate a new key for every logical request.
- Stop pagination on root
pagination.has_more: false, passing rootnext_cursorback unchanged ascursor. - Bound request rate and in-flight concurrency separately.
- Record whether each endpoint permits cached data or requires an explicit refresh.
- Load a production-only API key from a server-side secret store.
- Cap every non-production key.
- Set a credit budget using current endpoint prices and call volume.
- Configure low-credit alerts and verify webhook signatures against raw bodies.
- Log
request_idwith status, error type, credits, cache state, latency, and attempt count. - Complete a clean pre-production run using Testing your integration.
Next step
Run the pre-production checks with a separate capped key before you send production traffic.
