Skip to content
Scalekit Docs

Error handling

Catch and respond to invalid tokens, bad requests, missing resources, and rate limits on the Scalekit REST API.

Catch and respond to invalid tokens, bad requests, missing resources, and rate limits.

A failed REST call returns an HTTP status and a JSON body. Official SDKs raise typed exceptions for the same failures. Use the body, or the exception fields, to choose a response.

For the endpoint catalog, open the API reference. Product catalogs live at SaaSKit APIs and AgentKit APIs.

FieldMeaning
codegRPC (remote procedure call) status number. This is not the HTTP status. Example: 16 means Unauthenticated.
messageHuman-readable reason. Safe for logs. Do not show raw messages to end users.
details[].error_codeStable slug to switch on, such as UNAUTHENTICATED.
details[].validation_error_infoPresent on some 400 responses. Lists field violations (field, description, constraint).
details[].tool_error_infoPresent when a tool call fails. Includes execution_id, tool_error_message, and tool_error_code.
details[].help_infoOptional documentation links when the server attaches them.

Scalekit does not return a request ID or a dashboard log URL in this envelope.

401 when the bearer token is missing
{
"code": 16,
"message": "Token empty",
"details": [
{
"@type": "type.googleapis.com/scalekit.v1.errdetails.ErrorInfo",
"error_code": "UNAUTHENTICATED"
}
]
}

Switch on details[].error_code. Do not switch on code alone.

  • Codes in the 2xx range mean success.
  • Codes in the 4xx range mean the request failed given the data you sent. Fix the request. Do not retry the same payload, except for 429.
  • Codes in the 5xx range mean a server fault. Retry with backoff. Treat the result as unknown until a later call succeeds.
HTTPTypical error_codeMeaning
200 / 201n/aSuccess
400INVALID_ARGUMENT, BAD_REQUESTInvalid request or validation failure
401UNAUTHENTICATEDMissing or invalid bearer token
403PERMISSION_DENIED, FORBIDDENAuthenticated, but not allowed
404NOT_FOUND, RESOURCE_NOT_FOUNDResource does not exist
409RESOURCE_ALREADY_EXISTSDuplicate resource
429RATE_LIMITED, TOO_MANY_REQUESTSRate limit exceeded
500INTERNAL_ERRORServer error

SDKs translate non-success HTTP responses into exceptions. Catch the specific type first, then fall back to the base server exception.

catch-api-errors.ts
import {
ScalekitNotFoundException,
ScalekitUnauthorizedException,
ScalekitTooManyRequestsException,
ScalekitServerException,
} from '@scalekit-sdk/node'
try {
// Your Scalekit SDK call
await scalekit.organization.listOrganization({ pageSize: 30 })
} catch (err) {
if (err instanceof ScalekitUnauthorizedException) {
// Get a new access token. Do not retry the same bearer token.
} else if (err instanceof ScalekitNotFoundException) {
// Create the resource or return not-found to the caller.
} else if (err instanceof ScalekitTooManyRequestsException) {
// Back off. Read err.errorCode: RATE_LIMITED vs TOOL_ERROR.
} else if (err instanceof ScalekitServerException) {
// Log err.message and err.errorCode. Retry only on 5xx or 429.
} else {
throw err
}
}

Typed exception names and tool-specific types are listed on AgentKit Node error handling and AgentKit Python error handling.

error_codeProblemWhat to do
UNAUTHENTICATEDMissing header (Token empty), bad Bearer value (Invalid Token), or expired token (token expired)Request a new token. Do not retry the same token. See Authenticate with the Scalekit API.
INVALID_ARGUMENT / BAD_REQUESTThe request is malformed or fails validationFix the fields. Do not retry the same payload.
PERMISSION_DENIED / FORBIDDENThe caller is authenticated but not allowedChange roles, scopes, or the target resource.
NOT_FOUND / RESOURCE_NOT_FOUNDThe resource does not existCreate it, or return not-found to your user.
RESOURCE_ALREADY_EXISTSA create conflicts with an existing resourceUse the existing ID, or pick a new unique value.
RATE_LIMITED / TOO_MANY_REQUESTSA Scalekit service rejected the callBack off, then retry. See API rate limits.
TOOL_ERRORA tool call failedRead tool_error_info.tool_error_code. An inner RATE_LIMITED is the upstream provider.
INTERNAL_ERRORA server faultRetry with backoff. Treat the result as unknown until a later call succeeds.

/api/v1 accepts a bearer access token from client credentials. It does not accept an API key header.

Some 400 responses include validation_error_info.field_violations. Each violation names the field, a description, and the constraint that failed. The JSON below is an example of that shape.

Example validation error shape
{
"code": 3,
"message": "Validation error",
"details": [
{
"@type": "type.googleapis.com/scalekit.v1.errdetails.ErrorInfo",
"error_code": "INVALID_ARGUMENT",
"validation_error_info": {
"field_violations": [
{
"field": "page_size",
"description": "value must be less than or equal to 30",
"constraint": "lte"
}
]
}
}
]
}

Tool execution sets the outer error_code to TOOL_ERROR. The inner slug is tool_error_info.tool_error_code. An upstream provider 429 still returns HTTP 429.

Upstream provider rate limit on a tool call
{
"code": 8,
"message": "tool execution failed - rate limited",
"details": [
{
"@type": "type.googleapis.com/scalekit.v1.errdetails.ErrorInfo",
"error_code": "TOOL_ERROR",
"tool_error_info": {
"execution_id": "exec_123",
"tool_error_message": "rate limit",
"tool_error_code": "RATE_LIMITED"
}
}
]
}

Read the outer code first. Then read tool_error_info.tool_error_code when the outer code is TOOL_ERROR.

When a service exceeds its limit, Scalekit returns HTTP 429. The response body uses the same error envelope.

Outer error_codeMeaning
RATE_LIMITEDA Scalekit service rejected the call
TOO_MANY_REQUESTSEmail, one-time password (OTP), or time-based one-time password (TOTP) traffic hit a limit
TOOL_ERROR with inner tool_error_code RATE_LIMITEDThe upstream provider rate-limited the tool call

Back off and retry with exponential backoff. Do not retry immediately.

Scalekit does not send a Retry-After header on 429 responses. Limits vary by service and account. For 429 handling in the SDKs, see API rate limits.

Some 400 INVALID_ARGUMENT responses come from list and lookup URLs.

CaseHTTPerror_codeMessage
Bad page_token400INVALID_ARGUMENTinvalid page token or Invalid cursor
:external path plus an id query400INVALID_ARGUMENTExternalId is required

Fix the URL or the query. Do not retry the same request.

For list parameters, see the operation in the API reference. For external IDs, see organization identifiers.