# Confirm a connect session

Activate credentials held by a session created with requireConfirmation: true.

`POST https://api.smallworld.sh/api/v1/connect-sessions/:id/confirm`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| id | path | UUID | Yes | The connect-session ID returned when the session was created. |
| userId | body | string | No | For a user's session: the user authenticated in your application after the browser returns. Must match the user used to create the session. Send userId or groupId, not both. |
| groupId | body | string | No | For a group's session: the group the signed-in person connected the account for, after your backend checked their authority over it. Must match the session's group. |

## Request examples

### curl

```curl
curl --fail-with-body -X POST 'https://api.smallworld.sh/api/v1/connect-sessions/01995e58-1000-7000-8000-009ea3dcd8fc/confirm' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "userId": "customer_123"
}'
```

### typescript

```typescript
const response = await fetch("https://api.smallworld.sh/api/v1/connect-sessions/01995e58-1000-7000-8000-009ea3dcd8fc/confirm", {
  method: "POST",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
  "userId": "customer_123"
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();
```

### python

```python
response = requests.post(
    "https://api.smallworld.sh/api/v1/connect-sessions/01995e58-1000-7000-8000-009ea3dcd8fc/confirm",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
  "userId": "customer_123"
},
    timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Responses

Returns id, integration, userId, groupId, status, requireConfirmation, nullable redirectUrl/error/connection, expiresAt, createdAt, updatedAt, and nullable completedAt. Exactly one of userId and groupId is set: your user's ID, or your group's ID for a group's session. Status is pending, awaiting_confirmation, completed, failed, expired, or cancelled. A completed connection uses the public connection shape.

### 200 · Completed

Held credentials were activated for the authenticated user. Other session states return errors.

```json
{
  "id": "01995e58-1000-7000-8000-009ea3dcd8fc",
  "integration": "github",
  "userId": "customer_123",
  "groupId": null,
  "status": "completed",
  "requireConfirmation": true,
  "redirectUrl": "https://app.example.com/settings/integrations",
  "error": null,
  "connection": {
    "integration": "github",
    "userId": "customer_123",
    "groupId": null,
    "source": "personal",
    "overridesGroup": false,
    "authScheme": "api_key",
    "status": "connected",
    "accountId": "123456",
    "accountName": "octocat",
    "workspaceId": null,
    "connectedAt": "2026-10-10T12:00:01.000Z",
    "updatedAt": "2026-10-10T12:00:01.000Z",
    "error": null
  },
  "expiresAt": "2026-10-10T12:30:00.000Z",
  "createdAt": "2026-10-10T12:00:00.000Z",
  "updatedAt": "2026-10-10T12:00:01.000Z",
  "completedAt": "2026-10-10T12:00:01.000Z"
}
```

### 400

invalid_request: The body is invalid, such as both or neither of userId and groupId, or an unknown field; the message names the problem.

#### invalid_request

The body is invalid, such as both or neither of userId and groupId, or an unknown field; the message names the problem.

```json
{
  "statusCode": 400,
  "code": "invalid_request",
  "message": "Unknown field: color"
}
```

### 401

authentication_required: The Authorization header is missing or empty. invalid_api_key: The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

#### authentication_required

The Authorization header is missing or empty.

```json
{
  "statusCode": 401,
  "code": "authentication_required",
  "message": "Authentication is required"
}
```

#### invalid_api_key

The API key is invalid or revoked, or the header doesn't use the Bearer scheme.

```json
{
  "statusCode": 401,
  "code": "invalid_api_key",
  "message": "The API key is invalid or revoked"
}
```

### 403

ip_not_allowed: The request came from an address outside the workspace's IP allowlist.

#### ip_not_allowed

The request came from an address outside the workspace's IP allowlist.

```json
{
  "statusCode": 403,
  "code": "ip_not_allowed",
  "message": "The source IP address is not allowed by this account's security settings"
}
```

### 404

connect_session_not_found: The connect session does not exist in your workspace.

#### connect_session_not_found

The connect session does not exist in your workspace.

```json
{
  "statusCode": 404,
  "code": "connect_session_not_found",
  "message": "Connect session not found"
}
```

### 409

connect_session_not_awaiting_confirmation: The session is not waiting for confirmation, including when it is already completed. connect_session_user_mismatch: The session is a user's, and the confirmation named another user or a group; held credentials were discarded. connect_session_group_mismatch: The session is a group's, and the confirmation named another group or a user; held credentials were discarded.

#### connect_session_not_awaiting_confirmation

The session is not waiting for confirmation, including when it is already completed.

```json
{
  "statusCode": 409,
  "code": "connect_session_not_awaiting_confirmation",
  "message": "The connect session is completed, not awaiting confirmation"
}
```

#### connect_session_user_mismatch

The session is a user's, and the confirmation named another user or a group; held credentials were discarded.

```json
{
  "statusCode": 409,
  "code": "connect_session_user_mismatch",
  "message": "The connect session belongs to a different user. The credentials were discarded."
}
```

#### connect_session_group_mismatch

The session is a group's, and the confirmation named another group or a user; held credentials were discarded.

```json
{
  "statusCode": 409,
  "code": "connect_session_group_mismatch",
  "message": "The connect session belongs to a different group. The credentials were discarded."
}
```

### 410

connect_session_expired: The session expired before confirmation.

#### connect_session_expired

The session expired before confirmation.

```json
{
  "statusCode": 410,
  "code": "connect_session_expired",
  "message": "The connect session expired before it was confirmed"
}
```

### 413

request_too_large: The JSON body is larger than 12 MiB. File uploads count toward it, base64 or escaping included.

#### request_too_large

The JSON body is larger than 12 MiB. File uploads count toward it, base64 or escaping included.

```json
{
  "statusCode": 413,
  "code": "request_too_large",
  "message": "The request body is larger than 12 MiB."
}
```

### 415

unsupported_media_type: The request has a body that isn't JSON. Send JSON with Content-Type: application/json, or no body at all.

#### unsupported_media_type

The request has a body that isn't JSON. Send JSON with Content-Type: application/json, or no body at all.

```json
{
  "statusCode": 415,
  "code": "unsupported_media_type",
  "message": "Send the request body as JSON with Content-Type: application/json."
}
```

### 500

internal_error: An unexpected server error.

#### internal_error

An unexpected server error.

```json
{
  "statusCode": 500,
  "code": "internal_error",
  "message": "Internal server error"
}
```

## Notes

- Only confirm a session whose status is awaiting_confirmation. Derive userId from your server-side login session.

- For a group's session, send groupId once your backend has checked that the signed-in person may connect accounts for that group. The completed connection is the group's.

- A different user or group, or a userId for a group's session, fails the connection attempt and discards the held credentials. Repeated confirmation of a completed session returns a conflict.
