
<ApiOverview api="orders" />

The Orders API gives your server the orders of your shop, each with its
delivery address, customer, subscription and line items, and lets you mark
them as shipped with a carrier and a tracking number. It is made for shipping
and fulfillment integrations. Call it from a backend only; the key gives
access to every order and customer of your shop.

## Base URL

```text title="Base URL"
https://www.subbly.co/api/v1
```

Every path in this reference is relative to it. Requests and responses are
JSON; send `Content-Type: application/json` with a body.

## Authentication

Send the API key of your shop as a Bearer token in the `Authorization`
header on every request.

```bash title="Authenticated request"
curl https://www.subbly.co/api/v1/orders \
  -H 'Authorization: Bearer <api-key>'
```

Without a valid key the API answers `401` with `{"message": "Unauthorized
request"}`. The key is the shop API key of the Subbly admin, the same key the
Subbly Zapier app uses. It is not a Private API key; those work with the
[Private API](/api/private) only.

## Pagination

`GET /orders` takes `page` and `per_page` (1 to 100, 15 by default) and
returns the orders in `data` next to the page counters:

```json title="A page"
{
  "data": [],
  "current_page": 1,
  "total": 32,
  "first": 1,
  "last": 3,
  "per_page": 15
}
```

`first` and `last` are page numbers.

## Errors

The API answers with the usual HTTP status codes. Error responses carry a
JSON body with a `message`; validation errors (`422`) add an `errors` object
keyed by field.

| Status | Meaning |
| --- | --- |
| `401` | The API key is missing or wrong. |
| `404` | No order with this ID in your shop. |
| `422` | The body or the query failed validation. |

```json title="Validation error"
{
  "message": "Validation Failed",
  "errors": {
    "per_page": ["The per page must be between 1 and 100."],
    "status": ["The selected status is invalid."]
  }
}
```
