Order events: new order, status change, payment, tracking number, product cancellation and credit slip. Request parameters, notification selection and the response format are the same for all of them and are described in the [E-shop API overview](https://www.bulkgate.com/en/docs/eshop-api/eshop-api-overview/).

## API URL

| ENDPOINT                                                         | NOTIFICATION EVENT                                   |
|:-----------------------------------------------------------------|:-----------------------------------------------------|
| `https://portal.bulkgate.com/api/1.0/eshop/order/new`            | `order_new`                                          |
| `https://portal.bulkgate.com/api/1.0/eshop/order/change-status`  | `order_status_change_<order_status_id>`              |
| `https://portal.bulkgate.com/api/1.0/eshop/order/payment`        | `order_payment_complete`, `order_payment_confirmation` |
| `https://portal.bulkgate.com/api/1.0/eshop/order/tracking-number`| `order_tracking_number`                              |
| `https://portal.bulkgate.com/api/1.0/eshop/order/product-cancel` | `order_product_cancel`                               |
| `https://portal.bulkgate.com/api/1.0/eshop/order/slip-add`       | `order_slip_add`                                     |

> [!NOTE]
> If the request does not reach its destination, repeat it on the [backup server](https://www.bulkgate.com/en/docs/api-administration-tokens/api-backup-server/) `backup1.bulkgate.com`.

## Supported HTTP methods

- `POST` - `application/json`

```http
POST /api/1.0/eshop/order/new HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json
```

## New order

`eshop/order/new` triggers the notification of the `order_new` event. Send it when the customer completes the order.

```http-json
POST /api/1.0/eshop/order/new HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
  "application_id": 451,
  "application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
  "language": "en",
  "shop_id": "0",
  "variables": {
    "order_id": "10045",
    "order_total_paid": "49.90",
    "order_currency": "EUR",
    "order_payment": "Cash on delivery",
    "customer_firstname": "John",
    "customer_lastname": "Smith",
    "customer_email": "john.smith@example.com",
    "customer_mobile": "777777777",
    "customer_country_id": "cz"
  }
}
```

## Order status change

`eshop/order/change-status` looks up the notification for a specific status. It builds the event name from `order_status_change_` and the value of the `order_status_id` variable, so always send `order_status_id` — without it the portal cannot match the notification to any status. Your e-shop uploads the statuses notifications can be set up for via the [setup](https://www.bulkgate.com/en/docs/eshop-api/eshop-api-setup/).

```http-json
POST /api/1.0/eshop/order/change-status HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
  "application_id": 451,
  "application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
  "language": "en",
  "variables": {
    "order_id": "10045",
    "order_status_id": "completed",
    "order_status": "Completed",
    "customer_mobile": "777777777",
    "customer_country_id": "cz"
  }
}
```

The request above uses the notification set up for the `order_status_change_completed` event.

## Order payment

`eshop/order/payment` first looks for the `order_payment_complete` notification, and when it is not set up, it uses `order_payment_confirmation`. The customer and admin notifications are picked separately — so the customer can get `order_payment_complete` and the administrators `order_payment_confirmation`.

## Tracking number

`eshop/order/tracking-number` triggers the `order_tracking_number` notification. Pass the tracking number and carrier in variables, e.g. `order_carrier_tracking_number`, `order_carrier_name` and `order_carrier_url`.

```http-json
POST /api/1.0/eshop/order/tracking-number HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
  "application_id": 451,
  "application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
  "language": "en",
  "variables": {
    "order_id": "10045",
    "order_carrier_name": "DHL",
    "order_carrier_tracking_number": "JD014600006281230704",
    "customer_mobile": "777777777",
    "customer_country_id": "cz"
  }
}
```

## Product cancellation and credit slip

- `eshop/order/product-cancel` triggers the `order_product_cancel` notification — a product was cancelled from the order.
- `eshop/order/slip-add` triggers the `order_slip_add` notification — a credit slip was issued for the order.

## Response

```json
{
    "data": {
        "customer": [
            {
                "status": "accepted",
                "message_id": "tmpde1bcd4b1d1",
                "part_id": ["tmpde1bcd4b1d1"],
                "number": "420777777777",
                "channel": "sms"
            }
        ]
    }
}
```

The meaning of the `customer` and `admin` keys, send errors and error types are described in the [E-shop API overview](https://www.bulkgate.com/en/docs/eshop-api/eshop-api-overview/).
