Skip to content

Error Handling & Status Codes

Wetel’s API is a standard NestJS GraphQL (Apollo Server) service. Errors are not returned in the data field — they show up in the top-level errors array of the GraphQL response, each with a message and an extensions object.

{
"errors": [
{
"message": "Agent #42 not found",
"extensions": {
"code": "NOT_FOUND",
...
}
}
]
}

Always branch your client’s error handling on errors[].extensions.code (or, failing that, the exception’s HTTP-equivalent semantics below), not on parsing message text — message strings are meant for humans and can change without notice.

A note on precision: Wetel’s backend relies on Apollo Server’s and @nestjs/graphql’s default exception-to-extensions.code behavior, with a few additions: a “not found” (HTTP 404 semantics) answers NOT_FOUND, a conflict (409) answers CONFLICT, a rate limit answers TOO_MANY_REQUESTS, an upstream failure of your own MCP server in listMcpTools answers BAD_GATEWAY (status 502), and a refused outbound URL answers BAD_REQUEST with extensions.originalError.code OUTBOUND_URL_REFUSED (see Refused URLs and an unreachable MCP server). In practice this means standard NestJS HTTP exceptions map to predictable codes (unauthorized/forbidden-style exceptions to UNAUTHENTICATED/FORBIDDEN, validation failures to BAD_USER_INPUT, unhandled errors to INTERNAL_SERVER_ERROR), but because there’s no custom mapping layer to point to as the source of truth, treat the exact code string as informative rather than a hard contract, and always log the full extensions object during integration/debugging rather than hardcoding a single expected value. The full code table with a real example of each is on Errors.

The exception vocabulary the API actually throws

Section titled “The exception vocabulary the API actually throws”

Surveying the backend’s resolvers and services, errors are raised using a small, consistent set of standard NestJS exception classes — there is no bespoke error-code enum layered on top. In rough order of how often each shows up in the API:

  • BadRequestException — malformed input, a business-rule validation failure (e.g. a quota check, an invalid state transition). Most common exception in the codebase. For input validation, extensions.code is BAD_REQUEST; extensions.originalError.message is the array of constraint messages, and the top-level message is those messages joined with ; .
  • ForbiddenException — the caller is authenticated but not allowed to do this. This is also what you get from most resolvers when no tenant is associated with the calling token (e.g. “No tenant assigned”).
  • NotFoundException (extensions.code NOT_FOUND) — the requested resource (agent, session, workflow, custom action, etc.) doesn’t exist, or doesn’t exist for your tenant — Wetel’s multi-tenancy model returns “not found” rather than a distinct “forbidden” for cross-tenant access attempts, so as not to confirm whether a given ID exists at all under another tenant.
  • UnauthorizedException — authentication itself failed (missing/invalid/expired token).
  • InternalServerErrorException — an unexpected failure the API couldn’t map to a more specific case (e.g. a downstream provider call failed unexpectedly during message processing). If you see this repeatedly for the same operation, it’s worth reporting — it usually means an edge case the API doesn’t yet handle explicitly.
  • ConflictException (extensions.code CONFLICT) — rare; used for a small number of state-conflict cases (e.g. attempting an operation against a resource in a state that doesn’t support it).

A GraphQL call refused by a rate limit answers extensions.code TOO_MANY_REQUESTS, a message such as Too many requests. Try again in about 2 minutes. and extensions.retryAfterSeconds (whole seconds to wait). extensions.status is 429 and the HTTP status of the response is still 200. Branch on the code and wait retryAfterSeconds before retrying; do not match on the message text. Which operations are throttled, and how each limit is keyed, is on Rate limiting.

The per-workspace cap on headless tasks in flight (TENANT_BUSY, see Workflow tasks) answers the same code and status but carries no retryAfterSeconds: retry when an earlier task finishes.

Only when the platform has email-verification enforcement on (off by default). A short list of operations answers HTTP 403, extensions.code EMAIL_NOT_VERIFIED and the message Verify your email address first for an account whose email is not verified. Verify the address, then retry; see Email verification.

Wetel does not accept compressed request bodies. A request to any Wetel API (GraphQL, REST, the speech and avatar service, and webhook receivers) that carries a Content-Encoding header other than identity, such as gzip, deflate or br, is refused with HTTP 415. When the application answers, the body is:

{
"statusCode": 415,
"code": "UNSUPPORTED_CONTENT_ENCODING",
"message": "Compressed request bodies are not accepted. Send the body without Content-Encoding."
}

The public edge applies the same rule first, so a plain 415 page without that JSON is possible too: branch on the status. This is a transport refusal, not a GraphQL error: there is no errors array and no extensions.code. Browsers, fetch, axios and the usual GraphQL clients send plain JSON by default, so most integrations never see it. It appears when something in your path compresses requests: a proxy or gateway, an HTTP client with request compression switched on, or a script that pipes gzip output into curl.

Terminal window
# refused: 415
curl -sS -X POST https://api.wetel.dev/graphql \
-H 'content-type: application/json' -H 'content-encoding: gzip' \
-H 'x-huat-platform: customer' --data-binary @query.json.gz
# accepted: the same request without Content-Encoding
curl -sS -X POST https://api.wetel.dev/graphql \
-H 'content-type: application/json' -H 'x-huat-platform: customer' \
--data-binary @query.json

Not retryable as sent. The fix is to remove the header and send the body uncompressed: switch off request compression in your HTTP client, gateway or proxy for calls to Wetel (a request-compression interceptor or transformRequest that gzips, a gateway’s “compress upstream requests” option), or exempt Wetel’s hostnames. A request body is at most a few megabytes, so nothing is lost. Content-Encoding: identity is accepted. Compression of responses is unaffected: keep sending Accept-Encoding as you do today.

When Wetel calls a URL that you configured, it does not decompress Brotli, and its error names the refused encoding. Which calls refuse what:

Wetel callAsks forRefuses
webhook and action node requests (so Custom Actions), and their file fetchesAccept-Encoding: identityany response with a Content-Encoding
MCP connector calls (tool node, listMcpTools), externalSyncUrl deliveries, knowledge-base URL ingestionAccept-Encoding: gzip, deflatea Brotli (br) response; gzip and deflate still work

The failure is an ordinary node or call failure: a failure edge handles it, and nodeTrace shows the error. Fix it on your side: turn off response compression for the endpoint Wetel calls, or answer with an uncompressed body when the request says Accept-Encoding: identity. A server that follows Accept-Encoding needs no change. We have not listed other outbound calls (for example calls to model providers or to Wetel’s own services) because they are not configured by you.

The specific case of a missing platform header

Section titled “The specific case of a missing platform header”

A request missing the required x-huat-platform: customer header produces an error that can look unrelated to authentication at first glance. This is a known, documented gotcha with its own explanation and fix — see Authentication rather than duplicating it here. If you’re seeing an unexplained rejection on every request from a new integration, check that header first.

Failures inside a running workflow (a node erroring out mid-execution) are not the same thing as a GraphQL request error — the mutation that started the session can succeed while a later node in the workflow still fails. These surface through the event/subscription layer:

  • The NodeFailedEvent subscription event, if you’re subscribed to it.
  • workflowRun.nodeTrace, which records what happened node-by-node (JWT-authenticated access only today).

Each nodeTrace entry carries a status. Three of them mean materially different things, and are worth handling distinctly rather than collapsing into “something failed”:

  • FAILED — that node threw, and nothing intercepted it, so the whole run stopped there.
  • FAILED_HANDLED — a tool, action, webhook, llm, sub_agent or set_variable node threw, but the graph has a failure-labeled edge, so the workflow routed down it and the run itself still completed. Not an outage; the author planned for it.
  • BUDGET_EXCEEDED — the run exhausted its execution budget and the engine refused to dispatch the named node. Nothing went wrong with that node; it never ran. The run is persisted as FAILED, and the entry carries budgetLimit ("maxNodeExecutions" or "deadline"), budgetNodeExecutions and budgetElapsedMs so the cause is readable without parsing the message string.
  • VISIT_LIMIT_REACHED — the graph came back to a node that had already used up its own maxVisits for this run, so the engine refused to dispatch it again. Like BUDGET_EXCEEDED, nothing went wrong with the node. Unlike it, this does not on its own mean the run failed — read the run’s status. The entry carries visitLimit and visitCount. Three outcomes are possible: the node had a 'loop_exhausted' edge and the run carried on down it (usually COMPLETED); the node declared maxVisits and had no escape edge, so the run is FAILED; or the node never declared maxVisits, in which case that branch simply stops and the rest of the graph continues. Full detail: Workflow Overview: Loops and re-entry and Workflows API: Loop re-entry and VISIT_LIMIT_REACHED.

A run’s ceilings are 250 node executions and 10 minutes of wall-clock time; a graph is additionally capped at 200 nodes / 400 edges when it is saved or published, which surfaces as an ordinary BadRequestException on the mutation rather than a run-time failure. Full detail: Workflow Overview: Graph size and run limits and Workflows API: Run limits and BUDGET_EXCEEDED.

A run that is waiting is not a run that failed

Section titled “A run that is waiting is not a run that failed”

A run with status: "AWAITING_INPUT" paused at an await_reply node and is waiting on the user’s next message. It is neither complete nor broken, and it will never transition to COMPLETED — the reply is executed as a separate run whose resumedFromRunId points back at it. Don’t build alerting that treats a non-COMPLETED run as a failure without excluding this status; use pendingAwaitReplies to see what is waiting and until when.

Full details, event shapes, and query examples are already covered in Workflow API Reference and Troubleshooting — this page won’t duplicate them.

This is the one list; the other pages link here.

AnswerRetry?
TOO_MANY_REQUESTSYes, after extensions.retryAfterSeconds; without it, after the operation’s window (usually 60 seconds)
INTERNAL_SERVER_ERROR, BAD_GATEWAYYes, with exponential backoff and a cap on attempts; if it repeats for the same operation, report it
HTTP 415 (compressed body)Not as sent; resend the body without Content-Encoding
UNAUTHENTICATED, FORBIDDEN, NOT_FOUND, CONFLICTNo; fix the credential, the header or the id (re-read the resource on CONFLICT)
BAD_REQUEST, BAD_USER_INPUT, GRAPHQL_VALIDATION_FAILED, QUERY_TOO_COMPLEXNo; the same request gives the same answer
EMAIL_NOT_VERIFIEDOnly after verifying the address

Two rules behind the table:

  • Always branch on errors[].extensions.code first; fall back to message only for logging and debugging.
  • A specific code does not map 1:1 to one business meaning across every operation: FORBIDDEN, for instance, is used both for “no tenant on this token” and for genuine authorization failures. Read the message for the specific reason during development.

An operation with no enforced rate limit today can gain one; design any headless integration with this retry logic regardless, especially one that fans a single external event into many calls in a short window.