# Operator API

The control plane's API for the installation's shops: create and delete them, their keys, their people and their daily usage, called with the operator key.

Base URL in the compose stack: `http://127.0.0.1:8000`. Every call sends the operator key, `ORBSEARCH_OPERATOR_KEY`, as `Authorization: Bearer <key>`; a shop's key never works here, and the operator key never works on a shop's routes. [Conventions](/docs/reference/conventions) covers what the APIs share.

| Endpoint | What it does |
| --- | --- |
| [`GET /api/v1/shops`](#list-shops) | List the shops, oldest first |
| [`POST /api/v1/shops`](#create-shop) | Create a shop with its first secret key and its node's database role |
| [`GET /api/v1/shops/{shop}`](#show-shop) | Show a shop with its keys and people |
| [`PATCH /api/v1/shops/{shop}`](#change-shop) | Rename a shop |
| [`DELETE /api/v1/shops/{shop}`](#delete-shop) | Delete a shop and everything it owns |
| [`POST /api/v1/shops/{shop}/keys`](#issue-key) | Give a shop another secret key |
| [`DELETE /api/v1/shops/{shop}/keys/{key}`](#revoke-key) | Revoke one of a shop's secret keys |
| [`GET /api/v1/shops/{shop}/usage`](#show-usage) | Show a shop's searches, entities and index runs per day |
| [`POST /api/v1/shops/{shop}/users`](#add-person) | Let a person work in a shop |
| [`DELETE /api/v1/shops/{shop}/users/{user}`](#remove-person) | Take a person out of a shop |
| [`POST /api/v1/shops/{shop}/users/{user}/login-link`](#create-login-link) | Make a link that signs a person in once and opens their shop |

## List the shops, oldest first

`GET /api/v1/shops`

A page of shops; `links` and `meta` lead to the others.

### Parameters

- `page` (integer · at least 1): The page, counted from 1. Default: 1.

- `per_page` (integer · 1 to 100): How many to a page. Default: 15.

### Answers

- `200` (object): The shops.
  
  - `data` ([array of Shop](#Shop) · required)
  
  - `links` ([object](/docs/reference/management-api#PageLinks) · required): The pages around this one, as URLs to fetch.
  
  - `meta` ([object](/docs/reference/management-api#PageMeta) · required): Where this page stands in the whole list.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

## Create a shop with its first secret key and its node's database role

`POST /api/v1/shops`

Makes the shop's Postgres schema with its tables, its node's database role and its first secret key, all or nothing. The answer is the only time the key and the role's password are shown: the key is kept hashed and the password not at all, so write both where the shop's node and scripts read them. The slug never changes, since it names the schema, the role and the shop's address; slugs that name a page of the panel or an address of OrbSearch, such as `app` or `settings`, are refused.

### Body

A shop to create.

- `slug` (string · required): A shop's slug, such as `acme-tires`: up to 32 lowercase letters and digits, words joined by single hyphens. It never changes, since it names the shop's database schema and role and its address, `<slug>.orbsearch.dev`.

- `name` (string · required): The name people see in the panel, up to 100 characters.

- `query_api` (string · required): Where the control plane reaches the shop's Query API, such as `https://acme.orbsearch.dev`: an `http` or `https` URL of up to 255 characters, never an address that only a trusted network reaches.

### Answers

- `201` (object): The shop is created.
  
  - `shop` ([Shop](#Shop) · required): A shop of the installation.
  
  - `key` (object · required): A secret key as it is issued: the only time its secret is shown.
    
    - `id` (integer · required)
    
    - `name` (string): What it is for, as it was issued; left out for a key issued without a name.
    
    - `key` (string · required): What the shop's scripts send as `Authorization: Bearer <key>` to the management API.
    
    - `created_at` (string · required): A point in time as RFC 3339 with an offset, such as `2026-11-27T00:00:00+01:00`.
  
  - `node` (object · required): What the shop's node needs to connect, shown only when the shop is created.
    
    - `database_role` (string · required): The Postgres role the node connects as, the shop's `database_role`.
    
    - `database_password` (string · required): The role's password; it is not kept.
    
    - `node_key` (string · required): The key the control plane sends as `Authorization: Bearer <key>` on the calls to the node's Query API only it may make; the node's settings hold it as `ORBSEARCH_NODE_KEY`. The control plane keeps it encrypted.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `422` ([problem](/docs/reference/problems#422)): The slug or the name is refused, or the slug is taken.

## Show a shop with its keys and people

`GET /api/v1/shops/{shop}`

Its keys are listed by id and age, never by their secret.

### Parameters

- `shop` (string · required)

### Answers

- `200` ([Shop](#Shop)): The shop.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop.

## Rename a shop

`PATCH /api/v1/shops/{shop}`

Only the name changes; the slug stays, since addresses and the database name it.

### Parameters

- `shop` (string · required)

### Body

A shop's new name.

- `name` (string · required): Up to 100 characters.

### Answers

- `200` ([Shop](#Shop)): The shop is renamed.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop.

- `422` ([problem](/docs/reference/problems#422)): The name is missing or too long.

## Delete a shop and everything it owns

`DELETE /api/v1/shops/{shop}`

Removes the shop's kept catalogs, its schema with its tables, its node's database role, its keys and its people's membership; people keep their accounts and their other shops. Its node can no longer connect. It cannot be undone.

### Parameters

- `shop` (string · required)

### Answers

- `200` ([Shop](#Shop)): The shop is deleted, as it was.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop.

## Give a shop another secret key

`POST /api/v1/shops/{shop}/keys`

The key works at once beside the shop's other keys, so a key rotates without downtime: issue a new one, move the shop's scripts to it, then revoke the old one. The answer is the only time the key is shown. Its name says what it is for, as the publish history shows who published; send `{}` for a key without one.

### Parameters

- `shop` (string · required)

### Body

A key to issue.

- `name` (string): What the key is for, such as `Nightly feed job`, up to 100 characters; the publish history names the key by it.

### Answers

- `201` (object): The key is issued.
  
  - `id` (integer · required)
  
  - `name` (string): What it is for, as it was issued; left out for a key issued without a name.
  
  - `key` (string · required): What the shop's scripts send as `Authorization: Bearer <key>` to the management API.
  
  - `created_at` (string · required): A point in time as RFC 3339 with an offset, such as `2026-11-27T00:00:00+01:00`.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop.

- `422` ([problem](/docs/reference/problems#422)): The name is too long.

## Revoke one of a shop's secret keys

`DELETE /api/v1/shops/{shop}/keys/{key}`

Calls with the key answer 401 from then on; the shop's other keys keep working.

### Parameters

- `shop` (string · required)

- `key` (string · required)

### Answers

- `200` ([ShopKey](#ShopKey)): The key is revoked.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop, or no such key of it.

## Show a shop's searches, entities and index runs per day

`GET /api/v1/shops/{shop}/usage`

One entry per UTC day from `from` to `to`, both included, leaving out days before the shop existed and days after today. Counts come from the search log's daily rollups and the index runs. A day is settled once it was rolled up after [`event_hours`](/docs/reference/limits#event_hours) plus 15 minutes past its end in UTC, when no search or click for it can arrive any more; the roll-up runs every minute, so a day settles within a minute of that. A settled day's numbers never change, so it can be billed once and never corrected; a day that is not settled yet may still grow.

### Parameters

- `shop` (string · required)

- `from` (string · required): The first UTC day.

- `to` (string · required): The last UTC day, at most 365 days after `from`.

### Answers

- `200` (object): The shop's usage.
  
  - `days` (array of objects · required): One UTC day of a shop's usage.
    
    - `day` (string · required): A UTC day, such as `2026-10-09`.
    
    - `settled` (boolean · required): Whether the day's numbers are final: they never change once it is settled, as `showUsage` says.
    
    - `searches` (integer · required): The first pages the Query API answered shoppers on every surface: the search page with words typed, category pages and autocomplete. Later pages of an answer, the search page without words that storefronts ask for their rails, previews, tests, benchmarks and bots are not counted.
    
    - `entities` (integer · required): The entities searchable at the day's end, products and every other type, as the index run live then counted them; 0 before the first run went live.
    
    - `index_runs` (integer · required): The index runs that finished on the day, whether they went live or failed.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop.

- `422` ([problem](/docs/reference/problems#422)): A day is missing, malformed or out of order, or the range spans more than 366 days.

## Let a person work in a shop

`POST /api/v1/shops/{shop}/users`

With an email that already has an account, that person joins the shop as they are; their name stays. Otherwise a new account is made with the name and email, marked verified, since the operator vouches for it, and without a password that anyone knows: the person signs in by a login link, or sets a password through the panel's password reset.

### Parameters

- `shop` (string · required)

### Body

A person to let into a shop.

- `name` (string · required): Up to 255 characters; kept for a new account only.

- `email` (string · required): The person's account, or a new one for it.

### Answers

- `200` ([Person](#Person)): The person was already in the shop.

- `201` ([Person](#Person)): The person joined the shop.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop.

- `422` ([problem](/docs/reference/problems#422)): The name or the email is missing or malformed.

## Take a person out of a shop

`DELETE /api/v1/shops/{shop}/users/{user}`

The person can no longer open the shop; their account and their other shops stay, and links made for this shop stop working.

### Parameters

- `shop` (string · required)

- `user` (string · required)

### Answers

- `200` ([Person](#Person)): The person is out of the shop.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop, or the person does not work in it.

## Make a link that signs a person in once and opens their shop

`POST /api/v1/shops/{shop}/users/{user}/login-link`

The link opens the panel's page that asks to continue as the person into the shop; only confirming there signs in, so a mail scanner that opens the link does not use it up. It signs in once, within 10 minutes, without a password or second factor, and lands in the shop at `/<slug>/`. A used or expired link shows that and leads to the sign-in page.

### Parameters

- `shop` (string · required)

- `user` (string · required)

### Answers

- `201` (object): The link.
  
  - `url` (string · required): On the panel's address, such as `https://app.orbsearch.dev/login-links/...`.
  
  - `expires_at` (string · required): A point in time as RFC 3339 with an offset, such as `2026-11-27T00:00:00+01:00`.

- `401` ([problem](/docs/reference/problems#401)): The operator key is missing or wrong, or the installation sets none.

- `404` ([problem](/docs/reference/problems#404)): There is no such shop, or the person does not work in it.

**Guide:** [Manage shops from a script](/docs/self-hosting#manage-shops-from-a-script)

## `Person`

A person with an account who works in a shop.

- `id` (integer · required)

- `name` (string · required)

- `email` (string · required)

## `Shop`

A shop of the installation.

- `slug` (string · required): A shop's slug, such as `acme-tires`: up to 32 lowercase letters and digits, words joined by single hyphens. It never changes, since it names the shop's database schema and role and its address, `<slug>.orbsearch.dev`.

- `name` (string · required)

- `database_role` (string · required): The Postgres role the shop's node connects as; its `search_path` is the shop's schema.

- `query_api` (string · required): Where the control plane reaches the shop's Query API.

- `keys` ([array of ShopKey](#ShopKey) · required): Oldest first.

- `people` ([array of Person](#Person) · required): The people who work in it, by name.

- `created_at` (string · required): A point in time as RFC 3339 with an offset, such as `2026-11-27T00:00:00+01:00`.

## `ShopKey`

One of a shop's secret keys, without its secret.

- `id` (integer · required)

- `name` (string): What it is for, as it was issued; left out for a key issued without a name.

- `created_at` (string · required): A point in time as RFC 3339 with an offset, such as `2026-11-27T00:00:00+01:00`.
