Cosmoner Docs
SDKs

Apps

Deploy an image app onto a new tag or digest and wait for the rollout to finish — the step a CI job runs after pushing an image.

client.apps deploys image apps: apps that run an image from a Cosmoner container registry. Apps built from a repository deploy by pushing to their branch, and the API refuses to deploy them this way.

Listing apps and reading deployments needs apps:read. Starting a deployment needs apps:write.

Deploy and wait

const { data: apps } = await client.apps.list();
const web = apps.find((app) => app.name === "web");
if (!web) throw new Error("No app named web");

const { data: started } = await client.apps.deploy(web.id, { tag: "v2" });

const finished = await client.apps.waitForDeployment(web.id, started.id, {
  onPoll: (d) => console.log(d.phase),
});

if (finished.phase !== "ACTIVE") {
  throw new Error(finished.error ?? `Deployment ended ${finished.phase}`);
}

In a CI pipeline, cosmoner deploy does the same in one line, with no code to maintain.

deploy(appId, ...)

Starts a deployment and returns it straight away, without waiting.

ParameterDescription
tagDeploy this tag from the repository the app pulls from. A commit SHA pushed as a tag goes here.
digestDeploy this exact image: sha256: followed by 64 hex characters.
projectIdOverrides the client's project.

Pass tag or digest, not both. Pass neither to pull the image the app already names again — useful when a tag such as latest has been pushed over.

waitForDeployment(appId, deploymentId, ...)

Polls the deployment until it finishes, then returns it. wait_for_deployment in Python.

ParameterDefaultDescription
interval3 secondsTime between polls.
timeout10 minutesHow long to wait in total.
onPoll—Called with the deployment after every poll, including the last.
projectId—Overrides the client's project.

interval and timeout are in milliseconds in JavaScript and seconds in Python and PHP.

It returns for every finished phase, successful or not, so check phase yourself:

PhaseMeaning
ACTIVEThe new image is live.
ERRORThe rollout failed. error says why.
CANCELEDThe deployment was cancelled.
SUPERSEDEDA newer deployment replaced it before it finished.

It raises only when a request fails or timeout passes. A timeout stops the wait, not the deployment — the rollout carries on, and you can pick it up again with getDeployment.

Other methods

MethodDescription
list()Every app in the project, newest first.
getDeployment(appId, deploymentId)One deployment in its current phase — a single poll. get_deployment in Python.

A deployment carries its phase, the imageRef and imageDigest it deployed, an error when it failed, and its startedAt and finishedAt times.

On this page