> This page is for version Preview.
> For other versions, use one of these documentation indexes:
> - Current (default): https://docs.paid.ai/current/llms.txt
> - Preview: https://docs.paid.ai/preview/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.paid.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.paid.ai/_mcp/server.

# Migrate from the legacy API

> Move an integration from the legacy api.agentpaid.io API to api.paid.ai/v1.

The legacy `api.agentpaid.io` API keeps working while you move, and won't change in ways that break your integration. New resources and dated versions ship on `https://api.paid.ai/v1`. This guide lists what changes when you move an integration across.

## Prerequisites

* Have your [API key](https://app.paid.ai/settings/api-keys) ready. The same key works on both hosts.
* If your network allowlists outbound domains, add `api.paid.ai`.

## Change the base URL

Replace the legacy base URL with the new one. The `/api/` segment is gone, and the path version is `/v1`.

| Legacy                                | New                          |
| ------------------------------------- | ---------------------------- |
| `https://api.agentpaid.io/api/v2/...` | `https://api.paid.ai/v1/...` |

Resources move to `/v1` as they are released. Until a resource appears in the [API reference](../../api-reference), keep calling it on the legacy host. The two hosts share the same account and data, so you can move one resource at a time.

## Pin a version

Requests to `/v1` use your account's pinned [dated version](./versioning). Send `Paid-Version` on every request to make your integration independent of the pin:

```bash
curl https://api.paid.ai/v1/api-version \
  -H "Authorization: Bearer $PAID_API_KEY" \
  -H "Paid-Version: 2026-11-01"
```

## Update error handling

Legacy errors are a flat object. On `/v1`, every error is a standard object under `error`, with a stable `type` and `code`:

**`Legacy`**

```json title="Legacy"
{
  "error": "Validation failed",
  "code": "VALIDATION_ERROR",
  "details": "version: Required"
}
```

**`v1`**

```json title="v1"
{
  "error": {
    "type": "invalid_request_error",
    "code": "validation_error",
    "message": "version: Required",
    "requestId": "req_3f1c0b9e-2a7d-4c5e-9f61-0d8e4b2a7c13",
    "docUrl": "https://docs.paid.ai/preview/developers/api/errors#validation_error"
  }
}
```

* Branch on `error.type` for the category and `error.code` for the specific case. Codes are lowercase.
* `error.param` names the field or header at fault, when there is one.
* `error.requestId` matches the `Request-Id` response header. Include it when contacting support.

## Use betas instead of experimental resources

Legacy resources with `-experimental` in their names have no `-experimental` twin on `/v1`. Early access uses the `Paid-Beta` header instead, so the resource keeps its final name. See [Use a beta](./versioning#use-a-beta).

## Retry safely

`POST` and `PATCH` requests on `/v1` accept an `Idempotency-Key` header: 1 to 255 printable ASCII characters, with no spaces. Retrying with the same key and body within 24 hours returns the original response, marked with `Idempotent-Replayed: true`, instead of repeating the operation.

## Move customers

The customers resource on `/v1` is in the `customers=v1` private beta. Send `Paid-Beta: customers=v1` on every customer request.

* **One path for both IDs.** `/v1/customers/{customer}` takes the `cus_` ID, your `externalId`, or an alias, so the `/external/{externalId}` routes have no `/v1` equivalent.
* **Update is `PATCH`.** It changes only the fields you send. Send `null` to clear a field.
* **Archive, don't delete.** `POST /v1/customers/{customer}/archive` replaces `DELETE`. It fails with `customer_has_active_orders` while the customer has an open order.
* **Cursor pagination.** Lists return `{ object: "list", data, hasMore, nextCursor }`. Send `nextCursor` back as `cursor` instead of an `offset`.

| Legacy field                                    | `/v1` field                                                     |
| ----------------------------------------------- | --------------------------------------------------------------- |
| `id` (`""` when missing)                        | `id`, always a `cus_` ID                                        |
| `email`, `phone`, `website` (`""` when not set) | The same names, `null` when not set                             |
| `billingAddress`                                | `address`                                                       |
| `billingAddress.zipCode`                        | `address.postalCode`                                            |
| `defaultCurrency` (`USD`)                       | `currency` (`usd`), validated against your account's currencies |
| `vatNumber`                                     | `taxIds: [{ type, value }]`                                     |
| `creationState` and `status`                    | `status` (`draft` or `active`)                                  |
| `churnDate`                                     | `churnedAt`                                                     |
| `connections.stripe.customerId`                 | Not returned                                                    |
| (none)                                          | `object`, `livemode`, `archivedAt`                              |

## Related

* [Versioning](./versioning)
* [Changelog](./changelog)