# Update integration configuration

Activate an integration, choose its authentication mode, assign Worlds, or update tool defaults.

`PATCH https://api.smallworld.sh/api/v1/integrations/:integration/configuration`

## Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| integration | path | string | Yes | An integration key from GET /integrations or /integration-configurations. |
| enabled | body | boolean | No | Workspace activation. Omitting it preserves activation. |
| authScheme | body | string | No | oauth2 or api_key, from the supported authSchemes. Omitting it preserves the selected scheme. |
| worldIds | body | UUID[] | No | Complete replacement of assigned Worlds. Omit to preserve assignments; [] removes them all. Duplicate IDs are rejected. |
| toolPolicies | body | object[] | No | Atomic tool-default updates, up to 256 entries. Each entry has toolName and policy (allow, ask, or deny). Omitted tools keep their defaults; [] changes none. |

## Request examples

### curl

```curl
curl --fail-with-body -X PATCH 'https://api.smallworld.sh/api/v1/integrations/notion/configuration' \
  -H "Authorization: Bearer $SMALLWORLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "enabled": true,
  "worldIds": [
    "01995e56-e2d4-7f19-b691-7bf9af6abdc8"
  ],
  "toolPolicies": [
    {
      "toolName": "search",
      "policy": "ask"
    }
  ]
}'
```

### typescript

```typescript
const response = await fetch("https://api.smallworld.sh/api/v1/integrations/notion/configuration", {
  method: "PATCH",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
  "enabled": true,
  "worldIds": [
    "01995e56-e2d4-7f19-b691-7bf9af6abdc8"
  ],
  "toolPolicies": [
    {
      "toolName": "search",
      "policy": "ask"
    }
  ]
}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const result = await response.json();
```

### python

```python
response = requests.patch(
    "https://api.smallworld.sh/api/v1/integrations/notion/configuration",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
  "enabled": True,
  "worldIds": ["01995e56-e2d4-7f19-b691-7bf9af6abdc8"],
  "toolPolicies": [{
    "toolName": "search",
    "policy": "ask"
  }]
},
    timeout=30,
)
response.raise_for_status()
result = response.json()
```

## Responses

Returns workspace configuration, assigned worldIds, supported authentication schemes, tool catalog and defaults, optional runtime capabilities, and setup state. Lists are not paginated. World IDs represent assignment, even while workspace activation is off. The existing GET /integrations connection catalog keeps its original response.

### 200

Returns workspace configuration, assigned worldIds, supported authentication schemes, tool catalog and defaults, optional runtime capabilities, and setup state. Lists are not paginated. World IDs represent assignment, even while workspace activation is off. The existing GET /integrations connection catalog keeps its original response.

```json
{
  "integration": "notion",
  "name": "Notion",
  "description": "Connect Notion workspaces.",
  "enabled": true,
  "configured": true,
  "hasBeenActivated": true,
  "kind": "connected",
  "removable": true,
  "authScheme": "oauth2",
  "authSchemes": [
    "oauth2"
  ],
  "worldIds": [
    "01995e56-e2d4-7f19-b691-7bf9af6abdc8"
  ],
  "tools": [],
  "defaultPolicies": [],
  "setupMessage": null,
  "requiresSetup": true,
  "toolAvailabilityNote": null
}
```

### 400

invalid_request: A path or request body is invalid. Unknown fields are rejected. integration_invalid_provider: The integration key is unknown in this workspace. integration_always_enabled: This built-in integration is always active on every World. integration_auth_scheme_not_supported: The integration does not support this connection method. integration_setup_required: Complete provider or MCP setup before enabling the integration.

#### invalid_request

A path or request body is invalid. Unknown fields are rejected.

```json
{
  "statusCode": 400,
  "code": "invalid_request",
  "message": "The request is invalid"
}
```

#### integration_invalid_provider

The integration key is unknown in this workspace.

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

#### integration_always_enabled

This built-in integration is always active on every World.

```json
{
  "statusCode": 400,
  "code": "integration_always_enabled",
  "message": "Notion is always active on every World and cannot be removed or switched off"
}
```

#### integration_auth_scheme_not_supported

The integration does not support this connection method.

```json
{
  "statusCode": 400,
  "code": "integration_auth_scheme_not_supported",
  "message": "Notion does not support api_key connections"
}
```

#### integration_setup_required

Complete provider or MCP setup before enabling the integration.

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

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

world_not_found: The World does not exist in this workspace.

#### world_not_found

The World does not exist in this workspace.

```json
{
  "statusCode": 404,
  "code": "world_not_found",
  "message": "World not found"
}
```

### 409

integration_auth_scheme_change_not_allowed: The current active OAuth setup cannot switch back to API-key connections.

#### integration_auth_scheme_change_not_allowed

The current active OAuth setup cannot switch back to API-key connections.

```json
{
  "statusCode": 409,
  "code": "integration_auth_scheme_change_not_allowed",
  "message": "Notion already uses your OAuth app. The connection method can't be changed back to personal access tokens."
}
```

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

- Activation, authentication mode, World assignment, and the tool-default batch are saved in one transaction. A rejected field or unknown World saves nothing.

- Workspace activation and World assignment are separate: enabling the workspace alone does not assign a World. Disabling an integration prevents its tools from running.

- Always-enabled integrations cannot be turned off or assigned to a replacement World list. They remain active on every World.

- deny hides a tool and prevents lower-level overrides from making it available. ask requires approval. allow permits execution.

- The selected authentication scheme follows the same setup and transition rules as the dashboard. Existing connected accounts retain their credentials.
