sangtao.ai
API key

Overview

Error codes

Error format

Every failed call — a wrong key, a missing field, a route that does not exist — answers in JSON, in this shape:

json
{
  "success": false,
  "errorCode": "INVALID_DPI",
  "error": "dpi must be between 1 and 1200.",
  "details": [
    {
      "field": "dpi",
      "code": "INVALID_DPI",
      "message": "dpi must be between 1 and 1200.",
      "params": { "min": 1, "max": 1200 }
    }
  ],
  "requestId": "4bf92f3577b34da6a3ce929d0e0e4736"
}

Branch on errorCode — not on the message, nor on the HTTP status (a few codes come with another status on some endpoints). What each field means: API conventions.

HTTP status codes

StatusMeaningWhat to do
200 / 201SuccessRead the data field
400Invalid requestFix the field the error names, then send again
401No key, or a wrong oneSend a valid key in the X-Api-Key header
402Not enough creditsTop up, then retry — retrying before that fails the same way
403Not allowedThe key cannot use this endpoint
404Not foundCheck the path and the id
409Already doneThe thing was already done (an upload confirmed twice) — do not send it again
422A field has a wrong value (creating an image)See errorCode, fix the value, then send again
429Too many requestsWait, then retry with backoff
500 / 502 / 503Server errorRetry after a few seconds; contact support if it keeps happening

Most endpoints answer a bad request with 400. Creating an image (POST /images/generations) answers 422 instead — a missing model or prompt, an aspectRatio, format, resolution or dpi it does not take, or a reference image link that does not exist.

Error codes

The full list, read from GET /v2/errors (no key needed). Messages are in English, as calls with an API key get them; {name} is filled in from details[].params. HTTP is the usual status — an endpoint that answers another one says so on its page.

Codes any endpoint can answer:

errorCodeHTTPMessageRetry?
BAD_REQUEST400The request is invalid.No
VALIDATION_ERROR400 (some endpoints 422)The request contains invalid fields. See details.No
BODY_REQUIRED400Request body is required.No
UNAUTHORIZED401Missing or invalid API key.No
FORBIDDEN403You do not have permission to do this.No
NOT_FOUND404The requested resource was not found.No
CONFLICT409The request conflicts with the current state of the resource.No
PAYLOAD_TOO_LARGE413The request body is too large.No
INSUFFICIENT_CREDITS402Not enough credits. Required: {required}, available: {available}.No
RATE_LIMITED429Too many requests. Retry after {retryAfter} seconds.Yes
TOO_MANY_ACTIVE_JOBS429Too many active jobs ({active}/{limit}). Wait for current jobs to finish.Yes
INTERNAL_ERROR500Something went wrong on our side. Please try again.Yes
UPSTREAM_ERROR502A downstream service failed. Please try again.Yes
SERVICE_UNAVAILABLE503Service temporarily unavailable. Please try again later.Yes

Codes of particular endpoints:

errorCodeHTTPMessageRetry?
ENDPOINT_NOT_FOUND404Endpoint not found. Check the path and HTTP method.No
MODEL_REQUIRED422model is required.No
PROMPT_REQUIRED422prompt is required.No
MODEL_NOT_FOUND404Model not found. See GET /v2/models for available models.No
MODEL_WRONG_CATEGORY422This model belongs to another category. Use the endpoint for its category.No
SERVER_NOT_FOUND422This server is not available for the model. See details for available servers.No
IDEMPOTENCY_KEY_REUSED422This idempotency key was already used for a different request. Use a new key.No
INVALID_DPI422dpi must be between {min} and {max}.No
INVALID_FORMAT422format must be one of: {allowed}.No
INVALID_ASPECT_RATIO422aspectRatio must be W:H (positive integers, e.g. 16:9) or "auto", at most {max}:1. Received "{value}".No
INVALID_RESOLUTION422resolution '{value}' is not valid. Use one of: {supported}.No
RESOLUTION_NOT_SUPPORTED422Resolution '{value}' is not supported yet. Available: {supported}.No
REFERENCE_IMAGE_UNREACHABLE422 (some endpoints 400)Could not download reference image: {url}. Check that the link is alive and allows server downloads.No
AGENT_QUEUE_FULL429The queue is full ({queued} waiting, {running} running). Try again shortly.Yes
NO_AGENT_AVAILABLE503No worker is available right now. Please try again shortly.Yes
INVALID_COUNT422count must be between {min} and {max}.No
COUNT_NOT_SUPPORTED_FOR_API_KEY400count is web-only. With an API key, send one request per image.No
ROUND_NOT_AFFORDABLE402Not enough credits for this many images.No
INVALID_VISIBILITY422visibility must be 'public' or 'private'.No
RESOLUTION_REQUIRES_PLAN403This resolution requires an active plan.No
JOB_NOT_FOUND404Job not found.No
JOB_NOT_READY400The job has not finished yet.No
JOB_PUBLISHED409The job is published. Unpublish it first.No
CHARACTER_NOT_FOUND404Character not found.No
REF_IMAGE_NOT_FOUND404Reference image not found.No
ASSET_NOT_FOUND404Asset not found.No
ASSET_ALREADY_CONFIRMED409This upload was already confirmed.No
UNSUPPORTED_FILE_TYPE400Unsupported file type.No
UPLOAD_FAILED400 (some endpoints 500)Upload failed. Please try again.Yes
QUOTA_EXCEEDED429 (some endpoints 400)Quota exceeded. Delete some items or upgrade your plan.No
UPLOAD_QUOTA_EXCEEDED429Daily upload limit reached. Try again after 00:00 UTC, or use an image URL you already host.Yes
TEAM_NOT_FOUND404Publishing team not found.No
POST_NOT_FOUND404Post not found.No
PUBLISH_FAILED502Could not publish. Please try again.Yes
NO_API_ACCESS403Your plan does not include API access.No
NO_PUBLISHING_TEAM404No publishing team found. Connect a social account first.No
INVALID_GENRE422Unknown music genre.No
NO_CONNECTED_ACCOUNT400This platform is not connected. Connect it first.No
ACCOUNT_NEEDS_ATTENTION409The page for {platform} changed or lost access. Select the page again before posting.No
CHANNEL_LIMIT403Connected channel limit reached.No
NO_SUBSCRIPTION500Publishing is not set up for this account. Contact support.No
INVALID_DATE_RANGE400Invalid date range. Use 1DAY, 7DAY or 30DAY.No
BRAND_KIT_NOT_FOUND404Brand kit not found, or it belongs to another account.No
STYLE_NOT_FOUND404Saved style not found, or it belongs to another account.No
PROPS_INVALID400A request field is invalid. The error message says which one.No
PROP_INVALID400Field {field} {reason}.No
PROP_TOO_LONG400Field {field} {reason}.No
PROP_REQUIRED400Field {field} {reason}.No
ASSET_INVALID400The file could not be used. The error message says why.No
ASSET_MISSING404The referenced asset was not found.No
ASSET_KIND_NOT_ALLOWED400This kind of asset is not allowed here.No
AUDIO_SOURCE_CONFLICT400Send only one of audioKey or audioUrl.No
ROTATE_REQUIRES_LOGIN403An API key cannot rotate itself. Sign in to rotate it.No

Webhooks:

errorCodeHTTPMessageRetry?
INVALID_WEBHOOK_URL422url must be a public https URL on port 443 without credentials.No
INVALID_WEBHOOK_EVENT422Unknown event type. See details for allowed values.No
WEBHOOK_LIMIT_REACHED422You can have at most {limit} webhook endpoints.No
WEBHOOK_NOT_FOUND404Webhook endpoint not found.No
DELIVERY_NOT_FOUND404Delivery not found.No
WEBHOOK_DISABLED409This webhook endpoint is disabled. Enable it first.No

Motion — reading a source video (POST /motion/analyses; the last four usually come as error.code of an analysis that failed):

errorCodeHTTPMessageRetry?
TEMPLATE_NOT_FOUND404Template not found, or your account has no access to it.No
SOURCE_NOT_SUPPORTED400This template does not accept a source video.No
URL_NOT_ALLOWED400sourceUrl must be a public http(s) URL on port 80 or 443.No
ANALYSIS_NOT_FOUND404Analysis not found.No
URL_FETCH_FAILED502Could not download the video from this URL.Yes
ASSET_TOO_LARGE413The video is too large (max 300 MB).No
SOURCE_INVALID422The source video could not be read. Use an mp4 / mov / webm file.No
ANALYSIS_FAILED502Video analysis failed. Please try again later.Yes