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

# Data API

> Send orders, customers, product variants and refunds from your own backend to Eyk over HTTPS, and correct costs from a second system.

Send your orders, customers, product variants and refunds to Eyk over HTTPS, one object or a batch per request. Eyk stores every request and processes it in the night run.

## Before you start

You need:

* The [Custom data](/guides/custom-data) page, read once.
* The Custom Data API source added in Eyk under **Sources**.
* An API key, created on the **Configure** tab of that source with **Create API key**. The key is shown once.
* Your organization id, the UUID after `/org/` in the URL of your Eyk environment.

## Endpoints

| Object                 | Endpoint                                                       | Key field  |
| ---------------------- | -------------------------------------------------------------- | ---------- |
| Product variant        | `POST https://data-api.eykdata.com/v1/product_variants`        | `id`       |
| Customer               | `POST https://data-api.eykdata.com/v1/customers`               | `id`       |
| Order                  | `POST https://data-api.eykdata.com/v1/orders`                  | `id`       |
| Refund                 | `POST https://data-api.eykdata.com/v1/refunds`                 | `id`       |
| Order update           | `POST https://data-api.eykdata.com/v1/order_updates`           | `order_id` |
| Product variant update | `POST https://data-api.eykdata.com/v1/product_variant_updates` | `id`       |

Every request carries the header `X-API-Key` and a JSON body: one object, or an array of up to 100 objects. Every object carries your `organization_id`. Timestamps are ISO 8601 with a timezone offset, for example `2026-03-14T10:15:00Z`. Every field, with its type and meaning, is in the [Data API reference](https://data-api.eykdata.com/docs).

<Steps>
  <Step title="Validate a first object">
    Send one product variant with `debug=true`. Eyk validates the object and your key and stores nothing. A `200` means the object is accepted.

    ```bash theme={null}
    curl -X POST 'https://data-api.eykdata.com/v1/product_variants?debug=true' \
      -H 'X-API-Key: YOUR_API_KEY' \
      -H 'Content-Type: application/json' \
      -d '{
        "organization_id": "5f6a0c1e-2b3d-4e5f-8a9b-0c1d2e3f4a5b",
        "id": "VASE-BLU",
        "sku": "VB-001",
        "name": "Blue",
        "parent_id": "VASE",
        "parent_name": "Ceramic vase",
        "fallback_unit_cost": 8.50,
        "category_path": ["Home", "Vases"],
        "created_at": "2025-06-01T08:00:00Z",
        "updated_at": "2026-02-20T12:00:00Z"
      }'
    ```
  </Step>

  <Step title="Send variants and customers">
    Repeat without `debug=true` for every variant your order lines refer to, in batches of up to 100. Then send your customers to `/v1/customers`. `email` is required on a customer.
  </Step>

  <Step title="Send orders">
    Refer to the customer and the variants by id. Every amount excludes tax.

    ```bash theme={null}
    curl -X POST 'https://data-api.eykdata.com/v1/orders' \
      -H 'X-API-Key: YOUR_API_KEY' \
      -H 'Content-Type: application/json' \
      -d '{
        "organization_id": "5f6a0c1e-2b3d-4e5f-8a9b-0c1d2e3f4a5b",
        "id": "NV-10432",
        "order_number": "#1043",
        "payment_status": "paid",
        "store_view_id": "nl",
        "store_view_name": "Noor & Vos NL",
        "sales_channel": "web",
        "created_at": "2026-03-14T10:15:00Z",
        "updated_at": "2026-03-14T10:15:00Z",
        "currency": "EUR",
        "subtotal": 90.00,
        "discounts": 10.00,
        "discount_codes": ["SPRING10"],
        "shipping": 5.00,
        "shipping_tax": 1.05,
        "taxes": 17.85,
        "customer": "CUST-8842",
        "shipping_address": { "country": "NL" },
        "items": [
          { "id": "NV-10432-1", "quantity": 2, "unit_price": 20.00, "taxes": 8.40, "product_variant": "VASE-BLU" },
          { "id": "NV-10432-2", "quantity": 1, "unit_price": 50.00, "discounts": 10.00, "taxes": 8.40, "product_variant": "TRAY-OAK" }
        ]
      }'
    ```

    <Info>
      `customer` and `product_variant` also take the full object instead of the id. Then you can skip the separate customer and variant requests.
    </Info>
  </Step>

  <Step title="Send refunds">
    Send each refund to `/v1/refunds` with the `order_id` of the refunded order, the `amount` refunded for goods, and the refunded lines in `items` when you have them.
  </Step>

  <Step title="Send changes as they happen">
    Send a record again, in full, with a later `updated_at` whenever it changes. Per `id` the latest `updated_at` wins.
  </Step>

  <Step title="Send cost corrections">
    Optional. When a second system, such as an ERP, knows the real shipping cost or cost of goods, send an order update. Only the fields you name change. Per field, the update with the highest `priority` wins, then the latest `occurred_at`.

    ```bash theme={null}
    curl -X POST 'https://data-api.eykdata.com/v1/order_updates' \
      -H 'X-API-Key: YOUR_API_KEY' \
      -H 'Content-Type: application/json' \
      -d '{
        "organization_id": "5f6a0c1e-2b3d-4e5f-8a9b-0c1d2e3f4a5b",
        "order_id": "NV-10432",
        "occurred_at": "2026-03-16T07:00:00Z",
        "source_system": "erp",
        "priority": 10,
        "shipping_cost": 4.35,
        "items": [{ "id": "NV-10432-2", "unit_cost": 21.00 }]
      }'
    ```
  </Step>
</Steps>

A field that was removed from the API is accepted and ignored, and the response carries a `Warning` header that names it.

## Check it worked

Open the Custom Data API source in Eyk under **Sources**. The **Monitor** tab lists orders, refunds, product variants and customers received per day. Data appears in reports the morning after Eyk's night run.

## Troubleshooting

<AccordionGroup>
  <Accordion title="422 with a message about the timestamp">
    A timestamp has no timezone offset. Send `2026-03-14T10:15:00Z` or `2026-03-14T12:15:00+02:00`.
  </Accordion>

  <Accordion title="403 Forbidden">
    The API key does not belong to this `organization_id`. Check the id after `/org/` in your Eyk URL, and the scope chosen when the key was created.
  </Accordion>

  <Accordion title="422 batch size exceeds maximum">
    The array holds more than 100 objects. Split it.
  </Accordion>

  <Accordion title="422 duplicate item IDs">
    Two lines in one order share an `id`. Line ids must be unique within the order.
  </Accordion>

  <Accordion title="200 but the order is missing in reports">
    Reports update once a night. If the order is still missing the next morning, check the Monitor tab for the day you sent it. Then check that its `variant_id` and `customer_id` values match records you sent.
  </Accordion>
</AccordionGroup>
