> ## 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 overview

> Integrate Crevio into your own applications with the REST API.

The Crevio API lets you programmatically manage your account's products, orders, customers, checkouts, and more. Use it to build custom storefronts, sync data with external systems, or automate workflows.

## What you can do with the API

* **Products** — Create, update, delete, list, and retrieve products.
* **Price variants** — Create, update, archive, list, and retrieve price variants for products.
* **Orders** — List and retrieve order details with expandable line items and customers.
* **Order items** — Retrieve individual order line items.
* **Refunds** — Create, list, and retrieve refund details for orders. Supports full and partial refunds.
* **Customers** — List, create, update, and retrieve customer records.
* **Subscriptions** — List and retrieve subscriptions. Cancel (`POST /subscriptions/{id}/cancel`), pause (`POST /subscriptions/{id}/pause`), or resume (`POST /subscriptions/{id}/resume`) active subscriptions.
* **Invoices** — Create, list, retrieve, and void (`POST /invoices/{id}/void`) invoices. Pay invoices by creating a checkout with the `invoice` parameter.
* **Checkouts** — Create checkout sessions, retrieve, and update checkout details. Create checkouts with line items or for paying an invoice.
* **Checkout links** — Full CRUD: create, update, delete, list, and retrieve shareable checkout links.
* **Experiences** — List and retrieve experiences and their content.
* **Discounts** — Create, update, delete, list, and retrieve discount codes.
* **Blog posts** — List and retrieve blog posts. Filter by status.
* **Legal pages** — List, retrieve, and update legal pages (Terms of Service, Privacy Policy, Refund Policy).
* **Reviews** — Full CRUD: create, update, delete, list, and retrieve product reviews. Reorder reviews via `POST /reviews/{id}/position`.
* **Files** — Upload, list, retrieve, and delete files. Supports both direct uploads and external URLs.
* **Emails** — Send transactional emails to customers.
* **Webhook endpoints** — Create, update, delete, list, and retrieve webhook subscriptions.
* **Webhook events** — List and retrieve webhook event delivery history.
* **x402 Configuration** — Get and update x402 crypto payment settings.

## Authentication

All API requests are authenticated using **Bearer tokens**. Include your API token in the `Authorization` header of every request:

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

Requests without a valid token receive a `401 Unauthorized` response.

## Base URL

All API endpoints use the following base URL:

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

## Creating API tokens

<Steps>
  <Step title="Go to Developer settings">
    In your dashboard, navigate to **Settings** > **Developer**.
  </Step>

  <Step title="Create a new token">
    Click **New API token** and give it a descriptive name (e.g., "My integration" or "Storefront sync").
  </Step>

  <Step title="Copy the token">
    Your token is displayed once. Copy it and store it securely. You will not be able to view it again.
  </Step>
</Steps>

<Warning>
  Treat API tokens like passwords. Do not commit them to version control, share them in public channels, or include them in client-side code. Store them in environment variables or a secrets manager.
</Warning>

API tokens are scoped to your account. Any request made with a token acts on behalf of the user who created it, within the context of that account.

### Token management

* Tokens display their **last used** timestamp so you can identify stale tokens.
* You can delete a token at any time to revoke access immediately.
* Each account can have multiple active tokens.

## Rate limiting

The API enforces rate limits to ensure fair usage and platform stability. If you exceed the rate limit, the API responds with a `429 Too Many Requests` status code. Wait for the period indicated in the response headers before retrying.

<Tip>
  Implement exponential backoff in your API client to handle rate limits gracefully. The `@crevio/sdk` handles this automatically.
</Tip>

## Conventions

### snake\_case keys

All API responses use snake\_case keys, following Stripe conventions:

```json theme={null}
{
  "id": "prod_abc123",
  "object": "product",
  "name": "My Course",
  "created_at": "2025-01-15T10:30:00Z",
  "price_variants": [...]
}
```

### Slug lookup

Products, blog posts, experiences, and legal pages can be retrieved by slug instead of ID. Any endpoint that accepts an ID for these resources also accepts a slug:

```bash theme={null}
# By ID
curl https://api.crevio.co/v1/products/prod_abc123

# By slug
curl https://api.crevio.co/v1/products/my-course
```

### IDs

All resource IDs are prefixed strings that encode the resource type:

| Resource         | Prefix   | Example        |
| ---------------- | -------- | -------------- |
| Account          | `acct_`  | `acct_abc123`  |
| Product          | `prod_`  | `prod_abc123`  |
| Price Variant    | `price_` | `price_abc123` |
| Order            | `ord_`   | `ord_abc123`   |
| Order Item       | `ordi_`  | `ordi_abc123`  |
| Charge           | `ch_`    | `ch_abc123`    |
| Customer         | `cus_`   | `cus_abc123`   |
| Checkout         | `co_`    | `co_abc123`    |
| Checkout Link    | `cl_`    | `cl_abc123`    |
| Invoice          | `inv_`   | `inv_abc123`   |
| Subscription     | `sub_`   | `sub_abc123`   |
| Discount         | `disc_`  | `disc_abc123`  |
| Experience       | `exp_`   | `exp_abc123`   |
| Blog Post        | `post_`  | `post_abc123`  |
| Review           | `rev_`   | `rev_abc123`   |
| File             | `file_`  | `file_abc123`  |
| Webhook Endpoint | `wh_`    | `wh_abc123`    |
| Webhook Event    | `whev_`  | `whev_abc123`  |

### Object type discriminator

Every resource includes an `object` field identifying its type:

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

## List responses

List endpoints return a Stripe-style envelope with cursor-based pagination:

```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"
}
```

### Pagination parameters

| Parameter        | Description                                               |
| ---------------- | --------------------------------------------------------- |
| `limit`          | Number of items per page (1–100, default 20)              |
| `starting_after` | Cursor — the `id` of the last item from the previous page |

To fetch the next page, pass the last item's `id` as `starting_after`:

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

# Next page
curl "https://api.crevio.co/v1/products?limit=10&starting_after=prod_def456" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

When `has_more` is `false`, you've reached the last page.

## Expandable fields

Many endpoints support an `expand` query parameter to include related resources inline. Without expansion, related resources appear as collapsed IDs:

```json theme={null}
{
  "id": "ord_abc123",
  "object": "order",
  "customer": "cust_xyz789"
}
```

With `?expand=customer`:

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

Available expand fields vary by endpoint. See the API reference for details.

## Delete responses

Delete endpoints return a Stripe-style confirmation:

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

## Error format

When a request fails, the API returns a JSON error response:

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

| Field     | Description                                                                                      |
| --------- | ------------------------------------------------------------------------------------------------ |
| `type`    | Error category (e.g., `invalid_request_error`, `validation_error`, `api_error`)                  |
| `code`    | Machine-readable code (e.g., `resource_missing`, `authentication_required`, `validation_failed`) |
| `message` | A human-readable description of what went wrong                                                  |
| `param`   | The parameter that caused the error (included for parameter errors)                              |
| `errors`  | Field-level validation errors (included for validation errors)                                   |

### Common error types

| Type                    | HTTP status         | Description                                                  |
| ----------------------- | ------------------- | ------------------------------------------------------------ |
| `invalid_request_error` | `400`, `401`, `404` | The request is invalid (missing params, bad auth, not found) |
| `validation_error`      | `422`               | The request body contains invalid data                       |
| `api_error`             | `500`               | An unexpected server error occurred                          |

## Full API reference

For detailed documentation of every endpoint, request parameters, and response schemas, see the [API Reference](/developer/api-reference/introduction) tab.

## Available SDKs

### @crevio/sdk (TypeScript)

The official TypeScript SDK provides a type-safe client for the Crevio API with Zod validation, automatic retries, and support for multiple runtimes (Node.js, browsers, Cloudflare Workers, and Deno).

Install it with your preferred package manager:

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

  ```bash bun theme={null}
  bun add @crevio/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @crevio/sdk
  ```

  ```bash yarn theme={null}
  yarn add @crevio/sdk
  ```
</CodeGroup>

Basic usage:

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

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

// List products
const products = await crevio.products.list();

// Get a specific product
const product = await crevio.products.get({ id: "prod_abc123" });

// Create a checkout
const checkout = await crevio.checkouts.create({
  email: "customer@example.com",
  line_items: [
    { price_variant: "pv_xyz789", quantity: 1 },
  ],
});
```

The SDK handles authentication, pagination, error handling, and retries automatically.
