# Errors

Source: https://docs.lightair.app/developers/control/errors

> How Lightair's Remote API reports a failed call over JSON-RPC, MCP, obs-websocket and the command line, with every error code and what it means.

In short:
- A failed JSON-RPC call answers `error: {code, message}`. The message says what was wrong in plain words.
- `-32602` bad parameters, `-32004` no such scene or object, `-32005` not now, `-32000` it was tried and failed, `-32001` password.
- An MCP tool that fails answers a result with `isError: true` and the same message, so the agent can try again.
- `lightair call` prints the message on stderr and exits with 1.

Every way into Lightair reports a failure the same way underneath: a kind of error and a message written for a person. Show the message as it is; it names what was wrong ("no destination Twitch", "no stream key saved for Twitch") and often what to do.

## JSON-RPC

A failed call on `/rpc` answers with an `error` object instead of `result`:

```json
{"jsonrpc": "2.0", "id": 4, "error": {"code": -32004, "message": "no destination Twitch"}}
```

| Code | Meaning | Examples |
|---|---|---|
| `-32700` | The message isn't JSON | The parser's own message; `id` is null |
| `-32600` | The request isn't a request | "a request needs a method", "empty batch" |
| `-32601` | No such method | "Lightair has no method scene.swtich" |
| `-32602` | A parameter is missing or wrong | A required name left out, a value out of range, a name that isn't allowed |
| `-32001` | The password is missing or wrong | "send the password first (auth.login)", "wrong password" |
| `-32004` | No such scene, object, source, track, destination or canvas | "no canvas Vertical" |
| `-32005` | Not now: Lightair is in a state where it can't | Already recording, not live, a destination with no stream key, the person said no |
| `-32000` | It was tried and didn't work | A file couldn't be written; "Lightair didn't answer in time"; "Lightair is closing" |

`-32005` also covers errors from platforms and plugins: sending chat, moderating, and the commands and steps of a helper plugin come back with this code and the platform's or plugin's own message.

A method that Lightair's window answers has 20 seconds. If the window is busy for longer, the call fails with `-32000` "Lightair didn't answer in time"; the action may still happen after that.

### Connection errors

Some problems end the connection or are answered before it becomes a WebSocket:

| What happens | Why |
|---|---|
| HTTP 403 "Forbidden host" | The request's `Host` isn't a local name and **Other devices on your network** is off. See [the Host check](/developers/control/connect#the-host-check) |
| HTTP 404 "Not found" | A path other than `/`, `/rpc` or `/mcp` |
| The WebSocket closes with code 1003, "text messages only" | A binary message was sent |
| The WebSocket closes with code 1001, "Lightair stopped the remote API" | The server was turned off or restarted (a new port or password) |
| The connection is refused | Lightair isn't running, **Let other apps control Lightair** is off, or the port is different |

## MCP

On `/mcp`, protocol problems are JSON-RPC errors and a failed tool is a tool result.

| What happens | Why |
|---|---|
| HTTP 401, error `-32001` "Lightair's remote API password is missing or wrong (Settings > Remote API)", header `WWW-Authenticate: Bearer` | Every request needs `Authorization: Bearer <password>` while a password is asked |
| HTTP 404, error `-32001` "No such session: initialize again" (a `GET` or `DELETE` gets a plain 404) | The `Mcp-Session-Id` is unknown, usually because Lightair started again. Send `initialize` again |
| HTTP 400 "Send initialize first and give its Mcp-Session-Id" | A `GET /mcp` without a session |
| HTTP 405 | A method other than `POST`, `GET` or `DELETE` |
| Error `-32601` "no method …" | An MCP method Lightair doesn't answer |
| Error `-32602` "Lightair has no resource …" or "Lightair has no prompt …" | A wrong resource URI or prompt name |
| Error `-32600` "subscriptions need a session: …" | `resources/subscribe` without a session |

A tool call that fails answers normally, with the message as text and `isError: true`, so an agent sees why and can try again:

```json
{"content": [{"type": "text", "text": "no destination Twitch"}], "isError": true}
```

Messages only MCP gives:

| Message | Why |
|---|---|
| "Lightair has no tool named …" | A wrong tool name |
| "… needs an action: list, start, stop, …" | A tool with actions called without one, or with one it doesn't have |
| "The person said no (or didn't answer), so Lightair didn't do it." | An on-air action the person declined through the agent's client, or didn't answer within 120 seconds |
| "The person didn't allow it in Lightair, so it wasn't done." | The person chose **Don't Allow** in Lightair's own window |
| "Lightair asked the person to allow it and nobody answered, so it wasn't done." | Nobody answered Lightair's window within 90 seconds |
| "Lightair isn't running (open it, and turn on Settings › Remote API)" | `lightair mcp` couldn't reach or open Lightair |

When `lightair mcp` can't reach Lightair for another reason, it answers with error `-32000` and a message that starts with "Lightair: ". See [MCP server](/developers/control/mcp#confirmation-of-on-air-actions) for when Lightair asks the person.

## obs-websocket

obs-websocket answers each request with a `requestStatus`. Lightair uses OBS's codes:

| Code | Meaning |
|---|---|
| `100` | Success |
| `204` | A request Lightair doesn't answer: "Lightair doesn't do `…` yet." |
| `300` | A required field is missing: "Your request is missing the `sceneName` field." |
| `402` | A field has the wrong type or value |
| `500` | The output is already running |
| `501` | The output is not running |
| `506` | Studio mode is not active (every studio mode request) |
| `600` | No such scene, scene item, input or output |
| `702` | It couldn't be done now, or it was tried and failed |

The connection closes with obs-websocket's codes: `4002` for a message that isn't JSON or has no `op`, `4007` for a request before `Identify`, `4009` for a wrong password, `4010` for an `rpcVersion` other than 1.

## Command line

`lightair call` prints the result on stdout and exits with 0. When the call fails, it prints the error's message on stderr and exits with 1. It exits with 2 when it's used wrongly: no method, or parameters that aren't JSON.

```sh
lightair call scene.switch '{"scene": "Nowhere"}'
# stderr: no scene Nowhere   (exit 1)
```

When nothing answers on the port, the message starts with "Lightair isn't running".

## Related

- [Connect to the Remote API](/developers/control/connect)
- [MCP server](/developers/control/mcp)
- [Command line](/developers/control/command-line)
