# Register an agent from a blueprint

Source: https://immiscible.fly.dev/docs/api/post-v1-admin-agents

`POST /v1/admin/agents`

`agents:write`. Everything an agent needs on day one, all or nothing, so the hundredth agent is onboarded as code. The person it acts for is named by email and must be a member. The agent starts at the workspace's starting tier; a token cannot set a tier, cannot name a sponsor or kill owner (people do that in the console), and attaches mandates **from templates only**.

## Authentication

Service token. A scoped machine token (`ims_...`) made by an owner or admin under Settings, sent as `Authorization: Bearer`. Each route needs one scope; tokens expire within 90 days and can be pinned to address ranges. A token can stop agents but never start them, and never decides an approval.

## Request

curl:

```bash
curl -X POST "https://immiscible.fly.dev/v1/admin/agents" \
  -H "authorization: Bearer $IMMISCIBLE_SERVICE_TOKEN" \
  -H "content-type: application/json" \
  -d '{
    "name": "Invoice bot",
    "vendor": "custom",
    "principalEmail": "dev@acme.example",
    "purpose": "Pays approved supplier invoices",
    "assignmentEndsAt": "2027-01-31T00:00:00Z",
    "mandates": [
      {
        "template": "subscriptions"
      }
    ]
  }'
```

Node:

```ts
const res = await fetch('https://immiscible.fly.dev/v1/admin/agents', {
  method: 'POST',
  headers: {
    authorization: `Bearer ${process.env.IMMISCIBLE_SERVICE_TOKEN}`,
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Invoice bot',
    vendor: 'custom',
    principalEmail: 'dev@acme.example',
    purpose: 'Pays approved supplier invoices',
    assignmentEndsAt: '2027-01-31T00:00:00Z',
    mandates: [
      {
        template: 'subscriptions',
      },
    ],
  }),
});
const data = await res.json();
console.log(res.status, data);
```

Python:

```python
import os
import requests

res = requests.post(
    "https://immiscible.fly.dev/v1/admin/agents",
    headers={
        "authorization": f"Bearer {os.environ['IMMISCIBLE_SERVICE_TOKEN']}",
        "content-type": "application/json",
    },
    json={
        "name": "Invoice bot",
        "vendor": "custom",
        "principalEmail": "dev@acme.example",
        "purpose": "Pays approved supplier invoices",
        "assignmentEndsAt": "2027-01-31T00:00:00Z",
        "mandates": [
            {
                "template": "subscriptions",
            },
        ],
    },
)
print(res.status_code, res.json())
```
