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

# Send catalog, customer and document data

> Send catalog items, customers, quotes, orders, invoices and credits to Elastly from your own system, record by record or as a bulk file, and track each import.

When your system is connected through an integration that receives data by push, you send its records to Elastly through the API: catalog items with cost and stock, customers, and quotes, orders, invoices and credits. Send small changes as they happen and large loads as a bulk file. This page covers the connector key, the record format, both ways to send and how to read the result of each record.

> [!WARNING]
>
> The API reference playground sends requests to production with your own API key. A create, update or import request sent from it changes the live data of your workspace.

## Get a connector key

The data endpoints accept only a **Connector** key. A connector key belongs to one integration, and every record it sends lands in that integration.

On the integration's page, select **Create key** on the **Connector keys** card, then copy the key; it is shown once. A connector key is always a live key. Rotate and revoke it from the same card. If the integration cannot accept data, requests are refused with `409` and `connection_unavailable`.

## Record format

Every record has the same envelope.

| Field | Meaning |
| - | - |
| `externalKey` | Your system's unique key for the record. Up to 255 characters |
| `sequence` or `updatedAt` | The record's version: a whole number that grows with each change, or the time of the change. Send exactly one, and keep using the same one for a record |
| `fields` | The record's values |
| `deleted` | `true` to delete the record. A deleted record carries no `fields`; a deleted document carries only its `kind` |

A record with an older version than the one already stored is not applied and is reported as `stale`. The [API reference](/docs/api-reference/introduction.md) lists every field of catalog items, customers and documents.

```json theme={null}
{
  "externalKey": "item-10442",
  "sequence": 18,
  "fields": {
    "sku": "AX-2201",
    "name": "Ball bearing 25 mm",
    "listPrice": "14.20",
    "cost": { "amount": "8.35", "currency": "USD", "basis": "current-average" },
    "stock": [{ "location": "main", "quantity": "1200" }]
  }
}
```

## Send records as they change

`PUT /v1/catalog/items`, `PUT /v1/customers` and `PUT /v1/documents` each take up to 100 records in a body of up to 2 MiB. Each request needs an `Idempotency-Key`. See [Idempotency](/docs/developers/idempotency.md).

```bash theme={null}
curl -X PUT https://api.elastly.ai/v1/catalog/items \
  -H "Authorization: Bearer YOUR_CONNECTOR_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6b2f8d14-9c3a-4e57-a1d0-3f8e2c7b5a19" \
  -d '{
    "records": [
      {
        "externalKey": "item-10442",
        "sequence": 18,
        "fields": { "sku": "AX-2201", "name": "Ball bearing 25 mm", "listPrice": "14.20" }
      }
    ]
  }'
```

The response is `202` with an `importId` and one entry per record, in request order, with its `index`, `externalKey`, `state` and any `errors`.

## Send a bulk file

For a large load, send one file per import.

**1. Create the import**

`POST /v1/imports` with the `object` (`catalog_items`, `customers` or `documents`) and the `format` (`jsonl` or `csv`). Documents are imported as `jsonl` only. Send an `Idempotency-Key`. The response is `201` with the import's `id` and the state `awaiting_file`.

**2. Upload the file**

`PUT /v1/imports/{id}/file` with the file as the body and `Content-Type` set to `application/x-ndjson` for `jsonl` or `text/csv` for `csv`. The file is up to 100 MiB, and each record up to 1 MiB. Uploading again before the import starts replaces the file.

**3. Start the import**

`POST /v1/imports/{id}/commit` with an `Idempotency-Key`. The response is `202` and the import is `queued`.

**4. Follow the import**

`GET /v1/imports/{id}` returns its `state` and `counts`. When it finishes, the workspace emits an `import.completed` event. See [Webhooks and events](/docs/developers/webhooks.md).

```bash theme={null}
curl -X POST https://api.elastly.ai/v1/imports \
  -H "Authorization: Bearer YOUR_CONNECTOR_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 2a9e4c71-5d3b-4f08-b6e2-8c1d0a7f3e54" \
  -d '{ "object": "catalog_items", "format": "jsonl" }'

curl -X PUT https://api.elastly.ai/v1/imports/IMPORT_ID/file \
  -H "Authorization: Bearer YOUR_CONNECTOR_KEY" \
  -H "Content-Type: application/x-ndjson" \
  --data-binary @catalog-items.jsonl

curl -X POST https://api.elastly.ai/v1/imports/IMPORT_ID/commit \
  -H "Authorization: Bearer YOUR_CONNECTOR_KEY" \
  -H "Idempotency-Key: 8f3c1b62-0e4d-4a97-b5c8-6d2e9f1a7b03"
```

| Import state | Meaning |
| - | - |
| `awaiting_file` | Created and waiting for its file |
| `uploaded` | The file is stored and the import can start |
| `queued` | Started and waiting to run |
| `staging` | Records are being read and checked |
| `projecting` | Accepted records are being applied |
| `completed` | Finished. Read `counts` and the record results |
| `failed` | Stopped. `error` names the cause |
| `expired` | Not started within 24 hours of being created. Create a new import |

## Echo the price on an order line

When an order line was sold at a price Elastly served, send that price's `priceId` on the line. Elastly links the order line to the exact price decision, so the outcome of that price is known. The `priceId` comes from a priced line of `POST /v1/price` or from a [channel price](/docs/developers/channel-prices.md).

A line of an order document, with the price echoed:

```json theme={null}
{ "lineId": "1", "product": "item-10442", "quantity": "40", "amount": "568.00", "priceId": "PRICE_ID_FROM_THE_PRICE_RESPONSE" }
```

* `priceId` is optional and applies to order lines. A line can also carry the `version` that came with the price; it is accepted for reference and not stored. A `version` without a `priceId` is a field error.
* The line is linked only when the price was served for the same item and the same customer as the order.
* A `priceId` that does not match a price served to the workspace does not fail the record. The record is imported without it, and the record's result carries a notice with the code `price_id_unknown` and the message "The price id does not match a price served to this workspace. The line was imported without it."

## Read the result of each record

`GET /v1/imports/{id}/records` lists the result of every record by line, with up to 1,000 per page. Filter with `state` to see only the records that need attention. Every create or update request also returns an `importId` that you can read the same way.

| Record state | Meaning |
| - | - |
| `accepted` | Stored and waiting to be applied |
| `imported` | Applied |
| `unresolved` | Waiting for a record it refers to, such as a document's customer. It is applied when that record arrives |
| `failed` | Not applied. `errors` names each field and the reason |
| `stale` | Not applied because a newer version of the record is already stored |

A record's result also has `notices`: remarks about a record that was still imported, each with a `field`, a `code` and a `message`.

A record that stays `unresolved` for 48 hours fails with the message "The referenced records were not received within 48 hours." followed by the missing keys. Send the missing records and then the failed record again.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.