20% off your first month

API errors

What each status code from the Shotz API means, and what to do about it.

When a request doesn’t work, the API answers with a status code and a JSON body saying why, in a sentence you can show or log:

{"error": "That needs 140 credits and there aren't enough left. Top up or change plan, then try again."}

The codes

  • 400: the request isn’t right. The body is missing, isn’t JSON or isn’t a JSON object (the message says to send a JSON object with Content-Type: application/json), a field is the wrong type or out of range (the message names the field), you sent neither a prompt nor a skill, the skill isn’t one of the skills, the model doesn’t exist or doesn’t make the kind you asked for, the prompt is longer than the model takes (the message says by how much; shorten it or pick another model), the model is turned off in the workspace (an owner can turn it on in Settings → Generative models), the workspace’s Library is full (delete a few files or change plan), the Idempotency-Key header isn’t 1–200 visible ASCII characters, or before on GET /api/v1/media isn’t an ISO 8601 timestamp. Fix the request; check model ids with GET /api/v1/models.
  • 401: the key is missing, wrong or revoked, or whoever made it isn’t an owner or editor of the workspace any more. Send it as Authorization: Bearer sk_live_…, or make a new key in Settings → API.
  • 413: the request body is too large. POST /api/v1/generations takes up to 64 KB of JSON. Send a shorter prompt, or fewer ids and fields, and try again.
  • 429: too many requests. A key can make 60 calls a minute, and calls with a missing or wrong key are limited too. The answer has a retry-after header; wait that long and try again.
  • 402: there aren’t enough credits for the generation, or it would take the key’s maker over their monthly credit limit. Nothing is spent. Buy more credits, or ask an owner to raise the limit.
  • 404: there’s no generation with that id in this key’s workspace, or the projectId isn’t in it.
  • 409: you sent an Idempotency-Key that was already used for a different request. Use a new key for a new generation, or send the original body again.
  • 503: generating couldn’t start just then. Wait a moment and try again. If you sent an Idempotency-Key, send the same one again: the retry returns the original generation instead of making another. See Generate with the API.

Takes that fail later

A generation can start (202) and a take fail afterwards, for example when a model refuses the prompt. That isn’t an error code: the take’s status is failed, its error says why, and its credits come back. See What happens when a take fails.

If something keeps failing, write to us with the generation’s id.

Still stuck?

A real person in Melbourne will write back, usually within one business day.

Contact support