# Register an agent

Source: https://immiscible.fly.dev/docs/api/post-api-w-wid-agents

`POST /api/w/:wid/agents`

Register an agent and choose who it acts for (members may only register agents that act for themselves). It starts at the workspace's starting tier. Issue its key with [`POST .../agents/:aid/keys`](https://immiscible.fly.dev/docs/api/post-api-w-wid-agents-aid-keys.md).

| Field | Description |
|---|---|
| `name` | how people recognise it, for example "Expenses bot" |
| `vendor` | `anthropic`, `openai`, `google`, `meta` or `custom` |
| `principalId` | the principal it acts for; defaults to the caller's own |

## Authentication

Session cookie. A signed-in person: the console's session cookie. Every state-changing request also carries the header `x-immiscible-csrf: 1`, and the member's role decides what it may do. Bearer tokens are ignored on these routes, so no machine credential can reach them.

## Path parameters

- `wid` (string, required): Workspace id

## Request

curl:

```bash
curl -X POST "https://immiscible.fly.dev/api/w/$IMMISCIBLE_WORKSPACE/agents" \
  -H "cookie: __Host-sid=$IMMISCIBLE_SESSION" \
  -H "x-immiscible-csrf: 1" \
  -H "content-type: application/json" \
  -d '{
    "name": "Invoice bot",
    "vendor": "anthropic",
    "principalId": "prp_21b7"
  }'
```

Node:

```ts
const res = await fetch('https://immiscible.fly.dev/api/w/$IMMISCIBLE_WORKSPACE/agents', {
  method: 'POST',
  headers: {
    cookie: `__Host-sid=${process.env.IMMISCIBLE_SESSION}`,
    'x-immiscible-csrf': '1',
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Invoice bot',
    vendor: 'anthropic',
    principalId: 'prp_21b7',
  }),
});
const data = await res.json();
console.log(res.status, data);
```

Python:

```python
import os
import requests

res = requests.post(
    "https://immiscible.fly.dev/api/w/$IMMISCIBLE_WORKSPACE/agents",
    headers={
        "cookie": f"__Host-sid={os.environ['IMMISCIBLE_SESSION']}",
        "x-immiscible-csrf": "1",
        "content-type": "application/json",
    },
    json={
        "name": "Invoice bot",
        "vendor": "anthropic",
        "principalId": "prp_21b7",
    },
)
print(res.status_code, res.json())
```
