First call
Get a machine token, send the Cabinet Boundary, call an Operation, read the next Page and name an item by its Key.
This page makes one call of each kind. Each section links to the rule that it follows.
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.
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 describes the token.
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 describes the limits and what the API returns for data outside the Cabinet Boundary.
Call an Operation
An Operation is GET /api/v1/<name>, and its input is query parameters:
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 describes arrays and unknown parameters.
Read the next Page
Send the same request with cursor set to the nextCursor of the previous Page:
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 says.
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:
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 describes what happens with an unknown Key. To find an item by words, call search.
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.