# Create daemon

> Source: https://truto.one/docs/api-reference/admin/daemons/create/

`POST /daemon`

Resource: **Daemons**

## Request body

- **`label`** _(string)_
- **`group_key`** _(string)_
- **`metadata`** _(object)_
- **`environment_id`** _(string)_
  Ignored for API tokens.

## Response body

- **`id`** _(string)_
  The ID of the daemon.
- **`environment_id`** _(string)_
  The environment the daemon belongs to.
- **`label`** _(string)_
  A name for the daemon.
- **`status`** _(string)_
  The daemon's status. A new daemon starts as `stopped`; your daemon process updates it.
  Allowed: `stopped`, `active`, `stopping`, `starting`
- **`group_key`** _(string)_
  The daemon group this daemon belongs to. Runs created with a `daemon_group_key` go to a daemon in that group.
- **`metadata`** _(object)_
  Any JSON object you want to store with the daemon.
- **`last_active_at`** _(string)_
  When the daemon was last active.
- **`lock`** _(string)_
  A value your daemon process can set, for example to claim the daemon. Stored as sent.
- **`created_at`** _(string)_
- **`updated_at`** _(string)_

## Code examples

### curl

```bash
curl -X POST 'https://api.truto.one/daemon' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "label": "worker-1",
  "group_key": "default",
  "metadata": {},
  "environment_id": "your_environment_id"
}'
```

### JavaScript

```javascript
const body = {
  "label": "worker-1",
  "group_key": "default",
  "metadata": {},
  "environment_id": "your_environment_id"
};

const response = await fetch('https://api.truto.one/daemon', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/daemon"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "label": "worker-1",
    "group_key": "default",
    "metadata": {},
    "environment_id": "your_environment_id"
}

response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())
```
