# Agent

Mint an agent token, list the tools available to a caller, and run them over REST. The agent operates the course lifecycle — create, edit, publish, share, analyse, translate, narrate, and organise courses. For MCP-speaking clients, see [Embed MCP](/embed-mcp).

<a id="mint-token"></a>

## Mint an agent token

Create a bearer token the agent acts with. Authenticate with your workspace API key. The token encodes the end-user identity, an optional tenant key, an optional tool allowlist, an optional course pin, and a read-only flag. Default lifetime is 4 hours and the maximum is 24 hours; a longer `expiresIn` returns 400. Tokens are read-only unless you pass `readonly: false`.

POST `/api/v1/agent/auth`

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `identifier` | `string` | Yes | Your stable end-user identifier the agent acts as. | — |
| `clientIdentifier` | `string` | No | Tenant key (omit for workspace-default scope). | — |
| `tools` | `string[]` | No | Per-token tool allowlist; omit for the full read surface. | — |
| `courseId` | `number` | No | Pin the token to a single course. | — |
| `expiresIn` | `string \| number` | No | Lifetime as \<n>h\|m\|s, for example 4h, 90m or 3600s; default 4h, maximum 24h. Malformed, zero or longer values return 400. | — |
| `readonly` | `boolean` | No | Omitted or true = read-only. Pass false for write access. | — |

#### Examples

**cURL request**

```bash
curl --request POST \
  --url "https://api.coassemble.com/api/v1/agent/auth" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "identifier": "user_123",
    "clientIdentifier": "client_123",
    "tools": [
        "example"
    ],
    "courseId": 1234
}'
```

#### Response

**JSON response**

```json
{
  "token": "example",
  "expiresAt": "example"
}
```

<a id="list-tools"></a>

## List tools

List the tools the caller may run. Authenticate with the agent token (Bearer) or your workspace API key.

GET `/api/v1/agent/tools`

#### Query parameters

| Field | Type | Required | Default | Description | Options |
| --- | --- | --- | --- | --- | --- |
| `identifier` | `string` | No | — | Optional stable user identifier for workspace API key calls, with bearer calls using the identity in the agent token. | — |
| `clientIdentifier` | `string` | No | — | Optional client identifier string for workspace API key calls, with bearer calls using the client in the agent token. | — |
| `courseId` | `string` | No | — | Optional course ID as a numeric string to scope the tool list, with a course pinned by the agent token taking precedence. | — |

#### Examples

**cURL request**

```bash
curl --request GET \
  --url "https://api.coassemble.com/api/v1/agent/tools?identifier=user_123&clientIdentifier=client_123&courseId=1234" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY"
```

#### Response

**JSON response**

```json
{
  "tools": [
    {
      "name": "example",
      "description": "example"
    }
  ]
}
```

<a id="run-tool"></a>

## Run a tool

Execute a tool by name with its arguments. Authenticate with the agent token (Bearer) or your workspace API key.

POST `/api/v1/agent/tools/{name}`

#### Path parameters

| Field | Description | Options |
| --- | --- | --- |
| `name` | Exact tool name string returned by \`GET /v1/agent/tools\`. | — |

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `args` | `object` | No | Optional JSON object matching the tool input schema, defaulting to \`{}\`. | — |
| `courseId` | `number` | No | Optional numeric course ID to scope the tool call, with a course pinned by the agent token taking precedence. | — |
| `identifier` | `string` | No | Optional stable user identifier for workspace API key calls, with bearer calls using the identity in the agent token. | — |
| `clientIdentifier` | `string` | No | Optional client identifier string for workspace API key calls, with bearer calls using the client in the agent token. | — |

#### Examples

**cURL request**

```bash
curl --request POST \
  --url "https://api.coassemble.com/api/v1/agent/tools/example" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "args": {
        "key": "value"
    },
    "courseId": 1234,
    "identifier": "user_123",
    "clientIdentifier": "client_123"
}'
```

#### Response

**JSON response**

```json
{
  "name": "example"
}
```
