deployments

Retrieve the build output of a deployment as a list of log entries, in the order the build printed them. A log entry is one chunk of build output, and can contain several lines or part of a line.

Poll this endpoint to follow a running build:

  • Send the pagination.cursor of the last response as cursor. The response contains only the entries after it.
  • When hasMore is true, request again now.
  • When hasMore is false, you have all entries so far. Wait, then request again with the same cursor.
  • The cursor is absent only when the request had no cursor and the build has no entries yet.
  • A response can contain fewer than limit entries and still have hasMore: true when the entries are large.

New entries become visible up to a few seconds after the build prints them. To know that a build is done, check the deployment status with getDeployment. After the status is no longer building, request until you get an empty response at least 5 seconds later.

When a build attempt is retried, an entry from the earlier attempt can arrive after the cursor has moved past it, and a poll does not return it. A request without a cursor returns it. A deployment from a prebuilt image has no build and returns no entries. Build logs are kept for 3 months.

Required Permissions

Your root key must have the following permission:

  • unkey:v1:<workspace_id>:projects/<project_id>/apps/<app_id>/environments/<environment_id>/deployments/<deployment_id>/buildLogs#read
post/v2/deployments.listBuildLogs

Request

  • Base URL
    https://api.unkey.com
  • URL
    https://api.unkey.com/v2/deployments.listBuildLogs
  • Auth
    HTTP bearer

Request body

deploymentIdstring required

Identifies a resource by either its unique ID or its slug. Accepts a prefixed ID (such as 'proj_' or 'app_') or a slug.

stepIdstring

Return only the log entries of this build step. Use the stepId of an entry from a previous response. An unknown step returns no entries. Omit this field to return the entries of every step.

cursorstring

Pagination cursor from a previous response to fetch the entries after it. Omit it to start at the first entry of the build.

limitinteger

Maximum number of log entries to return. A response can contain fewer entries and still have hasMore: true when the entries are large.

Example request

{
  "deploymentId": "proj_1234abcd",
  "stepId": "sha256:3f9c2b7e1d4a6f8c0b5e9d2a7c4f1e8b3d6a9c2f5e8b1d4a7c0f3e6b9d2a5c8f",
  "cursor": "1704067201000001"
}

Response

Successfully retrieved the build log entries.

Example response

{
  "meta": {
    "requestId": "req_123"
  },
  "data": [
    {
      "time": 1704067201000,
      "stepId": "sha256:3f9c2b7e1d4a6f8c0b5e9d2a7c4f1e8b3d6a9c2f5e8b1d4a7c0f3e6b9d2a5c8f",
      "step": "[3/7] RUN npm ci",
      "output": "stdout",
      "message": "added 412 packages in 12s\n"
    }
  ],
  "pagination": {
    "cursor": "eyJrZXkiOiJrZXlfMTIzNCIsInRzIjoxNjk5Mzc4ODAwfQ==",
    "hasMore": true
  }
}

Changes