Start with a test key
A test key returns mock solutions and never charges credits. The task shape, status transitions, and error envelope are the same as live. That is enough to validate your polling loop, your webhook handler, and your UI states.
Keep the live key out of CI. Put the test key in the CI secret store, and run the live suite on a schedule or before a release with a dedicated test account.
Test the failure matrix
Most integrations work on the happy path and fall apart on the first 402. Exercise each error class explicitly: invalid request, unsupported type, insufficient credits, rate limited, concurrency limit, task expired, and solver unavailable.
For each one, assert the status code, the problem code, and the user-visible message. A generic toast that says something went wrong is not a failure path.
Bad sitekey
- Expected
- 422 invalid_request
- What to assert
- Field name and request ID
No balance
- Expected
- 402 insufficient_credits
- What to assert
- Top-up call to action
Burst over rate
- Expected
- 429 rate_limited
- What to assert
- Retry-After header
Too many in flight
- Expected
- 429 concurrency_limit
- What to assert
- Backoff, not a tight loop
Task timeout
- Expected
- expired
- What to assert
- Reservation released
Solver down
- Expected
- 503 solver_unavailable
- What to assert
- Retry policy and alert
Do not log the secrets
Log the task ID, request ID, type, status, latency, and price. Do not log the API key, the proxy password, the token, or the clearance cookie. If you need to debug a proxy, log the host and country, not the credentials.
A solution token is a credential for the target. A clearance cookie is a session credential. Treat both like passwords in logs, error trackers, and support tickets.
A small live smoke suite
After the mock suite passes, run one live task per type you actually use. Keep the volume low, use a test account, and assert the target accepted the solution separately from the API returning it. A completed task is not a successful solve.
- One token type, one Challenge task, one deliberate failure.
- Run on a schedule, not on every commit.
- Record task ID, target result, and latency.
- Alert on a change in success rate, not just on a thrown error.