Concepts

Errors

One error shape for every endpoint, the codes it uses, and the CLI's exit codes.

Every failure answers with the same JSON:

{
  "error": {
    "code": "invalid_request",
    "message": "text: Required.",
    "details": [{ "path": "text", "message": "Required." }]
  }
}

Branch on code; message is written for people and safe to show as is. details lists each problem in a request that isn't valid.

StatusCodeWhen
400invalid_requestA field is missing, mistyped or unknown. Unknown fields are refused, and the message lists the ones the endpoint takes.
400workspace_requiredA personal key or OAuth token in several workspaces didn't say which. See choosing the workspace.
401unauthorizedNo key, or it's invalid, expired or turned off.
402payment_requiredThe workspace's plan doesn't include the API, or a limit or monthly allowance is used up. The message says which.
403forbiddenThe guardrails don't allow it, the workspace is suspended, or the key can't act on that workspace.
404not_foundNo such endpoint, or no such item in this workspace.
405method_not_allowedThe path exists with other methods; the Allow header lists them.
409conflictThe item's state doesn't allow it, for example a post that already went out.
413payload_too_largeThe JSON body is over 1 MB, or the file is too big.
415unsupported_media_typeSend application/json (or multipart/form-data to upload media).
422unprocessableUnderstood, but refused: an unknown channel or media id, brand issues to fix first.
429rate_limitedToo many requests. Wait for Retry-After seconds.
500internal_errorSomething went wrong on Tracee's side. Safe to retry reads.
503unavailableA service Tracee needs is down. Retry later.

In the CLI

The CLI prints the message (and each detail) on stderr. With --json it also prints the error object on stdout.

Exit codeMeaning
0Done.
1Tracee refused or failed; the message says why.
2The command was mistyped (unknown command, missing argument, a flag of the wrong type). Nothing was sent.

In the SDK

Each status has its own error class, all extending TraceeError with status, code, message and details: TraceeValidationError (the other 4xx: 400, 402, 413, 415, 422), TraceeAuthError (401), TraceePermissionError (403), TraceeNotFoundError (404), TraceeConflictError (409), TraceeRateLimitError (429, with retryAfter), TraceeServerError (5xx) and TraceeConnectionError (no answer).