> ## Documentation Index
> Fetch the complete documentation index at: https://docs.logbrew.co/llms.txt
> Use this file to discover all available pages before exploring further.

# API error handling and API error codes

> Read LogBrew API error codes, HTTP statuses, and JSON examples. Use the returned recovery instructions to correct requests and retry safely.

LogBrew API errors use one JSON envelope. Use `code` and `next_action` for
program behavior. Show `error` and `next` as plain text. Do not match the
wording of `error` or `next`.

```json theme={null}
{
  "error": "invalid since value",
  "code": "validation_failed",
  "next": "use since=24h, since=7d, or an RFC3339 timestamp",
  "next_action": {
    "code": "fix_request",
    "target": "request"
  }
}
```

| Field | Meaning |
| - | - |
| `error` | Short human-readable problem. |
| `code` | Stable error code. Use it to select the client branch. |
| `next` | Human-readable recovery step. The text is route-specific. |
| `next_action.code` | Stable recovery action for program routing. |
| `next_action.target` | The object that the recovery action applies to, such as `auth` or `request`. |

Some responses add fields, such as `limit`, `reset_at`, or
`retry_after_seconds`. The [error codes](#error-codes) table names them.

## Handle an error response

1. Read the HTTP status.
2. Make sure that the body is JSON before you read `code`.
3. Use the status and `code` together to select the client branch.
4. Show `error` and `next` as plain text. Do not render them as HTML or run them as commands.
5. Use `next_action` for automatic recovery. If the client does not recognize the action, stop and show the error.
6. Keep the returned `limit`, `reset_at`, and `retry_after_seconds` values with the failed request.
7. Before you retry, use the [retry rules](#retry-rules).

If the response has no JSON envelope, keep the HTTP status and record the code
as unavailable. Do not invent a LogBrew `code`. A proxy or network failure can
produce this result.

Do not replace a LogBrew `code` with the HTTP status name. For example, a
`400` response can contain `invalid_json` or `invalid_path`. Each code needs a
different correction.

For logs, record the HTTP status and `code`. Do not log the full body,
credentials, or recovery tokens.

## Error codes

The same `code` can occur on more than one route. The `next` text and the
`next_action` values can change by route. Use the returned values. An
endpoint returns only the codes that apply to its authentication, method,
body, and limits.

| HTTP | `code` | Meaning | Client action |
| - | - | - | - |
| `400`, `413`, `415`, or `422` | `invalid_json` | The body is not valid JSON, is too large, has the wrong content type, or does not match the route's JSON shape. | Send valid JSON with `Content-Type: application/json` and the fields that the route needs. |
| `400`, `413`, or `500` | `invalid_multipart` | The server cannot read a `multipart/form-data` upload. | For `400` or `413`, correct the form or its size. For `500`, use the [retry rules](#retry-rules). |
| `400` or `500` | `invalid_path` | The server cannot read a value in the URL path, such as a project or issue ID. | For `400`, correct the ID and its type. For `500`, use the [retry rules](#retry-rules). |
| `400`, `405`, or `426` | `invalid_websocket_upgrade` | A live feed connection is not a valid WebSocket upgrade. | Connect with `GET` and WebSocket upgrade headers. See the [live event format](https://docs.logbrew.co/reference/telemetry-response-shapes.md#live-event-response-format). |
| `401` | `unauthorized` | Account authentication is missing, invalid, or expired. | Sign in again. For the CLI, run `logbrew login`. |
| `401` | `ingest_key_invalid` | Telemetry ingestion has no valid project-scoped ingest key. | Configure a current ingest key for that project. |
| `402` | `subscription_required` | The action needs a paid plan. Organizations, teammates, and projects do not need one. | Follow `next`. It names the plan step or tells you to contact support. |
| `403` | `forbidden` | The account cannot access the resource or action. | Use an account that has access. Do not try other IDs. |
| `403` | `role_forbidden` | The account cannot make this organization role change. | Ask an organization owner or admin to make the change. |
| `404` | `not_found` | The resource or API route is not available to the account. | Read an owned list again. Then examine the ID, the path, and the filters. |
| `405` | `method_not_allowed` | The route exists, but the HTTP method is not supported. | Use the method that `next` names. |
| `408` | `request_timeout` | The request did not complete in time. | Narrow the scope, or wait and send the request again. |
| `409` | `idempotency_conflict` | An `Idempotency-Key` or `deployment_id` was used again for a different request. | Retry the original request unchanged, or use a new key for new work. |
| `409` | `account_link_conflict` | The sign-in identity belongs to a different account. | Resolve the account link in account settings. Do not create a second account for the same identity. |
| `409` | `account_recovery_available` | The account is in its recovery window. | Follow the returned recovery action. Keep the recovery token private. |
| `410` | `account_recovery_expired` | The account recovery window ended. | Sign in to create a new account. |
| `422` | `validation_failed` | A query value, field, filter, cursor, header, or time range is not valid. | Correct the named value. Then send the request again. |
| `422` | `invite_invalid` | The invitation asks for the `owner` role, or you cannot accept it: it is expired, revoked, or not sent to your account. | Invite with the `admin` or `member` role. To accept, ask an owner or admin for a new invitation. |
| `422` | `organization_limit_exceeded` | The account has its maximum number of organizations. | Remove an organization or contact support. |
| `423` | `organization_paused` | The organization is paused because its paid subscription is not active. | Resume an active paid subscription. |
| `429` | `rate_limited` | The caller sent too many requests. Adds `retry_after_seconds`. | Wait for `retry_after_seconds`. Then retry with backoff. |
| `429` | `usage_limit_exceeded` | Ingestion reached the account's allowance for the billing period. Adds `limit` and `reset_at`. | Stop ingestion until `reset_at`. To raise the allowance, follow `next`. |
| `429` | `artifact_storage_limit_exceeded` | A release artifact or debug file upload reached a storage limit. Adds `limit`. | Wait before you upload again. If the limit stays, contact support. |
| `429` | `invitation_limit_exceeded` | The organization or the inviter reached its daily invitation allowance. Adds `limit` and `reset_at`. | Wait for `reset_at`. For `invitations_per_day`, follow `next` to raise the allowance. |
| `500` | `storage_error`, `json_error`, or `internal_error` | The server did not complete the request. | Use the [retry rules](#retry-rules). If the failure continues, [report a problem](https://docs.logbrew.co/guides/report-a-problem.md). |
| `503` | `service_unavailable` | The API cannot accept the request at this time. | Wait. Then send the request again. |
| `503` | `artifact_storage_unavailable` | Release artifact and debug file uploads are temporarily unavailable. | Wait before you upload again. Do not start parallel uploads. |
| `503` | `billing_unavailable` | Billing checkout or plan management is temporarily unavailable. | Wait. Then try the billing action again. |

An organization has no member limit and no project limit. The API does not
return `member_limit_exceeded`.

An unknown ID and an ID that you cannot access can return the same response.
Do not use error text to find which account owns an ID. An unknown API path
returns `404` with `not_found`.

### Limit fields

| `code` | `limit` values | Other fields |
| - | - | - |
| `usage_limit_exceeded` | `issue_events`, `log_bytes`, `metric_bytes`, or `trace_spans` | `reset_at`: the end of the billing period (RFC3339). |
| `invitation_limit_exceeded` | `invitations_per_day` (per organization) or `invitations_per_inviter_per_day` (per inviting account, 20 for each UTC day) | `reset_at`: the start of the next UTC day (RFC3339). |
| `artifact_storage_limit_exceeded` | A storage boundary name, such as `artifact_completed_project_bytes` | None. |
| `rate_limited` | None | `retry_after_seconds`: whole seconds to wait, at least `1`. |

Read the current allowance and use from the
[account API](https://docs.logbrew.co/reference/account-api.md#account-usage).

## Retry rules

Use the code and the operation to decide on a retry. The status alone is not
sufficient.

| Response | Retry rule |
| - | - |
| `validation_failed`, `invalid_json`, `invalid_path` (`400`), `invalid_multipart` (`400` or `413`), or `invalid_websocket_upgrade` | Correct the named request value first. Do not send the same request again. |
| `unauthorized` or `ingest_key_invalid` | Replace or refresh the correct credential first. |
| `forbidden`, `role_forbidden`, or `not_found` | Do not retry with other IDs. Read an owned list again, or get access from the owner. |
| `method_not_allowed` | Use the method in `next`. Do not send the rejected method again. |
| `idempotency_conflict` | Retry the original request unchanged, or use a new key for new work. |
| `rate_limited` | Wait for `retry_after_seconds`. Then use exponential backoff with jitter. |
| `usage_limit_exceeded` or `invitation_limit_exceeded` | Wait for `reset_at`. To raise the allowance, follow `next`. |
| `artifact_storage_limit_exceeded` | Wait before you upload again. If the limit stays, contact support. |
| `subscription_required`, `organization_paused`, or `organization_limit_exceeded` | Follow `next`. A retry without a plan or organization change fails again. |
| `request_timeout`, `service_unavailable`, `artifact_storage_unavailable`, or `billing_unavailable` | Wait. Then send a read again with the same scope. For a write, use the [write rules](#writes). |
| `storage_error`, `json_error`, `internal_error`, or another `5xx` | Wait. Then send a read again. For a write, use the [write rules](#writes). If the failure continues, [report a problem](https://docs.logbrew.co/guides/report-a-problem.md). |

* Do not start parallel retries for one failed request.
* For `rate_limited`, the response also has the `Retry-After` and
  `X-RateLimit-After` headers. Both contain the same number of seconds as
  `retry_after_seconds`.
* An account can run at most 8 telemetry and log reads at the same time. A
  further read waits up to 5 seconds for a free slot. Then it returns `429`
  with `rate_limited` and the `Retry-After` header. Wait that long, then send
  the read again.
* A timeout does not prove that the result is empty.

A rate limit controls request frequency. A usage limit controls the account
allowance for a billing period. Both use `429`. Keep their fields separate.
During either limit, show that collection or a read is delayed. Do not show
old data as the result of a new read.

### Writes

A timeout, a `5xx` response, or a network failure does not prove that a write
failed. Before you send a write again:

1. If the route supports an idempotency key, send the same key and the same
   body again. Use a new key only for new work.
2. If the route has no idempotency key, read the resource first. Send the
   write again only if the change is not present.
3. If you cannot find the result, stop automatic retries and tell the user.

These routes accept a retry key:

| Route | Retry key |
| - | - |
| `POST /api/projects` | Optional `Idempotency-Key` header. |
| `POST /api/projects/{project_id}/ingest-keys` | Optional `Idempotency-Key` header. |
| `POST /api/support/tickets` | Optional `Idempotency-Key` header. |
| `POST /api/support/tickets/{ticket_id}/context` | Required `Idempotency-Key` header. |
| `PUT /api/telemetry/deployments/{deployment_id}` | The `deployment_id` in the path. |

An `Idempotency-Key` value has 1 to 128 visible ASCII characters. Other values
return `422` with `validation_failed`.

`idempotency_conflict` means that the key belongs to a different request. Do
not change the body of a retry that uses the original key.

## Request shape errors

`invalid_json` means that the server cannot accept the body as the route's JSON
shape. Examine the content type, body size, JSON syntax, required fields, and
field types. The HTTP status shows which part failed:

| HTTP | Cause |
| - | - |
| `400` | The body is not valid JSON. |
| `413` | The body is too large. |
| `415` | The `Content-Type` header is not `application/json`. |
| `422` | The JSON is valid, but a field is missing or has the wrong type. |

`validation_failed` with the error `invalid query parameters` means that the
server cannot read the query string. Examine the parameter names and value
types. Do not send unknown query parameters. The
[query filters reference](https://docs.logbrew.co/reference/telemetry-api-filters.md) lists the
parameters for each route.

`invalid_path` with status `400` means that a path value, such as a project ID,
has the wrong format. Do not move a path value into a query parameter.

A `500` response with `invalid_path` or `invalid_multipart` does not prove that
the request was wrong. Use the [retry rules](#retry-rules).

## Authentication and access errors

* `unauthorized` means that account authentication is missing, invalid, or
  expired. Send `Authorization: Bearer <token>`, or sign in again. Some
  routes return `next_action.code` `authorize_request` with a route-specific
  `next`, such as a live feed connection without a valid ticket.
* `ingest_key_invalid` applies to telemetry ingestion only. Configure a
  current key for the exact project.
* `forbidden` means that the account cannot do the action. Do not retry with
  other resource IDs.
* `not_found` means that the resource is not available to the account.

Do not use an ingest key in place of an account bearer. Do not use an account
bearer in place of an ingest key.

## Keep error details safe

* An `account_recovery_available` response contains a short-lived
  `recovery_token`. Keep it in protected client state. Do not put it in logs,
  URLs, screenshots, support reports, or agent prompts.
* The `500` codes always use the message `Internal error`. The response does
  not name the component that failed. Do not guess the cause.
* Do not add credentials, private diagnostics, or customer data to an error
  that you show.
* An API response does not give permission for a purchase, a deletion, or
  another account change. Get the user's approval before those actions.

## Examples

These examples show the envelope shape. The `error` and `next` text can be
different on each route.

### Validation failure

```json theme={null}
{
  "error": "issue status must be unresolved, resolved, or archived",
  "code": "validation_failed",
  "next": "use status=unresolved, status=resolved, or status=archived",
  "next_action": {
    "code": "fix_request",
    "target": "request"
  }
}
```

### Invalid query parameters

```json theme={null}
{
  "error": "invalid query parameters",
  "code": "validation_failed",
  "next": "check query parameter names and value types, then retry",
  "next_action": {
    "code": "fix_request",
    "target": "request"
  }
}
```

### Invalid JSON

```json theme={null}
{
  "error": "invalid JSON request body",
  "code": "invalid_json",
  "next": "send Content-Type: application/json with a body matching this endpoint",
  "next_action": {
    "code": "send_valid_json",
    "target": "request"
  }
}
```

### Invalid path value

```json theme={null}
{
  "error": "invalid URL path parameters",
  "code": "invalid_path",
  "next": "check path resource IDs and value types, then retry",
  "next_action": {
    "code": "fix_request",
    "target": "request"
  }
}
```

### Invalid multipart upload

```json theme={null}
{
  "error": "invalid multipart form-data request",
  "code": "invalid_multipart",
  "next": "send multipart/form-data with a valid boundary and expected parts",
  "next_action": {
    "code": "fix_request",
    "target": "request"
  }
}
```

### Invalid WebSocket upgrade

```json theme={null}
{
  "error": "invalid WebSocket upgrade request",
  "code": "invalid_websocket_upgrade",
  "next": "connect with GET /api/feed/live?ticket=<ticket> using WebSocket upgrade headers",
  "next_action": {
    "code": "connect_live_feed",
    "target": "live_feed"
  }
}
```

### Authentication failure

```json theme={null}
{
  "error": "Invalid or expired token",
  "code": "unauthorized",
  "next": "send Authorization: Bearer <token>, include the logbrew_session cookie, or sign in again",
  "next_action": {
    "code": "sign_in",
    "target": "auth"
  }
}
```

### Invalid ingest key

This response applies to telemetry ingestion, not to account reads. The key
must belong to the project in the request.

```json theme={null}
{
  "error": "Invalid ingest key",
  "code": "ingest_key_invalid",
  "next": "create a project-scoped ingest key, then retry ingestion with that key",
  "next_action": {
    "code": "configure_ingest_key",
    "target": "project_ingest_key"
  }
}
```

### Resource not found

```json theme={null}
{
  "error": "issue not found",
  "code": "not_found",
  "next": "check the resource id or filters and retry",
  "next_action": {
    "code": "check_resource",
    "target": "resource"
  }
}
```

### Access denied

```json theme={null}
{
  "error": "Insufficient permissions",
  "code": "forbidden",
  "next": "use an account with access to this resource",
  "next_action": {
    "code": "request_access",
    "target": "auth"
  }
}
```

### Unsupported method

```json theme={null}
{
  "error": "Method not allowed",
  "code": "method_not_allowed",
  "next": "send GET /api/account/usage with Authorization or the logbrew_session cookie",
  "next_action": {
    "code": "use_supported_method",
    "target": "api_method"
  }
}
```

### Request timeout

```json theme={null}
{
  "error": "Request timed out",
  "code": "request_timeout",
  "next": "retry read-only requests later or narrow the request scope. Before repeating a write, check whether it succeeded and follow this endpoint's idempotency guidance",
  "next_action": {
    "code": "retry_or_narrow_scope",
    "target": "request"
  }
}
```

### Idempotency conflict

```json theme={null}
{
  "error": "Idempotency key was already used",
  "code": "idempotency_conflict",
  "next": "retry the original support request or use a new Idempotency-Key",
  "next_action": {
    "code": "use_new_idempotency_key",
    "target": "request"
  }
}
```

### Rate limit

```json theme={null}
{
  "error": "Rate limit exceeded",
  "code": "rate_limited",
  "next": "wait for retry_after_seconds, then retry with exponential backoff and jitter",
  "next_action": {
    "code": "retry_with_backoff",
    "target": "request"
  },
  "retry_after_seconds": 1
}
```

### Usage limit

The `next` text and `next_action` depend on whether paid checkout is open.
Paid checkout is not open yet, so the response looks like this example. When
checkout opens, `next_action.code` is `wait_or_upgrade` and the target is
`billing`.

```json theme={null}
{
  "error": "Usage limit exceeded",
  "code": "usage_limit_exceeded",
  "next": "wait until reset_at or contact LogBrew support to raise your limit before retrying ingestion",
  "next_action": {
    "code": "wait_or_contact_support",
    "target": "support"
  },
  "limit": "log_bytes",
  "reset_at": "2026-11-01T00:00:00+00:00"
}
```

### Artifact storage limit

```json theme={null}
{
  "error": "Release artifact storage limit exceeded",
  "code": "artifact_storage_limit_exceeded",
  "next": "wait before retrying the upload, or contact LogBrew support if the limit persists",
  "next_action": {
    "code": "wait_or_contact_support",
    "target": "support"
  },
  "limit": "artifact_completed_project_bytes"
}
```

### Account recovery available

This response adds `deleted_at` and a short-lived `recovery_token`. Keep the
token in protected client state.

```json theme={null}
{
  "error": "Account recovery available",
  "code": "account_recovery_available",
  "next": "restore account with POST /api/auth/restore",
  "next_action": {
    "code": "restore_account",
    "target": "account_recovery"
  },
  "deleted_at": "2026-09-04T09:00:00Z",
  "recovery_token": "<recovery token>"
}
```

### Account recovery expired

```json theme={null}
{
  "error": "Account recovery window expired",
  "code": "account_recovery_expired",
  "next": "create a new account after deletion completes",
  "next_action": {
    "code": "create_account",
    "target": "auth"
  }
}
```

### Organization paused

```json theme={null}
{
  "error": "Organization paused",
  "code": "organization_paused",
  "next": "resume an active paid subscription before using this organization",
  "next_action": {
    "code": "resume_subscription",
    "target": "billing"
  }
}
```

### Server error

`storage_error`, `json_error`, and `internal_error` use the same `error`
message. The `code`, `next`, and `next_action` values are different.

```json theme={null}
{
  "error": "Internal error",
  "code": "internal_error",
  "next": "retry read-only requests later. Before repeating a write, check whether it succeeded and follow this endpoint's idempotency guidance. Contact LogBrew support if the problem persists",
  "next_action": {
    "code": "retry_or_contact_support",
    "target": "support"
  }
}
```

| `code` | `next_action.code` | `next_action.target` |
| - | - | - |
| `storage_error` | `retry_or_check_storage` | `backend_status` |
| `json_error` | `send_valid_json` | `request` |
| `internal_error` | `retry_or_contact_support` | `support` |

For endpoints, authentication, and filters, read the
[Telemetry API](https://docs.logbrew.co/reference/telemetry-api.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.