# First call (/quickstart)

This page makes one call of each kind. Each section links to the rule that it follows.

## Get an M2M token for your machine [#get-an-m2m-token-for-your-machine]

The API accepts only an M2M JWT of a machine from Clerk, and the machine must be listed in `MACHINES` of the API. Create the token with the secret of your machine. One token serves the whole process for 24 hours.

```ts title="token.ts"
import { createClerkClient } from '@clerk/backend'

const clerk = createClerkClient({ machineSecretKey: process.env.CLERK_MACHINE_SECRET_KEY })
const { token } = await clerk.m2m.createToken({ tokenFormat: 'jwt', secondsUntilExpiration: 86_400 })
```

The API does not accept opaque tokens, so pass `tokenFormat: 'jwt'`. The [access rule](/rules#call-the-api-with-a-machine-token) describes the token.

## Send the Cabinet Boundary [#send-the-cabinet-boundary]

Every call of an Operation carries the `x-cabinets` header: the slugs of the Cabinets that the person behind the call may see, separated by commas. `*` means the whole catalog, for machine reads without a person. Your service decides the list. If the list is empty, do not call the API.

The [Cabinet Boundary rule](/rules#send-the-cabinet-boundary-with-every-call) describes the limits and what the API returns for data outside the Cabinet Boundary.

## Call an Operation [#call-an-operation]

An Operation is `GET /api/v1/<name>`, and its input is query parameters:

```bash
curl -s "https://rm-api.ovkch.com/api/v1/cabinets?limit=5" \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-cabinets: label-one,label-two"
```

The response is a Page: the rows are in `items`, and `nextCursor` is present while the Window goes on. The [address rule](/rules#call-an-operation-with-get-and-query-parameters) describes arrays and unknown parameters.

## Read the next Page [#read-the-next-page]

Send the same request with `cursor` set to the `nextCursor` of the previous Page:

```bash
curl -s "https://rm-api.ovkch.com/api/v1/cabinets?limit=5&cursor=$NEXT_CURSOR" \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-cabinets: label-one,label-two"
```

A response without `nextCursor` is the last Page, as the [Page rule](/rules#read-a-window-page-by-page) says.

## Name an item by its Key [#name-an-item-by-its-key]

The `key` of an item from a response names that item in the next call, without a new search:

```bash
curl -s "https://rm-api.ovkch.com/api/v1/release?key=release:c0000000-0000-0000-0000-000000000001&include=delivery" \
  -H "Authorization: Bearer $TOKEN" \
  -H "x-cabinets: label-one"
```

The [Key rule](/rules#name-an-item-by-its-key-from-a-response) describes what happens with an unknown Key. To find an item by words, call [`search`](/search/search).

## Handle an error by its code [#handle-an-error-by-its-code]

An error comes as `application/problem+json`. Read its `code` and follow the section for that code on the [rules page](/rules#distinguish-errors-by-code).