> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# Errors

**Published**: 2026-11-30
**Category**: Getting Started

> Every Lynkow API error has the same JSON body. This page shows it, lists the common status codes, and maps them to the SDK's `LynkowError`. Previous: [Authentication and Keys](/sdk/getting-started/authentication-and-keys) | Next: [Pagination](/sdk/getting-started/pagination)

> **Reference** - This guide is a tutorial. For exhaustive, always-current signatures and field lists, see the auto-generated reference:
> 
> - API: [Storefront API Overview](/storefront-api/overview), where each endpoint lists the codes it returns
> - SDK: [SDK Types](/sdk/types)

## Prerequisites

- A first request done ([Quick Start](/sdk/getting-started/quick-start))

## The error body

A request with a Site ID that is not a UUID:

```bash
curl -i "https://api.lynkow.com/storefront/not-a-uuid/contents"
```

returns 400 with this body:

```json
{
  "errors": [
    {
      "message": "Site ID must be a valid UUID",
      "code": "TENANT_SITE_ID_INVALID"
    }
  ],
  "requestId": "4f1c2a9e-8b7d-4e3f-a5c6-1d2e3f4a5b6c"
}
```

- `errors`: one entry or more. Each has a `message`, readable English for logs. Most have a `code`. A validation error adds a `field`.
- `code`: the stable reason. Branch on it, never on `message`, which can change.
- `requestId`: the ID of this request, on most error bodies. Every response carries the same ID in the `X-Request-Id` header. Quote it when you contact support.

A validation error returns 422 with one entry per invalid field:

```json
{
  "errors": [
    { "message": "The email field must be a valid email address", "field": "email", "code": "VALIDATION_EMAIL" }
  ],
  "requestId": "..."
}
```

Show each `message` next to its `field`. The `VALIDATION_...` code names the rule that failed: use `field` to place the message, and a 422 status to know the input was refused.

An unexpected server error returns 500 with the message `Internal server error`, without details.

## Status codes

| Status | Common codes | What to do |
| --- | --- | --- |
| 400 | `TENANT_SITE_ID_INVALID` | Fix the request: here, the Site ID in the URL |
| 401 | `AUTH_TOKEN_REQUIRED`, `AUTH_TOKEN_INVALID`, `STOREFRONT_KEY_REQUIRED`, `CUSTOMER_AUTH_REQUIRED` | Send a valid credential ([Authentication and Keys](/sdk/getting-started/authentication-and-keys)) |
| 402 |  | The site's plan or subscription does not allow the operation |
| 403 | `AUTHZ_INSUFFICIENT_PERMISSIONS`, `DOMAIN_MISMATCH` | The API token lacks a permission, or a browser call came from a domain the site does not allow |
| 404 | `TENANT_SITE_NOT_FOUND`, `RESOURCE_NOT_FOUND` | The site or the resource does not exist, or is not published |
| 409 | `RESOURCE_CONFLICT` | The resource changed or already exists: reload it and try again |
| 422 | `VALIDATION_...`, or a business code | Fix the input shown by `field`, or handle the code |
| 429 | `RATE_LIMIT_EXCEEDED` | Wait, then retry with a backoff ([Rate Limits](/sdk/getting-started/rate-limits)) |
| 500 | `INTERNAL_SERVER_ERROR` | Retry later. Send the `requestId` to support if it persists |
| 503 | `INTERNAL_SERVICE_UNAVAILABLE` | Retry later |


Some endpoints return their own codes, such as `TERMS_NOT_ACCEPTED` on checkout. The API reference lists them on each endpoint.

## With the SDK

Every SDK method rejects with a `LynkowError`. Use `isLynkowError()` to narrow it:

```tsx
import { isLynkowError } from 'lynkow'
import { notFound } from 'next/navigation'
import { lynkow } from '@/lib/lynkow'

export default async function ArticlePage({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params
  try {
    const article = await lynkow.contents.getBySlug(slug)
    return <h1>{article.title}</h1>
  } catch (error) {
    if (isLynkowError(error) && error.code === 'NOT_FOUND') notFound()
    throw error
  }
}
```

A `LynkowError` carries:

- `status`: the HTTP status, `0` when no response arrived.
- `code`: the category, from the status: `BAD_REQUEST` (400), `UNAUTHORIZED` (401), `PAYMENT_REQUIRED` (402), `FORBIDDEN` (403), `NOT_FOUND` (404), `CONFLICT` (409), `VALIDATION_ERROR` (422), `TOO_MANY_REQUESTS` (429), `SERVICE_UNAVAILABLE` (503), `INTERNAL_ERROR` (500 and any other status), `NETWORK_ERROR` (no response).
- `apiCode`: the API's `code`, from the first entry of `errors` that has one.
- `details`: the `errors` entries, with their `message`, `field` and `code`.

Branch on `code` for generic handling, and on `apiCode` when one status covers several cases. [Error Handling & Resilience](/sdk/advanced/error-handling) covers retries, timeouts and the commerce codes.

## Reference

- API: [Storefront API Overview](/storefront-api/overview), [Admin API Overview](/admin-api/api-overview)
- SDK: [SDK Reference](/sdk), [SDK Types](/sdk/types)

## Next Steps

- [Pagination](/sdk/getting-started/pagination) - page through lists with `page`, `limit` and `meta`
- [Rate Limits](/sdk/getting-started/rate-limits) - the limits, the headers and how to retry a 429
- [Error Handling & Resilience](/sdk/advanced/error-handling) - retries, timeouts and error pages in Next.js