# Create a group connect session

Create a hosted flow that connects one account for a whole group, through OAuth consent or API-key entry.

`POST https://api.smallworld.sh/api/v1/groups/:groupId/connect-sessions`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| groupId | path | string | Yes | Your application's group ID, URL-encoded. At most 512 characters, with no surrounding whitespace or null bytes. |
| integration | body | string | Yes | The key from GET /integrations. |
| redirectUrl | body | string \| null | No | Optional absolute URL, at most 2048 characters. HTTPS is required; HTTP is allowed only for loopback development. No credentials or fragment. |
| requireConfirmation | body | boolean | No | Defaults to false. true holds credentials until your backend confirms the session with this groupId; requires redirectUrl. |

## Request examples

### curl

```curl
curl --fail-with-body -X POST 'https://api.smallworld.sh/api/v1/groups/team_42/connect-sessions' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "integration": "github",
  "redirectUrl": "https://app.example.com/settings/integrations",
  "requireConfirmation": true
}'
```

### typescript

```typescript
const response = await fetch("https://api.smallworld.sh/api/v1/groups/team_42/connect-sessions", {
  method: "POST",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
  "integration": "github",
  "redirectUrl": "https://app.example.com/settings/integrations",
  "requireConfirmation": true
}),
});
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/groups/team_42/connect-sessions",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
  "integration": "github",
  "redirectUrl": "https://app.example.com/settings/integrations",
  "requireConfirmation": True
},
    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. Only creation returns connectUrl; store it temporarily and send the browser there.

### 201 · Pending

A new hosted attempt was created for the group. connectUrl is returned only here; navigate the browser to it.

```json
{
  "id": "01995e58-2000-7000-8000-009ea3dcd8fc",
  "integration": "github",
  "userId": null,
  "groupId": "team_42",
  "status": "pending",
  "requireConfirmation": true,
  "redirectUrl": "https://app.example.com/settings/integrations",
  "error": null,
  "connection": null,
  "expiresAt": "2026-10-10T12:30:00.000Z",
  "createdAt": "2026-10-10T12:00:00.000Z",
  "updatedAt": "2026-10-10T12:00:00.000Z",
  "completedAt": null,
  "connectUrl": "https://api.example.com/api/integrations/connect/one-time-example-token"
}
```

### 400

invalid_request: A parameter or the body is invalid; the message names the problem. Unknown body fields are rejected. integration_invalid_provider: The integration key does not identify an available integration. integration_connection_not_supported: Built-in integrations have authScheme none and do not need a connection. integration_setup_required: An added MCP server needs its setup verified before anyone can connect. The message says what is missing.

#### invalid_request

A parameter or the body is invalid; the message names the problem. Unknown body fields are rejected.

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

#### integration_invalid_provider

The integration key does not identify an available integration.

```json
{
  "statusCode": 400,
  "code": "integration_invalid_provider",
  "message": "Unsupported integration provider 'acme'"
}
```

#### integration_connection_not_supported

Built-in integrations have authScheme none and do not need a connection.

```json
{
  "statusCode": 400,
  "code": "integration_connection_not_supported",
  "message": "Web Access is built in and available without a connection; there is nothing to connect"
}
```

#### integration_setup_required

An added MCP server needs its setup verified before anyone can connect. The message says what is missing.

```json
{
  "statusCode": 400,
  "code": "integration_setup_required",
  "message": "This server requires your own OAuth app. Enter its client ID and, if required by the provider, its client secret."
}
```

### 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

group_not_found: The group does not exist in your workspace. Create groups from your backend with POST /groups.

#### group_not_found

The group does not exist in your workspace. Create groups from your backend with POST /groups.

```json
{
  "statusCode": 404,
  "code": "group_not_found",
  "message": "Group not found"
}
```

### 409

integration_disabled: Enable the integration in your workspace before connecting it. integration_setup_required: Complete the integration setup before connecting it.

#### integration_disabled

Enable the integration in your workspace before connecting it.

```json
{
  "statusCode": 409,
  "code": "integration_disabled",
  "message": "GitHub is not enabled for this workspace. Add it under Integrations first."
}
```

#### integration_setup_required

Complete the integration setup before connecting it.

```json
{
  "statusCode": 409,
  "code": "integration_setup_required",
  "message": "Complete the integration setup before users can connect it"
}
```

### 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

- The group must already exist. Check that the person signed in to your application may connect accounts for this group before you create the session, and again before you confirm it.

- The hosted API-key form names the group, such as Connect GitHub for Support team, and says that everyone in the group can use the account. A group without a name is called your team. OAuth continues to the provider's consent screen.

- When the flow completes, the account is the group's. Members without a connection of their own use it in every World that allows the integration; members with their own connection keep using theirs.

- A new session cancels earlier pending attempts for this group and integration with connect_session_superseded. Members' own attempts are not affected.

- Redirect query parameters (connectSessionId, status, and possible error) are hints. Read the session from your backend before relying on them.

- Sessions expire after 30 minutes by default. Use the returned expiresAt. With requireConfirmation, the session waits at awaiting_confirmation before credentials become active.
