> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cbpayapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom domains for KYC/KYB links

> Serve hosted KYC and KYB verification links from your company domain with automatic DNS and TLS verification

Same API on both environments — build against test first, then go live by swapping the base URL and the key. [Environments and testing →](https://docs.cbpayapp.com/en/environment-testing.md)

## What this does

An active company account can use one verified subdomain for hosted KYC/KYB links. The custom host replaces only the host in a link; the brand and product style are frozen with the invite when the link is created. This lets you send a link such as `https://verify.acme.example/...` without moving the verification flow or exposing provider-specific infrastructure.

The feature is self-serve for the company owner in the portal at **Settings → Styles → Custom domain** (`/settings/styles`). The same account owner can manage it through the API.

> [!NOTE]
>
> Use a subdomain that you control, such as `verify.acme.example`. An apex domain is not supported because verification requires a CNAME and most DNS providers do not allow CNAME records at the apex. IP addresses, private hostnames, and domains under CBPay-owned suffixes are not supported.

## Lifecycle

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
stateDiagram-v2
    [*] --> pending: POST /v1/account/verify-domains
    pending --> active: TXT + DNS-only CNAME pass
    active --> active: TLS probe succeeds
    active --> suspended: DNS check fails
    suspended --> active: TXT + CNAME pass again
    active --> [*]: DELETE domain
    suspended --> [*]: DELETE domain
```

`status` describes DNS ownership and routing:

| Status | `tls_status` | Meaning | What to do |
| - | - | - | - |
| `pending` | `pending` | The domain was registered but DNS has not passed yet. | Add both records and call `verify`. |
| `active` | `pending` | TXT and CNAME passed; certificate provisioning is in progress. | Wait for the TLS agent and call `GET` again. |
| `active` | `active` | DNS and HTTPS are ready. | New KYC/KYB links use the custom host. |
| `suspended` | `pending` | A hard DNS check failed. | Correct DNS and call `verify` again. Links use the canonical host while suspended. |
| `active` | `failed` | TLS could not be issued or served. | Automatic issuance retries; correct TLS/DNS and call `verify` again. |

## Configure DNS

**1. Register the subdomain**

Send the company owner's credential:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://api.qbank.cl/platform/v1/account/verify-domains \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"domain":"verify.acme.example"}'
```

The `201` response includes the exact target and TXT token:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "vd_3f2b1a09",
  "domain": "verify.acme.example",
  "status": "pending",
  "tls_status": "pending",
  "instructions": {
    "cname_target": "custom-verify.cbpayapp.com",
    "cname_host": "verify.acme.example",
    "txt_host": "_cbpay-verify.verify.acme.example",
    "txt_value": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
    "note": "Point the CNAME (DNS-only, no proxy) and publish the TXT, then call verify. Propagation may take a few minutes."
  },
  "hint": "add the DNS records, wait for propagation, then call verify"
}
```

**2. Publish both DNS records**

Create exactly these records at your DNS provider:

| Type | Name | Target/value | Important |
| - | - | - | - |
| CNAME | `verify.acme.example` | The returned `cname_target` | DNS-only; do not proxy it. |
| TXT | `_cbpay-verify.verify.acme.example` | The returned `txt_value` | Keep the complete token. |

A DNS provider may display the name without the zone suffix. Confirm the resulting fully qualified names before verifying.

**3. Verify ownership and routing**

Call the verification endpoint. It always returns `200` with independent `txt` and `cname` results when DNS was reachable:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://api.qbank.cl/platform/v1/account/verify-domains/vd_3f2b1a09/verify \
  -H "Authorization: Bearer <token>"
```

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "vd_3f2b1a09",
  "domain": "verify.acme.example",
  "status": "active",
  "tls_status": "pending",
  "checks": {
    "txt": {"ok": true, "detail": "token found"},
    "cname": {"ok": true, "detail": "points to origin"}
  },
  "hint": "domain verified; TLS is being provisioned"
}
```

**4. Wait for HTTPS and confirm**

TLS is provisioned automatically. The platform marks `tls_status: active` only after a real HTTPS probe succeeds; a certificate report alone is not enough.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl https://api.qbank.cl/platform/v1/account/verify-domains \
  -H "Authorization: Bearer <token>"
```

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "domains": [{
    "id": "vd_3f2b1a09",
    "domain": "verify.acme.example",
    "status": "active",
    "tls_status": "active",
    "verified_at": "2026-12-02T14:00:00Z",
    "tls_active_at": "2026-12-02T14:06:00Z"
  }]
}
```

## How links behave

* New KYC/KYB links use the custom host only when both `status` and `tls_status` are `active`.
* The invite carries the effective brand and product style snapshot. Changing the account style later does not restyle an existing invite.
* Links already sent keep the host selected when they were created. They are not rewritten retroactively.
* If the domain is pending, suspended, deleted, stale after revalidation, or TLS is not active, the link falls back to the canonical verification host.
* A failed or ambiguous DNS check does not make a custom host live. A temporary DNS reachability failure returns `503 dns_check_failed` and leaves the saved state unchanged.
* `resend-link` continues to issue the canonical host in v1. If you need a new custom-host link, create the applicable KYC/KYB link again after the domain is active.

## Limits and ownership

Version 1 supports **one domain per company account**. Delete the existing domain before registering a replacement. A domain already claimed by another account returns `409 domain_claimed` without revealing the other account.

Only active company accounts can use this feature. Company owners can create, verify, and delete the domain; other member roles receive `403 owner_required`. Person accounts and blocked accounts are rejected.

## Remove or replace a domain

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X DELETE https://api.qbank.cl/platform/v1/account/verify-domains/vd_3f2b1a09 \
  -H "Authorization: Bearer <token>"
```

The response is `204 No Content`. Links immediately fall back to the canonical host, and the TLS virtual host is removed on the next agent run. Delete the old DNS records before configuring the replacement.

## Errors

| HTTP | Code | Solution |
| -: | - | - |
| 400 | `invalid_domain` | Use a public hostname with at least two labels; do not use an IP, private hostname, or underscore. Use a subdomain because verification requires a CNAME and apex CNAME records are not generally supported. |
| 400 | `domain_not_allowed` | Remove a CBPay-owned suffix or ask for an explicitly allowlisted test hostname. |
| 401 | `unauthorized` | Refresh the credential and send it as a Bearer token. |
| 403 | `company_account_required` | Use an active company account. |
| 403 | `account_blocked` | Ask an authorized operator to restore the account. |
| 403 | `owner_required` | Use the company owner credential. |
| 404 | `domain_not_found` | List the account domain and use its current ID. |
| 409 | `domain_claimed` | Choose another domain; ownership is exclusive. |
| 409 | `domain_already_configured` | Delete the current domain before replacing it. |
| 429 | `too_many_requests` | Wait and retry later; creation and verification are each limited to 10 requests per hour per account. |
| 503 | `custom_domains_unavailable` | The environment is not provisioned for custom domains; contact your CBPay administrator. |
| 503 | `dns_check_failed` | DNS could not be reached. Wait, confirm nameservers, and call `verify` again. |

See [Errors](https://docs.cbpayapp.com/en/errors.md) for the common response envelope.

## FAQ

> [accordion] How long does DNS propagation take?
>
> It depends on the authoritative nameservers and TTL. Wait a few minutes, confirm the TXT and CNAME with a public DNS lookup, then call `verify` again. The `GET` endpoint never performs a DNS check.

> [accordion] Can I use a Cloudflare orange-cloud proxy?
>
> No. The CNAME must be DNS-only. A proxy hides the required CNAME target and can prevent the TLS challenge from reaching the verification origin.

> [accordion] Can I configure an apex domain such as acme.example?
>
> Use a delegated subdomain such as `verify.acme.example`. The verification flow requires a CNAME, and most DNS providers do not support CNAME records at the apex.

> [accordion] Why does Google Maps autocomplete degrade on my custom host?
>
> The browser key used by Places belongs to CBPay. Ask CBPay Support or Operations to allowlist `https://verify.acme.example/*` for the custom host. Until CBPay allowlists it, autocomplete can degrade to manual input; this is separate from DNS verification.

> [accordion] Does the custom host change my styles?
>
> No. The invite carries the style snapshot. The domain changes the host only, and existing invites keep their original host and style.

> [accordion] Can I create a second domain while the first is active?
>
> No. v1 allows one domain per account. Delete the current domain first, then register the replacement.

> [accordion] Why did my link use the canonical host?
>
> The custom domain may be pending, suspended, TLS-pending, stale after revalidation, or deleted. Correct DNS/TLS and verify again; only an active domain with active TLS is eligible.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.