# Approve an agent's sign-in

`POST /api/v1/oauth/requests/{requestId}/approve`

Approves the request for a workspace, optionally one project, with read or write access and optionally fewer scopes. The agent can then sign in.

Sign-in: a dashboard session only. API tokens and OAuth sign-ins get `403 token.not_allowed`.

Section: OAuth consent. Operation id in openapi.json: `approve_oauth_request`.

## Parameters

| Name | In | Required | Type | Description |
|---|---|---|---|---|
| `requestId` | path | yes | string (uuid) | The sign-in request's id, from the consent screen's address. |

## Request body

Required: yes.

`application/json`: OAuthApproveInput

| Field | Type | Required | Description |
|---|---|---|---|
| `access` | OAuthAccess | yes |  |
| `projectId` | string (uuid) \| null | no | Confines the grant to one project of the workspace. |
| `scopes` | array of Scope \| null | no | Narrower than `access`; `:write` scopes need `access: write`. Absent: all of `access`, within what the client asked for. |
| `workspaceId` | string (uuid) | yes |  |

## Responses

Errors are `application/problem+json` (`Problem`); branch on `type`.

### 200

Where to send the browser back to the agent.

`application/json`: OAuthDecision

| Field | Type | Required | Description |
|---|---|---|---|
| `apiToken` | ApiTokenView \| null | no |  |
| `redirectUrl` | string | yes | Send the browser here: the client's redirect URI with `code` (or `error=access_denied`), `state` and `iss`. |

### 400

Bad Request.

- `request.malformed`: the body or a parameter is not of the expected shape
- `auth.credentials_conflict`: the request carries both a session cookie and a token

### 401

Unauthorized.

- `auth.unauthenticated`, `auth.session_expired`: no session, or it ended
- `token.invalid`: the token is malformed, unknown, revoked or expired, or its creator left the workspace

### 403

Forbidden.

- `auth.forbidden`: your role is too low for this
- `token.not_allowed`: this operation needs a signed-in session; tokens cannot call it
- `request.origin_mismatch`, `request.header_required`: a changing request with a session comes from another site or lacks `X-Monitorly-Request: 1`

### 404

Not Found.

- `request.not_found`: it does not exist, or you cannot see it

### 409

Conflict.

- `oauth.request_decided`: sign-in request was already approved or rejected

### 410

Gone.

- `oauth.request_expired`: MCP client sign-in request is older than 10 minutes: sign-in must be started again in the client

### 413

Payload Too Large.

- `request.too_large`: the body is larger than 256 KiB

### 422

Unprocessable Entity.

- `field.required`, `field.too_long`, `field.invalid`: a field breaks a rule; `errors` points at it

### 429

Too Many Requests.

- `session.rate_limited`: more than 5 changes a second from your sessions

Schemas named above are listed with their fields in [the schema list](https://docs.monitorly.cloud/api/reference/schemas.md).
