> For the complete documentation index, see [llms.txt](https://docs.rad.live/rad/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rad.live/rad/rad-tv-developer-api/response-format-and-errors.md).

# Response Format and Errors

The API uses a consistent envelope so clients can rely on `data` for success and `errors` for failure.

## GraphQL (`POST /graphql`)

Every response follows the [GraphQL spec](https://spec.graphql.org/draft/#sec-Response): `{ data?, errors? }`.

### Success

* **data** is present. The key matches the operation name (e.g. `data.me`, `data.channel`, `data.createContent`).
* Use `response.data` for the result.

Example:

```json
{
  "data": {
    "me": {
      "id": "did:rad.live:user:...",
      "username": "alice"
    }
  }
}
```

### Error

* **errors** is an array of objects: `{ message: string, path?: string[], extensions?: object }`.
* HTTP status may still be 200; always check `response.errors` when present.
* Use `response.errors` for user-facing or logged error messages.

Example:

```json
{
  "errors": [
    {
      "message": "Authentication required.",
      "path": ["me"]
    }
  ]
}
```

Partial data: GraphQL can return both `data` and `errors` when some fields resolve and others fail. Inspect both.

## REST and internal HTTP JSON

For non-GraphQL JSON endpoints (e.g. generate-api-key, youtube disconnect):

### Success (2xx)

* Body shape: `{ data: <payload> }`. The payload is the response body.
* Example (generate-api-key):

```json
{
  "data": {
    "id": "did:rad.live:user:...",
    "key": "..."
  }
}
```

* Example (disconnect):

```json
{
  "data": { "ok": true }
}
```

### Error (4xx / 5xx)

* Body shape: `{ "errors": [ { "message": string, "code"?: string } ] }`.
* HTTP status indicates the error type; the body provides a consistent shape for parsing.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rad.live/rad/rad-tv-developer-api/response-format-and-errors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
