Skip to main content
Before launch, decide how much work each request may do, how fresh the result needs to be, and what users see when data is missing. Use this checklist after your first request works.

Choose the operation

A purpose-built response is easier to validate than a general scrape plus custom parsing. Do not crawl an entire site when one page or a sitemap lookup answers the question.

Protect your API key

CONTEXT_DEV_API_KEY is a bearer credential. Store it in a server-side secret manager or environment variable.
  • Do not include it in browser JavaScript, mobile bundles, public environment variables, or client-side localStorage.
  • Do not print the value while debugging. Log only whether the variable exists.
  • Rotate a key that appears in source control, build logs, screenshots, or chat history.
  • Grant only the API-key scopes the integration needs. Dashboard team roles and key scopes govern different access.
  • Use a backend route when a browser needs Context.dev data.
Logo Link uses a separate domain-restricted public client ID for frontend image embeds. It does not make a secret API key safe to expose.

Limit each request

Set cost and time limits at the request boundary: Start with a small page cap and inspect the result before increasing it. For current operation prices, use the endpoint badge in the API reference and the pricing page.

Set cache freshness

maxAgeMs controls how old a Context.dev cached result may be. Your own database or object cache controls how long your application reuses the response after receiving it. Ask two different questions:
  1. How fresh must the source fetch be when Context.dev handles the request?
  2. How long can this application reuse the returned value without another API call?
Defaults differ by operation. Markdown scraping defaults to one day, structured extraction to seven days, and Brand retrieval to three months. Brand retrieval, Styleguide, Fonts, and scraping accept maxAgeMs=0 for fresh data and honor positive sub-day values. The direct-URL Brand variant does not accept maxAgeMs. Inspect cache_metadata.status and cache_metadata.age_ms when cache behavior matters. A Brand profile assembled during a request reports a miss if any contributing scrape missed its cache; when all contributing scrapes hit, it reports the oldest contributing age. A stored Brand-cache hit uses the profile’s stored age. Store the time of your own successful retrieval as separate metadata.

Plan for slow requests

A cache miss can require browser work, crawling, or model inference. It can take materially longer than a cache hit.
  • Show an honest loading state when the user must wait.
  • Run crawls, batches, and broad product extraction in a background job.
  • Prefetch eligible Brand or styleguide data when you learn the identifier before the result is needed.
  • Set timeoutOpts.milliseconds according to the product’s latency budget, not an arbitrary HTTP-client default.
  • Use timeoutOpts.behavior: "return-partial" when usable incomplete data helps. Preserve partial: true or finalDOMState: "still-loading" in your UI and storage; see Timeouts and partial results.

Set a retry policy

Use the status and error_code together: Published SDKs can already retry selected network errors and statuses. The API gateway can also retry transient network failures and upstream 502/503/504 responses up to twice, after 1 and 2 seconds, when the request is replayable. Bodies above 1 MiB are streamed without replay, and cancellation stops further attempts. Account for these layers before adding an application retry loop. Use operation-specific idempotency controls for writes; retries do not guarantee exactly-once execution. A bounded policy needs all four values: retryable conditions, maximum attempts, delay with jitter, and final fallback.

Handle missing fields

A 200 means the API produced a usable result. In partial mode, work may still be unfinished; inspect the completion marker. Optional fields can also be missing from a complete response.
For example, this TypeScript adapter keeps a domain fallback and treats a missing logo explicitly:
  • Keep the user’s original input as a fallback.
  • Do not assume array index zero is the correct asset for every UI.
  • Distinguish “not returned” from a false or zero business value.
  • Do not describe discovered addresses, headcounts, contacts, or classifications as verified legal records.

Validate extracted data

For structured extraction, validate data against the same schema your application sent. Then validate the business meaning your product needs. Examples:
  • A valid URL can still point to the wrong kind of source.
  • A number can satisfy the schema but use the wrong unit.
  • A classification code can be valid while its confidence is too low for automatic action.
  • A required, non-null field can force a poor fallback when the source never states a value.
Use nullable schema fields for missing evidence, enable factCheck when values must be page-supported, and retain urls_analyzed for audit-sensitive workflows.

Track usage and failures

Record enough metadata to diagnose behavior:
  • Operation and a non-sensitive request identifier.
  • HTTP status and error_code.
  • Attempt count and total latency.
  • Cache status and age when returned.
  • Crawl totals, not scraped page bodies, unless your data policy permits content logs.
  • key_metadata.credits_consumed when cost attribution is required.
  • Request tags for product or environment attribution.
Use Zero Data Retention for eligible sensitive workloads and confirm the response header before assuming it was honored.

Before launch

  • Secret key exists only on the server.
  • The operation, page cap, timeout, and cache age are explicit.
  • Expected no-result states have a product fallback.
  • Retries are bounded and exclude permanent failures.
  • Optional fields and empty arrays are handled.
  • Structured output is schema-validated.
  • Usage, latency, and error categories are observable.

Next steps

Troubleshooting

Diagnose failed requests and handle expected no-result states.

Rate limits

Pace requests and handle 429 responses with bounded retries.

API stability

Check versioning, compatibility, and SDK upgrade requirements.