Skip to content
Using the APId7a6d83 · docs: requests

Requests

The rules every request follows, from JSON bodies and paths to pages and idempotency keys.

The base URL is https://api.cubecen.com. Requests and answers are JSON. Send Content-Type: application/json with a body: any other type is refused with 415, and a body over 1 MiB with 413. Every request needs an API key.

Paths

Paths name things by ID or by slug. The organization, the project and the cube each take either one:

Text
/v1/organizations/<org>/projects/<project>/applications/<cube>/builds

The reference prints these as {org}, {project} and {cube}. The path says applications where the dashboard says cubes. IDs are opaque strings: an ID such as a build's bld_… is not something to take apart.

A slug can change. After you change the slug of a project or a cube, paths with the old slug stop working. Use the ID in paths that you keep.

Sending a body

Send only the fields an operation lists. The requests that create or change a cube, start a build or make a deployment refuse a field they don't know, with 400. A change takes only the fields to change, and a field you leave out stays as it is.

Pages

A list of many things comes a page at a time. Most take limit, from 1 to 100, and cursor; the repositories of one GitHub connection take page and per_page. Send the next_cursor of one page as the cursor of the next, with the same filters. The last page has no cursor to send. A cursor that doesn't belong to the list is refused with 400.

Not every list is built the same way:

ListA page holdsTo get the next page
Projects, cubesitems, and next_cursor when there is moreSend next_cursor as cursor
Releases, variable versions, GitHub repositoriesdata, and next_cursor, null on the last pageSend next_cursor as cursor
Organizationsdata and afterAlways one page for a key: after is null
Repositories of one GitHub connectiondata, total_count and next_page, null on the last pageSend next_page as page
Builds, deployments, custom domains, previews, GitHub connectionsEverything, in dataNot paged

limit defaults to 20 for most lists, 25 for organizations and 30 for the repositories of all GitHub connections. per_page defaults to 30. The reference shows each list's fields.

Idempotency keys

An Idempotency-Key header makes a retry safe. Send any value that is unique to the action, such as a UUID, from 1 to 255 visible ASCII characters. Send the same value again if a request fails on the way: you get the first answer, and the work isn't done twice. When the first request had already finished, the answer carries Idempotent-Replayed: true.

Shell
-H "Idempotency-Key: $(uuidgen)"

Four requests need the header, because they start work: create a cube, start a build, create a deployment and add a custom domain. Changing a cube's variables and restoring a version of them take it when you send it: a retry with the same value gets the first answer. Other requests that change something accept it but ignore it; their reference says what a repeat does.

Use a new value for every new action. The same value with a different body is refused with 409 and IDEMPOTENCY_KEY_REUSED. A request that was refused for what it asks, such as with BUILD_IN_PROGRESS or PLAN_LIMIT_REACHED, keeps getting that answer for the same value. To try again, use a new value.

Work that takes time

Starting a build or a deployment answers 202 Accepted. The work goes on after the answer, and the Location header gives the path to follow. Read it every 3 to 5 seconds until it is done: a build says so with terminal: true, a deployment with a status of SUCCEEDED, FAILED or CANCELLED. Polling at that pace stays well under the rate limit.