• One key per app and environment, kept on your server in an environment variable or secrets manager, never in a browser or mobile app.
  • A spend cap on each key, so a bug can’t spend your whole month’s credits.
  • Branch on meta.error_code, never on the message.
  • Handle 402: INSUFFICIENT_CREDITS (top up or wait for renewal) and SPEND_CAP_REACHED.
  • Handle 429: wait for Retry-After seconds, then retry.
  • Retry 5xx with backoff. Failed calls cost nothing, so retries are safe.
  • Treat 404 on a job as closed and drop it from your side.
  • Use cursors within the hour, with the same parameters; don’t store them.
  • Narrow searches instead of paging deep: one search reaches at most 100 results.
  • Watch X-Credits-Remaining and alert before you run out.
  • Log meta.request_id on errors, for support.