## List container image builds

**get** `/v5/builds`

List container image build records for the caller's account as a paginated collection.

Each entry is one individual build with its current lifecycle status; pass `agent_name`,
`source_commit`, or `working_tree_hash` to return only matching builds. Archived builds are
excluded, and results are limited to builds the caller is permitted to read. Use this to
enumerate individual builds; to instead list agents that have been built but not yet
deployed, use `GET /v5/builds/undeployed`.

### Query Parameters

- `agent_name: optional string`

  Filter builds by agent name

- `ending_before: optional string`

- `limit: optional number`

- `sort_by: optional string`

- `sort_order: optional SortOrder`

  - `"asc"`

  - `"desc"`

- `source_commit: optional string`

  Filter builds by source git commit

- `starting_after: optional string`

- `working_tree_hash: optional string`

  Filter builds by build-context content hash

### Returns

- `has_more: boolean`

  Whether there are more items left to be fetched.

- `items: array of AgentexCloudBuild`

  - `id: string`

    The unique identifier of the entity.

  - `account_id: string`

    The ID of the account that owns the given entity.

  - `agent_name: string`

    The name of the agent that this build belongs to

  - `build_status: "queued" or "running" or "success" or 8 more`

    The current build lifecycle status

    - `"queued"`

    - `"running"`

    - `"success"`

    - `"failed"`

    - `"cancelling"`

    - `"cancelled"`

    - `"deleting"`

    - `"delete_failed"`

    - `"timed_out"`

    - `"error"`

    - `"unknown"`

  - `cloud_provider_build_id: string`

    The unique identifier of the build from the cloud provider, or an internal UUID when an existing image is copied without a provider build.

  - `created_at: string`

    The date and time when the entity was created in ISO format.

  - `created_by: Identity`

    The identity that created the entity.

    - `id: string`

    - `type: "user" or "service_account"`

      - `"user"`

      - `"service_account"`

    - `object: optional "identity"`

      - `"identity"`

  - `image_name: string`

    The name of the container image to build.

  - `image_tag: string`

    The tag for the container image.

  - `source_commit: string`

    Git commit the build context was at, when a git work tree.

  - `source_dirty: boolean`

    Whether the work tree had uncommitted changes at build time (null outside git).

  - `source_ref: string`

    Git branch or tag for source_commit, when resolvable.

  - `source_repo: string`

    Normalized git remote the build context came from (host/path, no credentials).

  - `source_subpath: string`

    Build-context path relative to the repo root (which agent, in a monorepo).

  - `working_tree_hash: string`

    Deterministic SHA-256 content hash of the build inputs (not the tarball).

  - `agent_id: optional string`

    The UUID of the agent that this build belongs to

  - `build_end_time: optional string`

    When the cloud provider finished the build

  - `build_start_time: optional string`

    When the cloud provider started the build

  - `image_url: optional string`

    The URL of the container image. This is not guaranteed to be present until the build is complete.

  - `object: optional "agentex_cloud_build"`

    - `"agentex_cloud_build"`

- `total: number`

  The total of items that match the query. This is greater than or equal to the number of items returned.

- `limit: optional number`

  The maximum number of items to return.

- `object: optional "list"`

  - `"list"`

### Example

```http
curl https://api.egp.scale.com/v5/builds \
    -H "x-api-key: $SGP_API_KEY"
```

#### Response

```json
{
  "has_more": true,
  "items": [
    {
      "id": "id",
      "account_id": "account_id",
      "agent_name": "agent_name",
      "build_status": "queued",
      "cloud_provider_build_id": "cloud_provider_build_id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "created_by": {
        "id": "id",
        "type": "user",
        "object": "identity"
      },
      "image_name": "image_name",
      "image_tag": "image_tag",
      "source_commit": "source_commit",
      "source_dirty": true,
      "source_ref": "source_ref",
      "source_repo": "source_repo",
      "source_subpath": "source_subpath",
      "working_tree_hash": "working_tree_hash",
      "agent_id": "agent_id",
      "build_end_time": "2019-12-27T18:11:19.117Z",
      "build_start_time": "2019-12-27T18:11:19.117Z",
      "image_url": "image_url",
      "object": "agentex_cloud_build"
    }
  ],
  "total": 0,
  "limit": 0,
  "object": "list"
}
```
