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

# Orders Field Mapping

> Map source order fields to Better Data order fields.

## Overview

Orders import writes customer orders and order lines for fulfillment workflows.
Each order requires an `externalOrderId` and at least one line.

## Quick Start

1. Build `orders[]` with order headers and nested `lines`.
2. POST to `/api/import/orders`.
3. Poll `/api/import/status/[jobId]`.

## Header Fields

| Better Data Field | Type   | Required | Example     | Description                       |
| ----------------- | ------ | -------- | ----------- | --------------------------------- |
| `externalOrderId` | string | YES      | `SO-778901` | Unique order ID (idempotent key). |
| `lines`           | array  | YES      | `[{...}]`   | Order line rows.                  |

## Line Fields (`lines[]`)

| Better Data Field | Type   | Required | Example   | Description                |
| ----------------- | ------ | -------- | --------- | -------------------------- |
| `skuId`           | string | YES      | `SKU-001` | Ordered SKU.               |
| `quantity`        | number | YES      | `2`       | Requested quantity.        |
| `locationId`      | string | YES      | `DC-EAST` | Fulfillment location code. |

## Validation Rules

* `orders[]` must be present and non-empty.
* Header requires `externalOrderId` and non-empty `lines[]`.
* Each line should include `skuId`, `quantity`, and `locationId`.

## Common Errors

| Error                     | Meaning                                    | How to fix                                            |
| ------------------------- | ------------------------------------------ | ----------------------------------------------------- |
| `orders[] is required`    | Missing order array.                       | Send `{ "orders": [ ... ] }`.                         |
| `required fields missing` | Missing `externalOrderId` or no line rows. | Provide required header fields and at least one line. |
