Using the API
Everything the Studio does, it does through the same API. You can use it from your own scripts. Every route is listed, with its inputs and outputs, in the API reference, which is generated from the API itself so it cannot drift from it.
The API description file
Section titled “The API description file”The API is described in a standard OpenAPI file. You can download it and load it into your own tools to generate a client:
Signing your requests
Section titled “Signing your requests”A request is allowed by one of two things. Both resolve to a member of an organisation with a set of permissions.
- A session cookie, which is what the Studio uses in your browser.
- An API token, which is what a script uses. Create one under Settings, API tokens, then send it as a bearer token:
GET /api/projects HTTP/1.1Host: <the product's address>Authorization: Bearer <your token>Treat a token like a password: keep it out of code you share, and revoke it if it leaks. See Members, roles and API tokens.
A request is refused if the token’s permissions do not cover it. Each route in the reference names the permission it needs.
Changes carry an idempotency key
Section titled “Changes carry an idempotency key”Any request that changes something should carry an Idempotency-Key header, a unique value you
make up for that attempt:
POST /api/projects HTTP/1.1Authorization: Bearer <your token>Idempotency-Key: <a unique value for this attempt>Content-Type: application/jsonIf your connection drops and you send the same request again with the same key, the change is made only once. Use a new key for a new change.
Errors
Section titled “Errors”When a request fails, the answer has one shape:
{ "error": { "code": "…", "message": "…", "details": {} } }code is a short word you can test for, message is for people, and details is present when
there is more to say.
Limits
Section titled “Limits”Use of the API is rate limited, and every use of a token is recorded. If you are slowed down, wait and retry with a growing delay, and keep the same idempotency key when you retry a change.