---
title: Error Handling
description: Status codes, error bodies and the WWW-Authenticate header in the Hostino API and MCP
sidebar:
  order: 12
  badge:
    text: Alpha
    variant: success
---

Errors are returned with an HTTP status code and a short JSON body:

```json
{ "error": "insufficient_scope", "required_scope": "domains:read" }
```

The `error` value is stable and safe to branch on in code.

## API and MCP errors

| Code | `error` | Meaning | Fix |
|---|---|---|---|
| `401` | `missing_token` | No `Authorization: Bearer` header | Get a token and send it in the header |
| `401` | `inactive_token` | Token expired, revoked or unknown | Use your `refresh_token` or sign in again |
| `401` | `invalid_audience` | Token was issued for another resource | Request tokens with `resource=https://mcp.hostino.ai` |
| `403` | `insufficient_scope` | Token lacks the required scope | Re-authenticate and approve the missing permission |
| `403` | `session_owner_mismatch` | (MCP) The MCP session belongs to another user | Start a new session (`initialize`) |
| `404` | — | (MCP) `Mcp-Session-Id` expired or unknown | The client should `initialize` again |
| `429` | — | [Rate limit](/en/api/rate-limits/) exceeded | Retry after `RateLimit-Reset` seconds |
| `502` | `backend_error` / `backend_unreachable` | Temporary internal error | Retry with backoff |
| `503` | `auth_unavailable` | Token validation temporarily unavailable | Retry with backoff |

## Request id

Every API response carries an `X-Request-Id` header, and every error body repeats it as `request_id`:

```json
{ "error": "invalid_status", "allowed": ["Unpaid", "Paid"], "request_id": "b19e6a38-dda8-4df5-bbad-f4c75bc9c14e" }
```

Include the `request_id` when reporting a problem to support so the request can be found quickly.

## WWW-Authenticate header

Every `401` and `403` carries the standard RFC 6750 header so clients know what to do:

```http
HTTP/2 401
WWW-Authenticate: Bearer resource_metadata="https://mcp.hostino.ai/.well-known/oauth-protected-resource", error="invalid_token"
```

MCP clients read `resource_metadata` to discover the authorization server and start the sign-in flow automatically.

## OAuth errors

Authorization server errors follow the OAuth standard:

| `error` | Meaning |
|---|---|
| `invalid_client` | Unknown `client_id`; register again (in Claude Code: remove and re-add the server) |
| `invalid_grant` | Code / refresh token invalid, expired or already used |
| `invalid_target` | `resource` not allowed; use `https://mcp.hostino.ai` |
| `invalid_request` | A required parameter (e.g. PKCE) is missing |
| `access_denied` | The user clicked "Deny" on the consent page |
| `authorization_pending` | (Device Flow) the user hasn't approved yet; keep polling |
| `expired_token` | (Device Flow) the device code expired; start over |
