# Digital products and delivery

How your app reads the codes and links delivered to the customer, and resends them through another channel when needed.

## When you need it

Stores that sell gift cards, subscriptions and files deliver a code or link to the customer as soon as the order is paid. Messaging and support apps need to resend that content to the customer over WhatsApp or SMS, or show it to a support agent.

The scope is `orders.digital:read`, which requires `orders:read`.

## Read the content

```bash
curl "https://larm.sa/stores/$STORE_ID/v1/orders/ord_8Kd2/digital-items" \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

```json
{
  "data": {
    "order_id": "ord_8Kd2",
    "items": [
      { "product_id": "311", "name": "Top-up card 100 SAR", "type": "code", "value": "X7Q2-9KLM-4PZT", "expires_at": null },
      { "product_id": "402", "name": "User guide", "type": "file", "value": "https://store.example/d/…", "expires_at": null }
    ]
  },
  "meta": { "request_id": "…" }
}
```

| `type` | `value` |
|---|---|
| `code` | The code itself |
| `link` | The subscription or service link |
| `file` | A download link signed for this order and this file |
| `text` | Text the merchant wrote for the product |

- An unpaid order returns 409 `ORDER_NOT_PAID`.
- File links are signed for the order and checked on download. Treat them like a password: send them to the customer, never publish them, and read them again when needed instead of storing them.
- `expires_at` is `null` today for every type. Code that reads it should already handle a time, so a future expiry needs no change on your side.

## With the webhook

Instead of reading on every order, subscribe to [`order.digital.delivered`](/events/order-digital-delivered). When your installation holds `orders.digital:read`, the webhook carries `digital_items` directly, so you do not need a second request.

> **Warning:** Codes are the merchant's money. Never write them to logs, and send them only to the customer who placed the order, at the phone number or email in that same order.
