---
title: "Connect domains with the account"
method: POST
path: "/provider-accounts/{id}/connect"
tags: ["Provider accounts"]
---

# Connect domains with the account

`POST /provider-accounts/{id}/connect`

## Request

- Base URL: `https://api.customdomain.ai/v1`
- URL: `https://api.customdomain.ai/v1/provider-accounts/{id}/connect`
- Auth: HTTP bearer

Creates a connection for each domain under the application and writes its records with the account's key (keeping the CAA and TXT values already there and recording what each write replaced). Each domain is linked to the account; a continuous account then keeps them in sync. A domain the application already serves is only linked. A one time account deletes its key once the domains are connected, even when the caller has gone away by then, and past its hour answers `409`. A domain in a zone the key does not reach fails alone (`zone_not_reached` on the connection); the account is flagged `needs_reconnect` only when the provider refuses the key itself, which is checked with a request that does not depend on the zone. Takes an admin, an owner or the member who connected the account.

## Path parameters

- `id` string, required

## Request body

- object
  - `application_id` string, required
  - `domains` string[], required
  - `www_redirect` boolean

## Response `200`

Per domain results and the account

- object
  - `results` object[]
    - `domain` string
    - `connection_id` string
    - `status` 'connected' | 'already' | 'failed'
    - `message` string
  - `account` ProviderAccount
    - `id` string, required
    - `kind` 'api_key', required
    - `provider` string, required
    - `provider_name` string, required
    - `label` string, required
    - `access` 'continuous' | 'one_time', required
    - `scope` 'all' | 'selected', required
    - `domains` string[], required: The selected zones (scope `selected`).
    - `credential_held` boolean, required: Whether the key is still kept and usable (false for a one time account past its hour). The key itself is never returned.
    - `status` 'active' | 'used' | 'expired' | 'needs_reconnect', required
    - `last_error` string
    - `created_by` string
    - `last_used_at` string, date-time
    - `expires_at` string, date-time: When a one time account's key is deleted at the latest.
    - `created_at` string, date-time, required
    - `updated_at` string, date-time
    - `connections` AccountConnection[], required
      - `id` string
      - `application_id` string
      - `domain` string
      - `status` string
    - `uses` string[], required: What the account's access is used for.
    - `can_manage` boolean, required: Whether the caller may change the account's access, scope or domains, connect domains with it and replace its key: an admin, an owner, or the member who connected it.

## Other responses

- `400`: Error envelope: {code, title, details}.
- `401`: Error envelope: {code, title, details}.
- `403`: Error envelope: {code, title, details}.
- `404`: Error envelope: {code, title, details}.
- `409`: Error envelope: {code, title, details}.
- `503`: Error envelope: {code, title, details}.

---

[API](https://skmtc.dev/customdomain/apis/customdomain-control-plane-api.md) · [All operations](https://skmtc.dev/customdomain/apis/customdomain-control-plane-api/llms.txt) · [OpenAPI document](https://skmtc.dev/customdomain/apis/customdomain-control-plane-api/revisions/34d89cb7a7cd?raw)
