API Reference Basics
Errors
One error shape for the REST API, one for the MCP endpoint, and the reason codes you will meet in both.
mot reports every failure with an HTTP status and a machine-readable reason. Branch on reason, not on the human message: messages can be reworded, reasons do not change.
#REST error shape
The REST API at https://api.mot3r.com returns errors as a JSON object with a single error key.
{
"error": {
"status": 404,
"reason": "not_found",
"message": "No such endpoint."
}
}| Field | Type | Description |
|---|---|---|
status | integer | The HTTP status, repeated in the body. |
reason | string | Stable code in snake_case. |
message | string | A sentence in English for a person or a model. |
Some errors add fields next to these three, for example available_micros and needed_micros on insufficient_balance.
A value the API could not read is never reported as zero. When the database does not answer, the API returns 503 with the reason unmeasured.
#MCP error shape
The MCP endpoint at https://mcp.mot3r.com/mcp answers in JSON-RPC 2.0. The HTTP status is set as well, and error.data carries the same status and reason as the REST API.
{
"jsonrpc": "2.0",
"error": {
"code": -32001,
"message": "Unauthorized — send Authorization: Bearer <tunnel key>.",
"data": { "status": 401, "reason": "missing_credential" }
},
"id": 3
}The JSON-RPC code follows the HTTP status:
| HTTP status | JSON-RPC code |
|---|---|
400, 404 | -32602 |
401 | -32001 |
402 | -32002 |
403, 423 | -32003 |
409 | -32009 |
410 | -32010 |
429 | -32004 |
503 and any other failure | -32005 |
When a 429 carries a wait time, the response has a Retry-After header and error.data.retry_after_s.
#Reason codes
These are the reasons you will meet most often. Each one below was observed on the production endpoints or is raised by the code path named in the description.
#Request
| Status | reason | When | What to do |
|---|---|---|---|
400 | bad_json | The body is not valid JSON. | Fix the body. |
400 | bad_<field> | A field has the wrong type or format, for example bad_from on GET /v1/usage. | Check the parameter table of the endpoint. |
400 | batch_tools_call_not_supported | A JSON-RPC batch on /mcp contains a tools/call. | Send each tool call as its own request. |
404 | not_found | The path does not exist. | Check the method and path. |
406 | /mcp request whose Accept header lacks application/json or text/event-stream. | Send Accept: application/json, text/event-stream. | |
413 | body_too_large | The REST body is over 64 KB. | Split the request. |
415 | json_required | A REST body without Content-Type: application/json. | Add the header. |
#Authentication and permission
| Status | reason | When | What to do |
|---|---|---|---|
401 | missing_credential | No Authorization header. | Send Authorization: Bearer <key>. |
401 | no_session | No key on an account route such as GET /v1/balance. | Send the root key. |
401 | invalid_credential | The key is malformed, unknown or revoked. | Check the key; after a rotation use the new one. |
401 | root_key_not_allowed | A root key was sent to /mcp. | Use a tunnel key. |
403 | key_kind_not_allowed | This kind of key cannot use the route. | Use the key kind the endpoint names. |
403 | scope_denied | The key lacks the scope for this tool family. data.family names it. | Create a key with the scope. |
403 | trust_too_low | The account's current trust level does not include this tool family. data.family and data.trust say which. | See Rate limits for the families of each level. |
403 | test_family_forbidden | A test key called a tool family that test keys cannot use, such as line. data.family names it. | Use a tunnel key on a funded account. |
403 | service_off | The family is switched off for this account or key. | Switch it on in the panel. |
403 | bad_origin | A browser request came from another site. | Call the API from your server. |
#Money and limits
| Status | reason | When | What to do |
|---|---|---|---|
402 | insufficient_balance | The balance does not cover the call. available_micros and needed_micros give the numbers. | Top up the account in the panel (minimum 10 USD). |
429 | rate_limited | The key exceeded its requests-per-minute limit. Retry-After: 60. | Wait and retry. |
429 | daily_cap, monthly_cap | The account reached its spending cap for the day or month. | Wait for the next day or month, or raise the trust level. |
429 | key_daily_cap | The key reached its own daily spending cap. | Wait for the next day or raise the key's cap. |
429 | test_daily_calls, test_daily_sends | A test key used its daily calls or sends. data.limit gives the limit. | Wait for the next day or use a tunnel key. |
429 | mail_daily_limit | The daily number of mail recipients is reached. | Wait for 00:00 UTC. |
429 | too_many_streams | The key already holds 5 open event streams. Retry-After: 30. | Close a stream. |
429 | too_many_attempts | Too many sign-in, sign-in link, password reset or code requests from the account or the address. Retry-After and data.retry_after_s give the wait. See Rate limits. | Wait and retry. |
429 | signup_rate_ip, signup_rate_global | Too many sign-ups from this address, or the service-wide daily sign-up limit is reached. | Wait for the Retry-After time. |
429 | code_attempts_exhausted | The e-mail confirmation code was entered wrong too many times. | Request a new code. |
#Tunnels and cables
| Status | reason | When | What to do |
|---|---|---|---|
404 | line_not_found | The tunnel id is not in this account. | Check the id with GET /v1/lines. |
409 | lease_required | A tool that writes as the tunnel was called before line_attach. | Call line_attach first. |
409 | cable_superseded | Another cable holds the tunnel now. Reads still work. | Stop writing, or ask the owner to switch the tunnel back. |
409 | lease_released | This cable released its lease. | Call line_attach again. |
409 | memory_full | The memory of the tunnel is full. | Remove content with mRAG_delete or raise the limit. |
409 | mail_account_inactive | The tunnel has no active mail account. | Activate mail for the tunnel in the panel. |
423 | line_off | The owner switched the tunnel off for agents. | Ask the owner to switch it back on. |
423 | line_muted | The owner muted the tunnel: reads work, outgoing writes are refused. | Ask the owner to unmute it. |
#Service
| Status | reason | When | What to do |
|---|---|---|---|
503 | unmeasured | The API could not read a value. Retry-After: 5. | Retry. This is a failure on our side, not missing data. |
503 | auth_unavailable | The key could not be checked. | Retry in a moment. |
503 | auth_busy | The sign-in queue is full. Retry-After: 60. | Retry after the wait. |
503 | magic_unavailable | The server cannot send the sign-in link e-mail at the moment. | Sign in with e-mail and password, or retry later. |
503 | edge_not_live | The tool needs the edge channel service (domain rooms, edge channels), which is not connected to the gateway. data.tool names the tool. The call costs zero. | Use the other mURL_ and mIRC_ tools; retrying does not help. |
#Example: handle an error
curl -sS -w "\n%{http_code}\n" https://api.mot3r.com/v1/balance \
-H "Authorization: Bearer mot_lk_live_xxxxxxxxxxxx"const res = await fetch('https://api.mot3r.com/v1/balance', {
headers: { Authorization: 'Bearer mot_lk_live_xxxxxxxxxxxx' },
});
if (!res.ok) {
const { error } = await res.json();
if (error.reason === 'insufficient_balance') {
// ask the account owner to top up
}
throw new Error(`${error.status} ${error.reason}: ${error.message}`);
}