API rules
The rules that every Operation follows, and what to do for each error code.
Call the API with a machine token
The Release Management API gives machines (TrackPlan and the agent) read access to the catalog of Release Management at Ovokacho. The API only reads: it never writes to Release Management.
Every call carries the M2M token of the machine from Clerk in the Authorization: Bearer header. The machine must be listed in MACHINES. A response with HTTP 401 has the WWW-Authenticate: Bearer header. The Consumer checks people before it calls the API.
Send the Cabinet Boundary with every call
Send the x-cabinets header with every call of an Operation: Cabinet slugs or Cabinet Keys cabinet:<slug> separated by commas, at most 250. * means the whole catalog. The Consumer decides the list. It never sends an empty list: when a person has no Cabinets, the Consumer does not call the API and reports the missing access itself.
A missing header, more than 250 elements or an invalid element returns invalid_input.
The API treats data outside the Cabinet Boundary as unknown: a response contains only data of the Cabinets inside it. If the key parameter names a Release outside the Cabinet Boundary, release returns not_found. Keys and ISRCs outside the Cabinet Boundary come back in missing, and a Selection by a Cabinet outside the Cabinet Boundary gives an empty Window.
A cursor does not carry the Cabinet Boundary: the API applies the Cabinet Boundary again on every Page.
Call an Operation with GET and query parameters
Call an Operation with GET /api/v1/<name> and pass its input as query parameters. Repeat a parameter to pass an array, for example ?dsp=yandex-music&dsp=zvuk: a comma is part of the value, not a separator. The x-cabinets header is the exception, because HTTP joins repeated headers with commas.
The input is strict: an unknown parameter returns invalid_input. A response may contain new fields and new enum values. Ignore the ones that you do not know.
An empty Window and a search with no candidates are not errors: the API returns HTTP 200.
Every response has the Cache-Control: private, no-store and X-Content-Type-Options: nosniff headers. The API only reads, so a response with HTTP 405 has the Allow: GET, HEAD header.
Name an item by its Key from a response
Name an item by the key from a previous response. The API does not accept internal database identifiers.
Only search accepts words. It returns candidates with key, the kind of match in match and the score in score, and the Consumer chooses among them.
A Key is opaque and stays valid for all of v1: the same key in a later call returns the same item without a new search. An unknown key in release returns not_found with details.key.
Read a Window Page by Page
Read a Window Page by Page: send limit and cursor, and take nextCursor from the response. A response without nextCursor is the last Page of the Window.
Discard saved Windows when ruleVersion changes
Every response has copyVersion, ruleVersion and dataAsOf: the Copy Version, the version of the rules that the API applies to build Windows, and the moment as of which the Catalog Copy is correct. The x-copy-version and x-rule-version headers repeat copyVersion and ruleVersion of an Operation response.
When ruleVersion changes, the Windows you saved are out of date: discard them and read them again. Use ruleVersion as the version of any cache that you persist.
A deprecated Operation is marked deprecated, its description starts with "Deprecated: use … instead.", and its responses have the Deprecation header (RFC 9745).
Choose the language of labels with Accept-Language
A response contains labels for people: the labels of statuses, stages, Attention reasons and territory sets, the names of fields and the texts of issues in the metadata, and the names of DSPs. The labels come in the language that the Accept-Language header asks for (RFC 9110): en or ru. The API picks the supported language with the highest q weight, ignoring case, and ru-RU counts as ru. If the header is missing or names no supported language, the labels are in English: this is not an error.
The Content-Language header names the language of the response, and the Vary: Accept-Language header tells caches to keep responses in different languages apart. Make decisions by codes, not by labels: next to each label is a fixed code, such as status.code, attention.code, the field and code of an issue, or dsp. A label repeats the wording of the Release Management interface in the same language. Release Management has no English interface yet, so the API writes the English labels itself.
Texts for developers do not depend on Accept-Language: the descriptions in the contract, title, detail and errors[].message are always in English. An error response and /api/v1/openapi.json therefore have Content-Language: en. Catalog data comes as is, without translation: titles, names, genres, the names of Labels, the values of Release Management enums and the letters of letter.
The language is not part of a Selection or a cursor: a cursor from a response in one language continues the Window in another. A label is part of the response, so ruleVersion also changes when a label in any language changes. Keep a separate persisted cache for each language, with ruleVersion as its version.
Distinguish errors by code
An error is application/problem+json (RFC 9457) with the fields type, title, status, detail and instance and the extensions code, requestId, retryable, errors and details. Distinguish errors by code: each code has its own section below.
type is https://docs.rm-api.ovkch.com/rules#<code>, a link to the section for the code. detail says what happened in this request and what to do next. instance is this occurrence of the error: the requestId as a URN. retryable says whether you may retry the same request. errors lists the issues with input fields in invalid_input errors, and details holds the Key in a not_found error for a Key.
Every response has the x-request-id header: the number of the request in the API log, the same as requestId in an error. If the request has a valid traceparent header, the response returns it as it came, and the API writes its trace-id to its log.
invalid_input
The input failed validation (HTTP 422, retryable: false). Fix the fields listed in errors and send the request again.
unauthorized
The token was not accepted (HTTP 401, retryable: false). Get a new M2M token for the machine and send the request again.
forbidden
The machine is not allowed (HTTP 403, retryable: false). Do not retry the request. The machine is not listed in MACHINES, or the scopes of its token do not include the API machine.
not_found
The path or the Key was not found (HTTP 404, retryable: false). If the response has details.key, the Catalog Copy has no item with that Key: find the item again with search. Otherwise the path does not exist: Operations are available at /api/v1/<name>, and /api/v1/openapi.json lists them.
method_not_allowed
The method is not allowed (HTTP 405, retryable: false). Send the request again with GET or HEAD: the API only reads, and the Allow header lists these methods.
rate_limited
The machine made too many calls (HTTP 429, retryable: true). Wait for the number of seconds in Retry-After, which is the time until the machine's next allowed call, and send the request again.
timeout
The request did not finish in time (HTTP 504, retryable: false). The API did not retry the request. Narrow it with a shorter period, a smaller limit or fewer Parts in include, and send it again: the same request will most likely exceed 5 s again.
unavailable
The Catalog Copy is unavailable (HTTP 503, retryable: true). Wait for the number of seconds in Retry-After and retry the request once. The connection to the Catalog Copy was lost, or the database is overloaded or starting after a pause, and the API has already retried once.
internal
The API failed with an internal error (HTTP 500, retryable: false). Do not retry the request: the API did not retry it, and the same request will fail the same way. Report the requestId.
Retry only errors with retryable: true
One rule covers retries on two layers. The API retries a database statement once when the connection is lost, the database is starting after a pause or the database is short of resources, if at least 1 s is left before the request deadline. Otherwise the API returns unavailable.
Retry only an error with retryable: true, and only once, after the number of seconds in the Retry-After header. Do not retry timeout and internal.
Stay within the rate limit and the request deadline
A machine may make at most 3,000 calls per minute. Above the limit, the API returns rate_limited, and Retry-After holds the number of seconds until the next allowed call.
A request may take at most 5 s, and a database statement at most 3 s. If a request does not finish in time, the API returns timeout. Set your own call timeout to more than 5 s, so that a timeout comes as an API response.
The Server-Timing header gives the timings of request phases in milliseconds: auth, db and total.