Skip to content
Menu
SilktideDevelopers

Errors

Every error has the same body. Detect it by its type, never by its message.

View as Markdown

A request that fails gets a 4xx status when the request was wrong, or a 5xx when Silktide could not answer. The body says what went wrong:

{
  "error": {
    "type": "AccessDenied",
    "message": "Access denied",
    "properties": []
  }
}
FieldWhat it is
typeWhat went wrong, such as ModelNotFound. It is stable, so branch on it.
messageA readable explanation, in the language of the key's user. It can change at any time, so show it, but never match on it.
propertiesDetails, when the error has any, as an object. An empty array ([]) when it has none.

Errors you will meet#

StatusTypeMeans
400InvalidRequestA parameter has a value Silktide does not accept, such as an id in the path that is not a whole number. message says what is wrong, and properties.field, when present, names the parameter.
401NotLoggedInNo key was sent, the key is wrong, or it belongs to another region. See Authentication.
403AccessDeniedThe key cannot do this. The operation's page says what it needs under Access.
404ModelNotFoundNothing with that id exists in the account.
429TooManyRequestsToo many requests. properties.retryAfter and the Retry-After header give the seconds to wait. See Rate limits.
503ServiceUnavailable, or another typeSilktide is busy. Retry after the number of seconds in Retry-After.

Each operation's page lists the errors it can return, and what each means there.

Results report some errors as 200#

The results operations, under /v1/results/, report errors they find while answering with status 200 and an error body in place of result. Check for error before you read result:

const body = await response.json();
if (!response.ok || body.error) {
  throw new Error(body.error?.message ?? `HTTP ${response.status}`);
}

Retrying#

Retry 429 and 503 after the Retry-After header's seconds. Retry other 5xx a few times with a growing wait. Do not retry other 4xx: the same request will fail the same way.