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

# API reference

> Programmatically manage your Crevio storefront

The Crevio API lets you manage products, pricing, checkouts, orders, customers, invoices, subscriptions, and more. All endpoints return JSON with snake\_case keys following Stripe conventions.

## Base URL

```
https://api.crevio.co/v1
```

For local development:

```
https://api.crevio.dev/v1
```

## Authentication

All API requests require a Bearer token in the `Authorization` header.

```bash theme={null}
curl https://api.crevio.co/v1/products \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Generate API tokens from **Settings > Developer > API tokens** in your dashboard.

<Warning>
  Keep your API tokens secure. Do not expose them in client-side code or public repositories.
</Warning>

## Object types

Every API resource includes an `object` field that identifies the resource type:

```json theme={null}
{
  "id": "prod_abc123",
  "object": "product",
  "name": "My Course",
  "slug": "my-course"
}
```

All IDs are prefixed strings that encode the resource type (e.g., `prod_abc123`, `cus_ghi789`).

## Slug lookup

Products, blog posts, experiences, and legal pages can be retrieved by slug instead of ID:

```bash theme={null}
curl https://api.crevio.co/v1/products/my-course \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

This works anywhere an ID is accepted for these resources.

## List responses

List endpoints return a Stripe-style envelope:

```json theme={null}
{
  "object": "list",
  "data": [
    { "id": "prod_abc123", "object": "product", "name": "My Course" },
    { "id": "prod_def456", "object": "product", "name": "Templates Pack" }
  ],
  "has_more": true,
  "url": "/v1/products"
}
```

Use `starting_after` and `limit` query parameters to paginate. Pass the `id` of the last item to fetch the next page:

```bash theme={null}
curl "https://api.crevio.co/v1/products?starting_after=prod_abc123&limit=20" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

Default limit is 20, maximum is 100.

## Expandable fields

Some endpoints support an `expand` query parameter to include related data inline. Pass a comma-separated list of fields:

```bash theme={null}
curl "https://api.crevio.co/v1/orders?expand=line_items,customer"
```

Without expand, related resources appear as collapsed IDs:

```json theme={null}
{ "customer": "cust_abc123" }
```

With expand, they become full objects:

```json theme={null}
{
  "customer": {
    "id": "cust_abc123",
    "object": "customer",
    "email": "jane@example.com",
    "name": "Jane Doe"
  }
}
```

## Delete responses

Delete endpoints return a Stripe-style confirmation:

```json theme={null}
{
  "id": "disc_abc123",
  "object": "discount",
  "deleted": true
}
```

## Errors

All errors follow this format:

```json theme={null}
{
  "error": {
    "type": "validation_error",
    "code": "validation_failed",
    "message": "Email can't be blank",
    "errors": {
      "email": ["can't be blank"]
    }
  }
}
```

| Status | Type                    | Code                      | Description                     |
| ------ | ----------------------- | ------------------------- | ------------------------------- |
| 400    | `invalid_request_error` | `parameter_missing`       | A required parameter is missing |
| 401    | `invalid_request_error` | `authentication_required` | Invalid or missing API token    |
| 404    | `invalid_request_error` | `resource_missing`        | Resource not found              |
| 422    | `validation_error`      | `validation_failed`       | Request failed validation       |
| 500    | `api_error`             | —                         | Internal server error           |

## SDKs

### TypeScript

Install the official SDK:

```bash theme={null}
npm install @crevio/sdk
```

```typescript theme={null}
import { Crevio } from "@crevio/sdk";

const crevio = new Crevio({
  apiKeyAuth: "YOUR_API_TOKEN",
});

const products = await crevio.products.list();
```

<Card title="Full endpoint reference" icon="code" href="/developer/api-reference/introduction">
  Browse all available endpoints below.
</Card>
