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

# Create multiple orders in one request.

> Batch processed with one or more failures

### Path parameters

<ParamField path="tenant_id" type="string" required>
  Tenant identifier
</ParamField>

### Query parameters

<ParamField query="dry_run" type="boolean">
  When true, validates and previews results without creating orders
</ParamField>

### Request body

`CreateOrdersBatchRequest`

<ParamField body="dryRun" type="boolean">
  Validate and preview batch execution without writing any orders.
</ParamField>

<ParamField body="orders" type="CreateOrderRequest[]">
  Orders to create in sequence.
</ParamField>

<ParamField body="stopOnError" type="boolean">
  Stop processing after the first failed item.
</ParamField>

### Response

`CreateOrdersBatchResponse`

<ResponseField name="completed" type="boolean" required>
  Whether every input entry was attempted.
</ResponseField>

<ResponseField name="dryRun" type="boolean" required>
  True when the request executed in dry-run mode (no writes performed).
</ResponseField>

<ResponseField name="failed" type="integer" required>
  Number of failed orders.
</ResponseField>

<ResponseField name="results" type="CreateOrderBatchResult[]" required>
  Per-order result details.

  <Expandable title="CreateOrderBatchResult">
    <ResponseField name="action" type="string" required>
      Result action: · `created_or_reused` for live writes. · `would_create` / `would_reuse_existing` for dry-run previews. · `failed` when validation or write fails.
    </ResponseField>

    <ResponseField name="error" type="object">
      <Expandable title="error">
        <ResponseField name="code" type="string" required>
          Stable machine-readable error code.
        </ResponseField>

        <ResponseField name="message" type="string" required>
          Human-readable error message.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="index" type="integer" required>
      Input index of this order in the original request array.
    </ResponseField>

    <ResponseField name="shopifyOrderId" type="string" required>
      Shopify order id from input.
    </ResponseField>

    <ResponseField name="statesetOrderId" type="string (uuid)">
      Created/reused StateSet order id on success.
    </ResponseField>

    <ResponseField name="success" type="boolean" required>
      True when creation succeeded (or was idempotently resolved).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="succeeded" type="integer" required>
  Number of successfully created/reused orders.
</ResponseField>

<ResponseField name="total" type="integer" required>
  Number of input orders.
</ResponseField>

### Status codes

| Code  | Meaning                                   |
| ----- | ----------------------------------------- |
| `200` | Batch processed with one or more failures |
| `201` | All orders created successfully           |
| `401` | Unauthorized - invalid or missing API key |
| `422` | Validation error                          |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.sync.stateset.com/v1/tenants/{tenant_id}/orders/batch' \
    --header 'x-stateset-api-key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "dryRun": false,
    "orders": [
      {
        "createdAt": "2026-08-31T14:22:05Z",
        "externalOrderId": "string",
        "externalPlatform": "string",
        "lineItems": [],
        "locationId": "string",
        "netsuiteId": "string",
        "orderNumber": "M-1001",
        "shopifyOrderId": "1234567890",
        "sourceOrderPayload": null,
        "tags": [],
        "workflowId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      }
    ],
    "stopOnError": true
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "completed": true,
    "dryRun": false,
    "failed": 1,
    "results": [
      {
        "action": "string",
        "error": {
          "code": null,
          "message": null
        },
        "index": 1,
        "shopifyOrderId": "string",
        "statesetOrderId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "success": true
      }
    ],
    "succeeded": 1,
    "total": 102
  }
  ```
</ResponseExample>
