Skip to content
Get started6d47da8 · docs: quickstart

Quickstart

Make an API key, create a cube, start a build and follow it until it's live.

This page deploys a cube with the API: make a key, create a cube, start a build and follow it. You need a Cubecen account and a public GitHub repository. A cube made from a public repository doesn't need a GitHub connection.

The examples use curl. Replace <org> with your organization's slug.

Make an API key

In the dashboard, open Settings → API keys and make a key with Full access. A Read-only key can't create or deploy anything. The key starts with cbc_ and is shown only once, so copy it now. Keep it like a password.

Put it in an environment variable. In CI, store it as a secret.

Shell
export CUBECEN_API_KEY="cbc_..."

More on keys, their lifetimes and their limits is under Authentication.

Find your organization

Paths name your organization by its slug or its ID. List organizations to find them. A key belongs to one organization, so the list has one entry. It also shows that your key works.

Shell
curl -sS "https://api.cubecen.com/v1/organizations" \
  -H "Authorization: Bearer $CUBECEN_API_KEY"

The answer holds your organization in data, with its slug and its default_project_id.

Create a cube

Create a cube in a project. Organizations made at sign-in have a project called default; use its slug here, or the slug of another project. An older organization may not have one called default: list your projects to see yours.

Creating a cube needs an Idempotency-Key header: any value that is unique to this request, such as a UUID. If a retry carries the same key, Cubecen doesn't create a second cube.

Shell
curl -sS -X POST "https://api.cubecen.com/v1/organizations/<org>/projects/default/applications" \
  -H "Authorization: Bearer $CUBECEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"name": "Web", "slug": "web",
       "repository": {"url": "https://github.com/acme/storefront"}}'

Use the link to a public repository of your own. The answer is 201 with the cube, in state active. A pushed commit doesn't deploy a cube made from a public link, so you start each deploy with a build, as in the next step.

Now and then the answer is 202: the cube is still creating, and Cubecen finishes setting it up on its own. Read the cube every few seconds until its state is active or failed. If it is failed, its failure_code says why; if it is active, go on. If the answer is 402 with PLAN_LIMIT_REACHED, your plan has no room for another cube.

Start a build

Start a build with "deploy": true, so Cubecen deploys it when it succeeds. Without a revision, it builds the branch the cube deploys from, or the repository's default branch.

Shell
curl -sS -X POST "https://api.cubecen.com/v1/organizations/<org>/projects/default/applications/web/builds" \
  -H "Authorization: Bearer $CUBECEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"deploy": true}'

The answer is 202 with the build. It is usually QUEUED. Note its id:

JSON
{
  "id": "bld_00000001a0fdd794980f85f9c353bf",
  "revision": "main",
  "status": "QUEUED",
  "release_status": "QUEUED",
  "terminal": false
}

Follow the build

Get the build every 3 to 5 seconds until terminal is true.

Shell
curl -sS "https://api.cubecen.com/v1/organizations/<org>/projects/default/applications/web/builds/<build-id>" \
  -H "Authorization: Bearer $CUBECEN_API_KEY"

release_status says where the release is. While it is QUEUED, BUILDING, DEPLOYING or UNKNOWN (a status the API doesn't describe yet), keep polling. These are final:

  • DEPLOYED: live at public_url.
  • BUILT: built without deploying. It can be deployed later.
  • BUILD_FAILED and DEPLOY_FAILED: error says why.
  • CANCELLED: it was cancelled.
  • SUPERSEDED: it was built, but a newer build was deployed instead.

When it is DEPLOYED, the cube is live at public_url:

JSON
{
  "id": "bld_00000001a0fdd794980f85f9c353bf",
  "release_status": "DEPLOYED",
  "terminal": true,
  "public_url": "https://web-acme-3f9a2c.cubecen.app"
}

If the build or the deployment fails, error says why. A failed deployment leaves the version before it serving.

Next steps

  • Put the two calls from the last steps in your CI: start a build, then poll it. Builds shows the options, such as revision and reuse.
  • Read Requests for the rules every request follows, and Errors for what to do when one fails.
  • To go back to an earlier version, create a deployment from an earlier build.