---
title: "Apply a spec bundle as the agent's next version"
url: https://hexelstudio.com/docs/api/harness/agents/apply-a-spec-bundle-as-the-agent-s-next-version
---

# Apply a spec bundle as the agent's next version

**POST** `/harness/agents/{name}/versions`

Creates the agent on its first apply. Applying the latest version's digest again is a
no-op (200, `created: false`). `?promote=<channel>` also points the channel at the new
version alone (needs `harness:agent:promote`). An invalid bundle is
`422 invalid_bundle` with `details.problems`.


## Query parameters

- `promote: optional string`

  A channel to point at the version (lowercase letters, digits and hyphens).

## Headers

- `Authorization: string`

  `Bearer <token>`. A Hexel Studio access token for your organization.

- `X-Workspace-Id: string`

  The workspace the request acts in (`ws_...`). It never grants access by itself.

- `X-Environment-Id: string`

  The environment the request acts in (`env_...`). It never grants access by itself.

## Body parameters

- `name: string`

- `model: string`

- `instructions: optional string`

- `tools: optional array of string`

- `skills: optional array of string`

- `budgets: optional object`

  - `max_steps: optional integer`

  - `max_tokens: optional integer`

  - `max_usd: optional number`

  - `max_wall_clock_s: optional number`

## Returns

`200` The latest version already had this bundle. (`ApplyResult`)

- `agent: Agent`

  - `channels: map[array of Target]`

  - `created_at: string`

  - `created_by: string`

  - `id: string`

  - `latest_version: integer`

  - `name: string`

  - `registry_agent_id: optional string`

- `created: boolean`

- `version: Version`

  - `agent_id: string`

  - `bundle: optional AgentBundle`

    An agent spec bundle (at most 512 KiB). `name` must match the path.

    - `name: string`

    - `model: string`

    - `instructions: optional string`

    - `tools: optional array of string`

    - `skills: optional array of string`

    - `budgets: optional object`

      - `max_steps: optional integer`

      - `max_tokens: optional integer`

      - `max_usd: optional number`

      - `max_wall_clock_s: optional number`

  - `bundle_digest: string`

  - `created_at: string`

  - `created_by: string`

  - `id: string`

  - `registry_revision_id: optional string`

  - `version: integer`

## Errors

- `default` 

## Example

```bash
curl --request POST \
  --url 'https://api.hexelstudio.com/v1/harness/agents/{name}/versions' \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header 'X-Workspace-Id: X_WORKSPACE_ID' \
  --header 'X-Environment-Id: X_ENVIRONMENT_ID' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "string",
  "model": "string",
  "instructions": "string",
  "tools": [
    "string"
  ],
  "skills": [
    "string"
  ],
  "budgets": {
    "max_steps": 0,
    "max_tokens": 0,
    "max_usd": 0,
    "max_wall_clock_s": 0
  }
}'
```

### Response (200)

```json
{
  "agent": {
    "channels": {
      "key": [
        {
          "version": 0,
          "weight": 0
        }
      ]
    },
    "created_at": "2026-01-01T00:00:00Z",
    "created_by": "string",
    "id": "string",
    "latest_version": 0,
    "name": "string",
    "registry_agent_id": "string"
  },
  "created": true,
  "version": {
    "agent_id": "string",
    "bundle": {
      "name": "string",
      "model": "string",
      "instructions": "string",
      "tools": [
        "string"
      ],
      "skills": [
        "string"
      ],
      "budgets": {
        "max_steps": 0,
        "max_tokens": 0,
        "max_usd": 0,
        "max_wall_clock_s": 0
      }
    },
    "bundle_digest": "string",
    "created_at": "2026-01-01T00:00:00Z",
    "created_by": "string",
    "id": "string",
    "registry_revision_id": "string",
    "version": 0
  }
}
```

### Response (201)

```json
{
  "agent": {
    "channels": {
      "key": [
        {
          "version": 0,
          "weight": 0
        }
      ]
    },
    "created_at": "2026-01-01T00:00:00Z",
    "created_by": "string",
    "id": "string",
    "latest_version": 0,
    "name": "string",
    "registry_agent_id": "string"
  },
  "created": true,
  "version": {
    "agent_id": "string",
    "bundle": {
      "name": "string",
      "model": "string",
      "instructions": "string",
      "tools": [
        "string"
      ],
      "skills": [
        "string"
      ],
      "budgets": {
        "max_steps": 0,
        "max_tokens": 0,
        "max_usd": 0,
        "max_wall_clock_s": 0
      }
    },
    "bundle_digest": "string",
    "created_at": "2026-01-01T00:00:00Z",
    "created_by": "string",
    "id": "string",
    "registry_revision_id": "string",
    "version": 0
  }
}
```
