heydecks

API

Errors

Every non-2xx response uses the same error envelope.

#Error envelope

Every non-2xx response returns a JSON object with a single error key:

JSON
{
  "error": {
    "code": "insufficient_credits",
    "message": "Insufficient credits: need 10, have 3 remaining."
  }
}

code is a stable machine-readable identifier. message is a human-readable description that may include contextual detail.

#Error codes

CodeHTTPWhen
invalid_key401Missing, malformed, or revoked API key.
api_not_on_plan403Your plan doesn't include API access. Pro plan required.
insufficient_credits402Not enough credits remaining this billing period.
deck_limit402Deck count is at the plan limit. Upgrade to create more.
brand_limit402Brand count is at the plan limit. Upgrade to create more.
invalid_input422Request body missing required fields or failed validation (e.g. input too long, missing title).
not_found404The resource doesn't exist or belongs to a different user.
rate_limit429Too many generate requests per second for your plan's RPS limit. Retry after 1 second.
internal_error500An unexpected server error. The message may contain details.

The rate_limit code (HTTP 429) applies to POST /v1/generate only. Read-only endpoints are not rate-limited.

#Handling 402 errors

A 402 covers three distinct situations — always check error.code:

  • insufficient_credits — you've used your monthly allowance. Wait for the next billing period or upgrade.
  • deck_limit — you've reached the maximum deck count for your plan. Delete a deck or upgrade.
  • brand_limit — you've reached the maximum brand count for your plan. Delete a brand or upgrade.

#Retrying

Safe to retry (idempotent reads):

  • GET /v1/decks, GET /v1/decks/{id}, GET /v1/jobs/{id}, GET /v1/brands

Not safe to retry without checking first:

  • POST /v1/generate — each call deducts 10 credits and creates a new job.
  • POST /v1/decks/{id}/publish — idempotent by effect but each call creates a version snapshot.

500 internal_error responses are safe to retry with exponential backoff.