
# Replace an application's connections

`PUT /v1/applications/{application_id}/connections` · permissions `applications:write` and `connections:write`

Replaces the whole list of connections enabled on the application in one step. The order of `connection_ids` is the order of the buttons on the hosted login page; an empty list disables every connection. Each connection must exist in the same environment: a connection of another environment is treated like one that does not exist (`422` at `/connection_ids`) and nothing is written. Sending the list the application already has changes nothing and keeps the version. The change is written to the management audit log as `application.updated` and published as an `application_changed` event; removing a connection takes effect at the next sign-in.

## Request

**Headers**: `If-Match: "<version>"` (optional). With `If-Match` the list is only written if the application is still at that version (`412` otherwise); without it the list is written whatever the version is. Send an `Idempotency-Key` header to make retries safe.

| Parameter | In | Required | Description |
|---|---|---|---|
| `application_id` | path | yes | Application id, prefixed `app_`. |

**Body**

| Field | Type | Required | Description |
|---|---|---|---|
| `connection_ids` | array of string | yes | Connection ids (`conn_…`), unique, at most 100, in button order. |

## Response

`200 OK` with the application and its new `ETag`.

## Errors

Every error is an `application/problem+json` body with a stable `code`.

| HTTP | `code` | When |
|---|---|---|
| 400 | `malformed_request`, `unknown_field` | The body is not valid JSON or has an unknown field. |
| 401 | `unauthenticated` | The API key is missing, invalid or revoked. |
| 403 | `insufficient_permissions` | The key lacks `applications:write` or `connections:write`. |
| 404 | `not_found` | The application does not exist in this environment (or the id is malformed). |
| 412 | `precondition_failed` | The version in `If-Match` is stale. |
| 422 | `validation_failed` | `connection_ids` is missing, has more than 100 items, a malformed or repeated id, or a connection that is not in this environment. |
| 429 | `rate_limited` | The rate limit was exceeded; honor `Retry-After`. |
| 503 | `service_unavailable` | A dependency is temporarily unavailable; retry later. |

## Example

```bash
curl -X PUT https://api.eu.keenauth.com/v1/applications/app_6f8d0cjgbmf0gtn2rg6pscp3cg/connections \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"connection_ids":["conn_01h455vb4pex5vsknk084sn02q"]}'
```

CLI: `keenauth applications put-connections app_6f8d0cjgbmf0gtn2rg6pscp3cg --connection-ids conn_01h455vb4pex5vsknk084sn02q` (to disable every connection, send `{"connection_ids":[]}` with `--data -`)
