
# Activate a connection

`POST /v1/connections/{connection_id}:activate` · permission `connections:write`

Sets the connection `status` to `active`. The request body is optional and has no fields. The operation is idempotent: if the connection already has this status nothing is written, the version is unchanged and the current connection is returned. `If-Match` is not used; if another writer changes the connection at the same moment the call is retried a few times. Activating an `enterprise` (SAML or OIDC) connection requires a successful test sign-in in the last 24 hours that covered the current protocol configuration and the `allowed_email_domains` the connection will have; otherwise the call returns `409 connection_test_required` and nothing is written. If the check cannot be made, the connection is not activated and the call returns `503`. Other connection types are not checked.

## Request

| Field | Type | Required | Description |
|---|---|---|---|
| `connection_id` | string | yes | Connection identifier (`conn_…`). |
| `Idempotency-Key` | header | no | Optional key (16-64 characters) that makes a retried request safe. |

The body is optional; if present it must be `{}`.

## Response

`200 OK` with the connection and its `ETag`.

```json
{
  "id": "conn_0k3v8m1q2x9dz4h7s5t6w0y1ab",
  "key": "google",
  "type": "social",
  "strategy": "google",
  "name": "Google",
  "display_name": "Sign in with Google",
  "status": "active",
  "org_id": null,
  "allowed_email_domains": [],
  "allow_external_domains": false,
  "jit_mode": null,
  "email_trust": null,
  "default_role_ids": [],
  "trust_idp_mfa": null,
  "allow_idp_initiated": null,
  "idp_initiated_default_application_id": null,
  "idp_initiated_allowed_application_ids": [],
  "settings": {},
  "created_at": "2026-10-05T09:30:00.123456Z",
  "updated_at": "2026-10-05T09:30:00.123456Z"
}
```

## Errors

| HTTP | code | When |
|---|---|---|
| 400 | `unknown_field` | The body contains a field. |
| 404 | `not_found` | The connection does not exist or belongs to another environment. |
| 409 | `connection_test_required` | An `enterprise` connection has no successful test of its current configuration in the last 24 hours. Run a test sign-in, then retry. |
| 412 | `precondition_failed` | The connection kept changing concurrently; retry. |
| 401 | `unauthenticated` | The credential is missing, invalid or revoked. |
| 403 | `insufficient_permissions` | The credential lacks the required permission. |
| 429 | `rate_limited` | The rate limit was exceeded; retry after the `Retry-After` period. |
| 503 | `service_unavailable` | A dependency is temporarily unavailable; retry after the `Retry-After` period. |

## Example

```bash
curl -X POST https://api.eu.keenauth.com/v1/connections/conn_0k3v8m1q2x9dz4h7s5t6w0y1ab:activate \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY"
```
