1. Base Origin & Authentication

Planned Stage 1 REST traffic targets https://api.dataroute.dev/v1/* over HTTPS with a single bearer key passed in the Authorization header:

Authentication Header Convention Stage 1 Spec
GET /v1/sites/example.com/profile HTTP/1.1
Host: api.dataroute.dev
Authorization: Bearer ${DATAROUTE_API_KEY}
Accept: application/json

2. Success Response Envelope

Every successful DataRoute endpoint returns HTTP 200 with a predictable top-level JSON structure containing ok, request_id, route, data, provenance, and billing:

Standard HTTP 200 Envelope Schema-Validated
{
  "ok": true,
  "request_id": "dr_req_01JDR9X4K8M2N7Q5V1W6Y3Z8",
  "route": "GET /v1/social/x/search",
  "data": {
    "query": "openrouter mcp",
    "items": [
      {
        "id": "1894012345678901234",
        "author_handle": "example_dev",
        "text": "Unified MCP routing for public web and social data...",
        "created_at": "2026-11-22T06:15:00Z"
      }
    ],
    "next_cursor": "cursor_example_token"
  },
  "provenance": {
    "engine": "ark",
    "upstream_id": "ark_owned_pool_us_west",
    "failover_attempts": 0,
    "latency_ms": 418,
    "fetched_at": "2026-11-22T06:16:02Z"
  },
  "billing": {
    "billable": true,
    "http_status": 200,
    "schema_valid": true,
    "currency": "USD"
  }
}

3. Explicit Upstream Provenance

DataRoute records which engine or upstream fulfilled every call directly inside provenance:

  • engine: Logical serving layer (ark, vaneform, page_receipt, multi_upstream_social, or multi_upstream_serp).
  • upstream_id: Identifier of the specific execution pool or upstream slot that served the payload.
  • failover_attempts: Count of automatic failover retries executed before settlement.
  • latency_ms and fetched_at: End-to-end execution duration and UTC ISO-8601 capture timestamp.

4. Normalized Error Taxonomy

Upstream provider errors map into one stable set of HTTP status codes and machine-readable error.code values. Every non-200 error response sets billing.billable to false.

Normalized Non-Billable Error Envelope billable: false
{
  "ok": false,
  "request_id": "dr_req_01JDR9Z0P9Q4R8S2T6U1V5W9",
  "route": "GET /v1/search/serp",
  "error": {
    "code": "upstream_exhausted",
    "message": "Primary and secondary SERP upstreams failed within the request timeout window.",
    "retryable": true
  },
  "provenance": {
    "engine": "multi_upstream_serp",
    "upstream_id": "serp_secondary_eu",
    "failover_attempts": 2,
    "latency_ms": 4820,
    "fetched_at": "2026-11-22T06:21:14Z"
  },
  "billing": {
    "billable": false,
    "http_status": 502,
    "schema_valid": false,
    "currency": "USD"
  }
}
HTTP Code Billable Owner Behavior
200 ok Yes (schema-valid) DataRoute Gateway Valid structured payload passed schema verification and explicit provenance checks.
400 invalid_parameter No ($0.00) Client Request Malformed query parameter, unsupported market code, or invalid URL/domain format.
401 invalid_api_key No ($0.00) Client Auth Missing, revoked, or malformed DATAROUTE_API_KEY bearer token.
402 insufficient_credits No ($0.00) Account Ledger Prepaid USD credit balance is below the route maximum reservation.
404 resource_not_found No ($0.00) Public Target Target public tweet, user handle, video ID, or URL was confirmed nonexistent or private.
422 validation_failed No ($0.00) Schema Gate Upstream returned data that failed required field validation; rejected before billing.
429 rate_limited No ($0.00) Gateway / Upstream Caller concurrency limit reached or all configured upstream pools temporarily throttled.
502 upstream_exhausted No ($0.00) Failover Router Primary and secondary upstreams returned upstream errors; circuit breaker updated.
504 upstream_timeout No ($0.00) Failover Router Bounded end-to-end execution budget expired before a valid response arrived.

5. HTTP 200-Only Metering

Credits deduct only when both http_status === 200 and schema_valid === true. See the complete HTTP 200-Only Billing Contract and Routing & Failover Methodology for ledger settlement details.