Errors
Every error has the same body. Detect it by its type, never by its message.
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": []
}
}| Field | What it is |
|---|---|
type | What went wrong, such as ModelNotFound. It is stable, so branch on it. |
message | A readable explanation, in the language of the key's user. It can change at any time, so show it, but never match on it. |
properties | Details, when the error has any, as an object. An empty array ([]) when it has none. |
Errors you will meet#
| Status | Type | Means |
|---|---|---|
400 | InvalidRequest | A 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. |
401 | NotLoggedIn | No key was sent, the key is wrong, or it belongs to another region. See Authentication. |
403 | AccessDenied | The key cannot do this. The operation's page says what it needs under Access. |
404 | ModelNotFound | Nothing with that id exists in the account. |
429 | TooManyRequests | Too many requests. properties.retryAfter and the Retry-After header give the seconds to wait. See Rate limits. |
503 | ServiceUnavailable, or another type | Silktide 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.