---
title: "Allocate a new Agent VM"
url: https://hexelstudio.com/docs/api/compute/vms/allocate
---

# Allocate a new Agent VM

**POST** `/compute/v1/vms/allocate`

Allocates a VM from the pool or creates a new one for the requesting org

## Headers

- `Authorization: string`

  `Bearer <token>`. STS access token. Obtain via POST https://sts.hexelstudio.com/token with X-API-Key header.

## Body parameters

- `env: optional map[string]`

- `metadata: optional map[string]`

- `org_id: optional string`

- `secure_runtime: optional string`

- `skills: optional array of string`

- `tier: string`

- `ttl_seconds: optional integer`

## Returns

`201` Created (`AllocateResponse`)

- `endpoint: optional string`

- `expires_at: optional string`

- `skills_loaded: optional array of string`

- `state: optional string`

- `tier: optional string`

- `token: optional string`

- `vm_id: optional string`

- `ws_url: optional string`

## Errors

- `400` Bad Request
- `503` No VMs available, retry shortly

## Example

```bash
curl --request POST \
  --url 'https://compute.hexelstudio.com/compute/v1/vms/allocate' \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
  "env": {
    "key": "string"
  },
  "metadata": {
    "key": "string"
  },
  "org_id": "string",
  "secure_runtime": "string",
  "skills": [
    "string"
  ],
  "tier": "string",
  "ttl_seconds": 0
}'
```

### Response (201)

```json
{
  "endpoint": "string",
  "expires_at": "2026-01-01T00:00:00Z",
  "skills_loaded": [
    "string"
  ],
  "state": "string",
  "tier": "string",
  "token": "string",
  "vm_id": "string",
  "ws_url": "string"
}
```

### Response (400)

```json
{
  "code": 0,
  "error_code": "string",
  "message": "string"
}
```

### Response (503)

```json
{
  "code": 0,
  "error_code": "string",
  "message": "string"
}
```
