# Save group API-key credentials

Validate and save API-key credentials your backend collected for a group.

`POST https://api.smallworld.sh/api/v1/groups/:groupId/connections/:integration`

## 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 | path | string | Yes | An integration key from GET /integrations, such as github or notion. |
| credentials | body | object | Yes | String values keyed by the integration's credentialFields names. Each value is at most 4096 characters; provider-specific rules also apply. |

## Request examples

### curl

```curl
curl --fail-with-body -X POST 'https://api.smallworld.sh/api/v1/groups/team_42/connections/github' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "credentials": {
    "token": "YOUR_GROUP_GITHUB_TOKEN"
  }
}'
```

### typescript

```typescript
const response = await fetch("https://api.smallworld.sh/api/v1/groups/team_42/connections/github", {
  method: "POST",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
  "credentials": {
    "token": "YOUR_GROUP_GITHUB_TOKEN"
  }
}),
});
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/connections/github",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
  "credentials": {
    "token": "YOUR_GROUP_GITHUB_TOKEN"
  }
},
    timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Responses

Returns the shape of a user's connection with userId null: integration, groupId, source (group, or null when not connected), overridesGroup (always false), authScheme, status (connected, needs_reauth, or not_connected), and nullable accountId, accountName, workspaceId, connectedAt, updatedAt, and error. Credentials are never returned.

### 200 · Connected

The group's own account, which members without a connection of their own use. Secret credential values are never returned.

```json
{
  "integration": "github",
  "userId": null,
  "groupId": "team_42",
  "source": "group",
  "overridesGroup": false,
  "authScheme": "api_key",
  "status": "connected",
  "accountId": "654321",
  "accountName": "support-bot",
  "workspaceId": null,
  "connectedAt": "2026-10-10T12:00:01.000Z",
  "updatedAt": "2026-10-10T12:00:01.000Z",
  "error": null
}
```

### 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. integration_credentials_not_supported: This integration uses OAuth; create a group connect session instead. integration_credentials_invalid: Credential fields are invalid or the provider rejected them.

#### 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."
}
```

#### integration_credentials_not_supported

This integration uses OAuth; create a group connect session instead.

```json
{
  "statusCode": 400,
  "code": "integration_credentials_not_supported",
  "message": "GitHub connects through OAuth. Create a connect session instead."
}
```

#### integration_credentials_invalid

Credential fields are invalid or the provider rejected them.

```json
{
  "statusCode": 400,
  "code": "integration_credentials_invalid",
  "message": "GitHub did not accept these credentials"
}
```

### 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"
}
```

### 502

integration_provider_unavailable: The provider could not be reached to verify credentials.

#### integration_provider_unavailable

The provider could not be reached to verify credentials.

```json
{
  "statusCode": 502,
  "code": "integration_provider_unavailable",
  "message": "GitHub could not be reached to check these credentials"
}
```

## Notes

- Fetch /integrations to discover the actual credential fields. This endpoint supports api_key, not oauth2 or none.

- Smallworld checks the credentials with the provider before storing them encrypted, once for the whole group. The group must already exist; reconnecting replaces the group's credentials.

- Members without a connection of their own use the account from their next tool call. Members with their own connection keep using theirs.
