> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
