# Notify an order

Confirmation, shipping and delivery with a template.

An order creates three useful moments: confirmation, shipping, delivery. Each is a `UTILITY` template, which is the easiest to get approved.

> **Tip**

> Without a dedicated number, use the [Relay plan](/en/docs/relay) instead (`POST /relay/messages` and `POST /relay/orders/{id}/notify`): ready-made scenarios on the shared LocalTech number. This guide covers the **dedicated number** path (Starter+).

## The templates

| Name | Text |
|---|---|
| `order_confirmed` | Hello {{1}}, we received your order {{2}}. |
| `order_shipped` | {{1}}, your order {{2}} is on its way. Tracking: {{3}} |
| `order_delivered` | {{1}}, your order {{2}} has been delivered. Thank you! |

Create them once with [`POST /templates`](/en/docs/templates), then wait for the `approved` state.

## Send at each step

```php
function notify(string $to, string $template, array $values): void
{
    $body = [
        'connectionId' => getenv('WA_CONNECTION_ID'),
        'to' => $to,
        'template' => [
            'name' => $template,
            'language' => 'en',
            'components' => [[
                'type' => 'body',
                'parameters' => array_map(fn ($v) => ['type' => 'text', 'text' => (string) $v], $values),
            ]],
        ],
    ];

    $ch = curl_init(getenv('WA_API_BASE').'/messages');
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('WA_API_KEY'), 'Content-Type: application/json'],
        CURLOPT_POSTFIELDS => json_encode($body),
    ]);
    curl_exec($ch);
}

notify('+237600000000', 'order_shipped', ['Awa', 'A-2041', 'https://track.example.com/A-2041']);
```

## Good practice

- Send from a queue: a network failure must not block the order.
- Keep the message `id` with the order to find its status.
- Listen to [webhooks](/en/docs/webhooks): a customer reply ("where is my parcel?") opens a 24-hour window in which you can answer freely.
