# Site REST API

> Read a site's orders, products, bookings, contacts, invoices, form entries and subscribers, and make changes, with an API key from Settings › Developers.

The site REST API is for the site's owner and their tools: n8n, Zapier, Make, a spreadsheet script or your own server. It can
see everything in the admin panel that its key is allowed to, unlike the public [Shop and content API](/developers/commerce-api),
which only shows what a visitor could see.

- **Address**: `https://api.vorjo.com/v1/sites/<site>` plus the path below, where `<site>` is the site's ID (its address name, shown in **Settings › Developers › Quick start**). With an API key, `<site>` can also be `me`: the key's own site.
- **Key**: every request sends `Authorization: Bearer vsk_…`. Make keys in **Settings › Developers › API keys**.
- **Format**: JSON in and out, camelCase keys, money as numbers in the site's currency, dates as ISO 8601 strings in UTC.

A request with an API key always goes to this API. Without one, the same address is the public API.

A [private Gear](/developers/gears-hosted#private-gears) calls this API too, with its install's access token
(`Authorization: Bearer vgt_…`) instead of a key. The Gear's scopes decide what it may do (see [Gears and scopes](#gears-and-scopes)).

## API keys and scopes

Each key belongs to one site and works only there. A key is shown once when it's made; Vorjo keeps only its SHA-256 hash, so a
lost key can't be shown again: revoke it and make a new one. A revoked key stops working at once.

Give each tool its own key with only the access it needs:

| Scope | Allows |
| --- | --- |
| `orders:read` | List and get orders |
| `orders:write` | Mark orders as sent (fulfilments). Includes `orders:read`. |
| `products:read` | List and get products and their variants |
| `products:write` | Create draft products. Includes `products:read`. |
| `bookings:read` | List and get bookings |
| `bookings:write` | Create bookings for free services. Includes `bookings:read`. |
| `contacts:read` | List and get contacts |
| `contacts:write` | Create contacts and change their tags. Includes `contacts:read`. |
| `invoices:read` | List and get invoices and quotes |
| `invoices:write` | Create draft invoices and quotes. Includes `invoices:read`. |
| `forms:read` | List and get form entries |
| `subscribers:read` | List and get newsletter subscribers |
| `inventory:read` | List and get stock levels per product variant |
| `inventory:write` | Change stock levels, each change with a reason. Includes `inventory:read`. |
| `availability:read` | List the times that can't be booked |
| `availability:write` | Block and unblock times for bookings (only the blocks this key made). Includes `availability:read`. |
| `leads:read` | List taps on the site's Call, WhatsApp and Email links (the kind and the page, never who) |

A call without the scope it needs gets `403` with the code `insufficient_scope`.

## Endpoints

| Method and path | Body | Returns |
| --- | --- | --- |
| GET `me` | | `{ site: { id, slug, name }, key: { id, name, scopes, rateLimit } }` |
| GET `orders?status=&payment_status=&fulfillment_status=` | | A page of orders |
| GET `orders/:id` | | One order |
| POST `orders/:id/fulfillments` | `{ lines?: [{ lineId, qty }], carrier?, trackingNumber?, trackingUrl?, notify? }` | `201` and the order. Without `lines`, everything not yet sent. `notify` (default true) emails the customer. |
| GET `products?status=` | | A page of products with their variants |
| GET `products/:id` | | One product |
| POST `products` | `{ title, description?, handle?, type?, vendor?, tags?, images?: ["https://…"], options?, specs?: [{ name, value, group? }], variants?: [{ title, price, sku?, compareAtPrice?, trackInventory?, inventory? }] }` | `201` and the product, always as a **draft**: the owner publishes it |
| GET `bookings?status=&service=` | | A page of bookings |
| GET `bookings/:id` | | One booking |
| POST `bookings` | `{ service, start, staff?, customer: { name, email, phone?, note? } }` | `201` and the confirmed booking. Free services only; `start` must be a free slot. The customer gets the usual confirmation email. |
| GET `contacts?tag=&email=&source=` | | A page of contacts |
| GET `contacts/:id` | | One contact |
| POST `contacts` | `{ name?, email?, phone?, company?, notes?, tags?, address? }` | `201` and the contact. An email that's already a contact is `409 already_exists` with its `id`. |
| POST `contacts/:id/tags` | `{ add?: string[], remove?: string[] }` | The contact with its new tags |
| PATCH `contacts/:id` | `{ name?, email?, phone?, company?, notes?, tags?, address? }` | The contact. Fields left out stay as they are; an email another contact has is `409 already_exists`. Needs `contacts:write`. |
| POST `contacts/:id/notes` | `{ body }` | `201` and `{ id, contactId, body, createdAt }`. Needs `contacts:write`. |
| POST `contacts/:id/tasks` | `{ title, dueAt? }` | `201` and `{ id, contactId, title, dueAt, done, createdAt }`. Needs `contacts:write` and the **Tasks & reminders** Gear (`409 tasks_off` without it). |
| GET `leads?kind=` | | A page of taps: `{ id, kind /* call \| whatsapp \| email */, page, createdAt }`. Needs `leads:read`. |
| GET `hooks` | | This key's REST hooks: `{ data: [{ id, url, event, app, enabled, createdAt }] }` |
| POST `hooks` | `{ url, event, app? }` | `201` and the hook with its signing `secret` (only now). See [REST hooks](#rest-hooks). |
| DELETE `hooks/:id` | | `{ id, deleted: true }`. Only hooks this key made. |
| GET `invoices?kind=&status=` | | A page of invoices and quotes (`kind`: `invoice` or `quote`) |
| GET `invoices/:id` | | One invoice or quote |
| POST `invoices` | `{ kind?: "invoice" \| "quote", customer: { name, email, company? }, contactId?, currency?, lines: [{ title, qty, price, taxName?, taxRate? }], dueDate?, notes?, terms? }` | `201` and the **draft**. The owner checks and sends it. |
| GET `form-entries?form=&status=` | | A page of form entries (spam left out) |
| GET `form-entries/:id` | | One form entry |
| GET `subscribers?status=` | | A page of newsletter subscribers (`subscribed`, `pending`, `unsubscribed`) |
| GET `subscribers/:id` | | One subscriber |
| GET `inventory?sku=&low=1&product=` | | A page of stock levels: `{ variantId, productId, product, variant, sku, inventory, trackInventory, allowBackorder, low }`, plus `lowStock` (the site's alert level) |
| GET `inventory/:variantId` | | One variant's stock |
| POST `inventory/:variantId/adjust` | `{ delta, reason }` or `{ set, reason }` | The variant's stock with `previous`, `delta` and `reason`. **Needs an `Idempotency-Key`.** `delta` adds or takes away (`-1` for a sale); `set` is a count. Turns on stock tracking for the variant and logs the change in its history (**Inventory** in the admin panel). |
| POST `bookings/:id/cancel` | `{ notify? }` | The cancelled booking. `notify` (default true) emails the customer. Cancelling again returns the same booking. A booking paid online is `409 payment_taken`: the owner cancels it in the admin panel, so the refund is handled there. |
| GET `availability` | | `{ data: [{ id, date, to, start, end, allDay, staff, note, createdBy, mine }], timezone }`: time off and blocks, in the business's time zone |
| POST `availability` | `{ date, to?, start?, end?, staff?, note? }` | `201` and the block, plus `conflicts`: ids of bookings already in that time (they stay). Days are `2026-12-24`, times `09:00` in the business's time zone; leave out `start` and `end` for whole days; `to` for several days. |
| DELETE `availability/:id` | | `{ id, deleted: true }`. Only blocks this key or Gear made. |

Free slots for `POST bookings` come from the public API: `GET bookings/slots?service=&date=` without a key. Services that
take a payment are booked on the site, where the customer pays.

Previews (test orders, bookings and messages) are never listed.

```bash title="curl" group="Example: the newest orders"
curl "https://api.vorjo.com/v1/sites/harbor-coffee/orders?limit=2" \
  -H "Authorization: Bearer vsk_YOUR_KEY"
```

```js title="JavaScript"
const r = await fetch("https://api.vorjo.com/v1/sites/harbor-coffee/orders?limit=2", { headers: { authorization: `Bearer ${process.env.VORJO_KEY}` } });
const { data, hasMore, nextCursor } = await r.json();
```

```json title="Response"
{
  "data": [
    { "id": "1042", "number": 1042, "name": "#1042", "status": "open", "paymentStatus": "paid", "fulfillmentStatus": "unfulfilled",
      "currency": "USD", "subtotal": 24, "discountTotal": 0, "shippingTotal": 5, "taxTotal": 0, "total": 29, "refunded": 0,
      "customer": { "name": "Mia Wong", "email": "mia@example.com", "phone": "" },
      "lines": [{ "id": "l8x2", "productId": "17", "variantId": "31", "title": "Mug", "variantTitle": "", "sku": "MUG-1", "qty": 2, "price": 12, "total": 24, "fulfilled": 0 }],
      "fulfillments": [],
      "source": { "label": "Google Ads — Holiday Beans", "channel": "Paid search", "campaign": "Holiday Beans", "keyword": "coffee gift set", "landing": "/", "recorded": true,
        "first": { "label": "Google Shopping (free listing)", "channel": "Shopping (free listings)", "landing": "/products/mug", "clickType": "srsltid", "...": "..." },
        "last": { "label": "Google Ads — Holiday Beans", "channel": "Paid search", "source": "Google Ads", "name": "Google", "utm": { "source": "google", "medium": "cpc", "campaign": "Holiday Beans", "term": "coffee gift set" }, "clickType": "gclid", "clickId": "Cj0KCQiA…", "referrer": "google.com", "at": "2026-11-21T09:02:11.000Z" } },
      "createdAt": "2026-11-21T09:12:04.000Z", "updatedAt": "2026-11-21T09:15:40.000Z" }
  ],
  "hasMore": true,
  "nextCursor": "MTA0MQ"
}
```

Orders and bookings carry `source`: where the customer came from, as the first and last visit before buying (UTM tags, the ad
network's click id, the referring site and the landing page). `recorded: false` means no source was kept (a direct visit, or the
visitor didn't allow cookies); `null` means the order was placed before sources were kept. Webhooks send the same object.

## REST hooks

Zapier, Make and similar tools subscribe a web address to one event when an automation is turned on, and unsubscribe when it's
turned off. `POST hooks` with `{ "url": "https://hooks.zapier.com/…", "event": "order.created" }` makes a hook; the answer has its
`id` (keep it to unsubscribe) and its signing `secret`. Deliveries are the usual [webhook events](/developers/webhook-events):
signed with that secret, retried, and listed in **Settings › Developers › Logs**.

- The address must be `https://` on a public host.
- The key needs the read scope of the event: `orders:read` for `order.*`, `bookings:read` for `booking.*`, `contacts:read` for
  `contact.created`, `customer.signed_up` and `chat.lead`, `forms:read` for `form.submitted`, `leads:read` for `lead.tapped`, and so on.
  Otherwise `403 insufficient_scope`.
- A key can have 30 hooks and a site 60 (`409 too_many_hooks`). They don't count towards the 10 endpoints in Settings › Developers.
- Only the key that made a hook lists or removes it. Revoking the key removes its hooks.

The **Zapier & Make** Gear makes keys with the scopes its triggers and actions need, so owners don't pick scopes themselves.

## Pagination and changes since

Lists are newest first and come in pages of `{ data, hasMore, nextCursor }`.

- `limit`: 1 to 100 (default 50).
- `cursor`: the `nextCursor` of the page before. Keep asking until `hasMore` is `false`.
- `updated_since`: an ISO date and time. Only records changed at or after it, for syncing: save the time you started, then ask for changes since then next time.

## Idempotency

Send an `Idempotency-Key` header (any string up to 200 characters, like a UUID) with a `POST` to make it safe to retry. The
first answer is kept for 24 hours: the same key and request get the same answer again, with `Idempotent-Replayed: true`, and
nothing is created twice. The same key with a different request gets `409 idempotency_conflict`. Keys are per API key.

```bash title="curl" group="Example: add a contact, safe to retry"
curl -X POST "https://api.vorjo.com/v1/sites/harbor-coffee/contacts" \
  -H "Authorization: Bearer vsk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2b9e-0d4a-4a6b-9c1e-2f7d8e9a0b1c" \
  -d '{"name":"Ava Chen","email":"ava@example.com","tags":["Lead"]}'
```

## Gears and scopes

A private Gear's token works on the endpoints above that match its scopes:

| Gear scope | REST scope it gives |
| --- | --- |
| `read_orders` / `write_orders` | `orders:read` / `orders:write` |
| `read_products` / `write_products` | `products:read` / `products:write` (and `inventory:read` / `inventory:write`) |
| `read_inventory` / `write_inventory` | `inventory:read` / `inventory:write` |
| `read_bookings` / `write_bookings` | `bookings:read` / `bookings:write` |
| `write_availability` | `availability:read` and `availability:write` |
| `read_customers` | `contacts:read` |

Invoices, form entries and subscribers aren't open to Gears. A Gear's rate limit is per Gear per project: 120 requests a
minute, shared with the [admin API](/developers/gears-hosted#the-api). Every call is listed in the Gear's **Activity** (the
owner's Gear page and the Developer dashboard), with its answer.

## Errors

Every error has the same shape and a matching HTTP status:

```json title="Error"
{ "error": { "code": "insufficient_scope", "message": "This key can't do that: it needs contacts:write. Create a key with that access in Settings › Developers." } }
```

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `invalid_request`, `invalid_json`, `invalid_cursor`, `idempotency_key_required` | Something in the request is missing or wrong; the message says what |
| 401 | `invalid_key`, `invalid_token` | No key, an unknown key, or a revoked key (`invalid_token`: a Gear's token that was replaced or revoked) |
| 403 | `insufficient_scope` | The key doesn't have the scope this call needs |
| 403 | `wrong_site` | The key belongs to another site |
| 404 | `not_found` | No such endpoint, or no record with that id on this site |
| 405 | `method_not_allowed` | The path exists, the method doesn't |
| 409 | `already_exists`, `slot_taken`, `payment_required`, `idempotency_conflict`, `idempotency_in_progress`, `bookings_off`, `payment_taken`, `not_cancellable`, `too_many_blocks` | The request can't be done as it is |
| 413 | `too_large` | The body is over 64 KB |
| 429 | `rate_limited` | Too many requests for this key; wait `Retry-After` seconds |
| 500 | `server_error` | Something went wrong on Vorjo's side; try again |

## Rate limits

Each key has its own limit: 60, 120 (the default), 300 or 600 requests a minute, set in **Settings › Developers**. Every
answer has `X-RateLimit-Limit` and `X-RateLimit-Remaining`; going over returns `429` with `Retry-After`.

The API is for servers and automation tools. Browsers can't call it with a key (CORS allows no `Authorization` header), so a
key never ends up in a web page.

See [Webhook events](/developers/webhook-events) to get changes as they happen instead of asking, and
[n8n, Zapier and Make](/developers/automation) for step-by-step setups.
