# Register an agent as an OAuth client

> Register an agent as an OAuth client: CustomDomain™ API reference in the agents group. Covers request parameters, the request body, responses and error codes.

Source: https://docs.customdomain.ai/docs/api-reference/agents/registerAgentClient

## `POST https://api.customdomain.ai/v1/oauth/agent/register`

Dynamic Client Registration (RFC 7591). An AI assistant registers itself as a public client (PKCE, no secret) and can do nothing until a person approves a grant for it in the console. Registration is open on purpose, so it is bounded: a per-IP hourly budget on top of the global limit, and a client that nobody ever approves into a workspace is deleted after a while. Other client metadata (`client_uri`, `logo_uri`, `scope`, `contacts`, ...) is accepted and ignored. A `client_name` that claims a well known brand (Claude, ChatGPT, ...) is refused unless every redirect host belongs to that brand or is a loopback address. Errors use the RFC 7591 envelope.

### Authentication

None.

### Request body (JSON)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `client_name` | string | yes | Shown to the person who approves the agent. At most 100 characters, with no control or invisible characters and no Latin letters mixed with look-alike letters from another alphabet. A name that claims a well known brand is refused unless every redirect host belongs to that brand or is a loopback address. |
| `redirect_uris` | array of string | yes | Where the authorization code may be sent. `https`, or `http` on a loopback host (`localhost`, `127.0.0.1`, `::1`) for a program on the person's own computer. No fragment and no user information. A redirect URI is matched exactly later, except for the port of a loopback one. |
| `grant_types` | array of string | no | Optional. When sent it must include `authorization_code`; other values are ignored. The client is registered for `authorization_code` and `refresh_token`. |
| `response_types` | array of string | no | Optional. When sent it must include `code`. |
| `token_endpoint_auth_method` | string | no | Ignored. Every agent client is a public client (`none`) and PKCE protects its code. |

### Responses

| Status | Description |
| --- | --- |
| `201` | The registered client |
| `400` | `invalid_client_metadata` (a bad or impersonating name, grant or response types without the authorization code grant) or `invalid_redirect_uri` (none, more than 10, a fragment, user information, or http on a host that is not loopback). |
| `429` | Error envelope: {code, title, details}. |
| `503` | Error envelope: {code, title, details}. |

### `201` response body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `client_id` | string | yes | Starts with `agc_`. |
| `client_id_issued_at` | integer | yes | Unix time of the registration. |
| `client_name` | string | yes |  |
| `redirect_uris` | array of string | yes | The registered URIs, normalized. |
| `token_endpoint_auth_method` | `none` | yes |  |
| `grant_types` | array of string | yes |  |
| `response_types` | array of string | yes |  |

The full specification is served at `GET https://api.customdomain.ai/v1/openapi.json`.
