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

# Create order fulfillment

> The "Order Fulfillment" API facilitates the process of fulfilling an order.

The "Order Fulfillment" API facilitates the process of fulfilling an order.

```http theme={null}
POST https://services.leadconnectorhq.com/payments/orders/{orderId}/fulfillments
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Path parameters

<ParamField path="orderId" type="string" required default="653f5e0cde5a1314e62a837c">
  ID of the order that needs to be returned
</ParamField>

## Body

<ParamField body="altId" type="string" required default="6578278e879ad2646715ba9c">
  Account Id or Agency Id
</ParamField>

<ParamField body="altType" type="string" required>
  Posibles valores: 'account'
</ParamField>

<ParamField body="trackings" type="object[]" required>
  Fulfillment tracking information

  <Expandable title="cada item">
    <ParamField body="trackingNumber" type="string" default="40012345678">
      Tracking number provided by the shipping carrier
    </ParamField>

    <ParamField body="shippingCarrier" type="string" default="FedEx">
      Shipping carrier name
    </ParamField>

    <ParamField body="trackingUrl" type="string" default="https://www.fedex.com/wtrk/track/?trknbr=40012345678">
      Tracking URL
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="items" type="object[]" required>
  Fulfilled items

  <Expandable title="cada item">
    <ParamField body="priceId" type="string" required default="6578278e879ad2646715ba9c">
      The id of product price
    </ParamField>

    <ParamField body="qty" type="number" required default="1">
      The no of quantity of the item
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="notifyCustomer" type="boolean" required default="True">
  Need to send a notification to customer
</ParamField>

## Respuestas

<Accordion title="200 - Successful response">
  <ResponseField name="status" type="boolean" required default="True">
    Status of api action
  </ResponseField>

  <ResponseField name="data" type="object" required>
    fulfillment data
  </ResponseField>

  ```json theme={null}
  {
    "status": true
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://services.leadconnectorhq.com/payments/orders/YOUR_orderId/fulfillments' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "altId": "6578278e879ad2646715ba9c",
    "altType": "account",
    "trackings": [
      {
        "trackingNumber": "40012345678",
        "shippingCarrier": "FedEx",
        "trackingUrl": "https://www.fedex.com/wtrk/track/?trknbr=40012345678"
      }
    ],
    "items": [
      {
        "priceId": "6578278e879ad2646715ba9c",
        "qty": 1
      }
    ],
    "notifyCustomer": true
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/payments/orders/YOUR_orderId/fulfillments', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"altId": "6578278e879ad2646715ba9c", "altType": "account", "trackings": [{"trackingNumber": "40012345678", "shippingCarrier": "FedEx", "trackingUrl": "https://www.fedex.com/wtrk/track/?trknbr=40012345678"}], "items": [{"priceId": "6578278e879ad2646715ba9c", "qty": 1}], "notifyCustomer": true}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'POST',
      'https://services.leadconnectorhq.com/payments/orders/YOUR_orderId/fulfillments',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"altId": "6578278e879ad2646715ba9c", "altType": "account", "trackings": [{"trackingNumber": "40012345678", "shippingCarrier": "FedEx", "trackingUrl": "https://www.fedex.com/wtrk/track/?trknbr=40012345678"}], "items": [{"priceId": "6578278e879ad2646715ba9c", "qty": 1}], "notifyCustomer": true},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/payments/orders/YOUR_orderId/fulfillments');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode({'altId': '6578278e879ad2646715ba9c', 'altType': 'account', 'trackings': [{'trackingNumber': '40012345678', 'shippingCarrier': 'FedEx', 'trackingUrl': 'https://www.fedex.com/wtrk/track/?trknbr=40012345678'}], 'items': [{'priceId': '6578278e879ad2646715ba9c', 'qty': 1}], 'notifyCustomer': true}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
