# Issue a key

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

`POST /v1/admin/keys`

Issue a gateway key for a principal, from an admin key. The raw key is in the answer once.

## Authentication

Workspace key, admin scope. A gateway key issued with the `admin` scope, sent as `Authorization: Bearer`. An inference-scoped key gets `403` here.

## Request

curl:

```bash
curl -X POST "https://immiscible.fly.dev/v1/admin/keys" \
  -H "authorization: Bearer $IMMISCIBLE_ADMIN_KEY" \
  -H "content-type: application/json" \
  -d '{
    "principalId": "prp_21b7",
    "teamId": "team_platform",
    "taskClassId": "code.feature",
    "label": "CI",
    "scope": "inference"
  }'
```

Node:

```ts
const res = await fetch('https://immiscible.fly.dev/v1/admin/keys', {
  method: 'POST',
  headers: {
    authorization: `Bearer ${process.env.IMMISCIBLE_ADMIN_KEY}`,
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    principalId: 'prp_21b7',
    teamId: 'team_platform',
    taskClassId: 'code.feature',
    label: 'CI',
    scope: 'inference',
  }),
});
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/keys",
    headers={
        "authorization": f"Bearer {os.environ['IMMISCIBLE_ADMIN_KEY']}",
        "content-type": "application/json",
    },
    json={
        "principalId": "prp_21b7",
        "teamId": "team_platform",
        "taskClassId": "code.feature",
        "label": "CI",
        "scope": "inference",
    },
)
print(res.status_code, res.json())
```

## Response

```json
{ "key": "ask_...", "binding": { "id": "key_5d1e9b", "prefix": "ask_5d1e", "scope": "inference", "principalId": "prp_21b7", "teamId": "team_platform", "taskClassId": "code.feature" } }
```
