<!-- Source: https://www.orderkraft.com/docs/developers/erp/ -->

# Integrate your ERP

When a shop uses an ERP, every new manufacturing order waits in `analysis` until the ERP has checked that the materials are there. This guide connects an ERP to that step: it hears about each new order, checks the stock, and then releases the order to production or puts it on hold with a reason.

Every ERP connects the same way, through the [API](/docs/developers/api/) and [webhooks](/docs/developers/webhooks/). There's nothing to install.

## Before you start

You need:

- **ERP** turned on under **Settings → Integrations**. See [Connect your ERP](/docs/setup/connect-your-erp/)
- An [API key](/docs/developers/api/#create-an-api-key) with *Read and write* access

## Step 1: Hear about new orders

Subscribe to webhooks for the topics your ERP acts on. At the least that's `manufacturing_order.created`:

```sh
curl -X POST https://orderkraft.app/api/v1/webhook_subscriptions \
  -H "Authorization: Bearer ok_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://erp.example.com/orderkraft/webhooks", "topics": ["manufacturing_order.created", "manufacturing_order.released", "manufacturing_order.cancelled"] }'
```

Store the `secret` from the answer and [verify every webhook](/docs/developers/webhooks/#verify-a-webhook) with it. A merchant can also add the subscription under **Settings → Webhooks** and hand you the secret.

## Step 2: Check the materials

A new order arrives as `manufacturing_order.created` with `"status": "analysis"`. Its `inputs` list every material the order needs, with `sku`, `requestedQuantity` and `unitOfMeasure`. Check those against your stock.

Answer the webhook with a `2xx` right away and do the check afterwards. See [answer quickly](/docs/developers/webhooks/#answer-quickly).

## Step 3: Release or hold the order

When everything is there, release the order. It goes to production with the status `waiting`:

```sh
curl -X POST https://orderkraft.app/api/v1/manufacturing_orders/5521/release \
  -H "Authorization: Bearer ok_live_..."
```

When something is missing, put the order on hold with a note the merchant can read:

```sh
curl -X POST https://orderkraft.app/api/v1/manufacturing_orders/5521/holds \
  -H "Authorization: Bearer ok_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "note": "Waiting on oak planks, expected on Thursday" }'
```

The answer is the manufacturing order, with your new hold in its `holds` list. Keep that hold's `id`.

When you know when the materials arrive, move the order's ship-by date too, so the merchant sees it's going to be late before it is:

```sh
curl -X PATCH https://orderkraft.app/api/v1/manufacturing_orders/5521 \
  -H "Authorization: Bearer ok_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "shipBy": "2026-12-15" }'
```

## Step 4: Lift the hold when the materials arrive

```sh
curl -X DELETE https://orderkraft.app/api/v1/manufacturing_orders/5521/holds/88 \
  -H "Authorization: Bearer ok_live_..."
```

Once nothing else holds the order, it goes on to production. You don't release it separately: an order you held is moved on by lifting its holds, and [release](/docs/developers/api-reference/#release-a-manufacturing-order) only works on an order still in analysis.

## What the merchant can do

Your holds are ordinary holds. The merchant sees your note on the order and can lift the hold themselves, for example when they buy the material locally. An order you haven't answered yet can be sent to production by hand too. Subscribe to `manufacturing_order.released` so your ERP hears when that happens.

Holds add up. If the merchant has an order on hold as well, production only resumes once every hold is lifted.

## Test it

Point a subscription at a request bin like [webhook.site](https://webhook.site/), turn on **ERP** in a development store, and place an order for a made-to-order product. You'll see `manufacturing_order.created` arrive with the order in `analysis`, and can try the release and hold calls against it.
