*Cloud › Networking*

# Connect a custom domain

```http
POST https://devapi.dispralabs.com/v1/cloud/domains/:dom/connect
```

When the domain's DNS provider supports Domain Connect: the address where you approve the records at your provider. The domain is then checked as usual.

Needs a key with `full` access.

- **Authentication:** Secret key (send it as `Authorization: Bearer <key>`)
- **Idempotency:** Safe to retry. Send an `Idempotency-Key` header and repeated calls within 24 hours return the first result.

## Parameters

- `dom` (string, required): The custom domain's id. Example: `dom_01jdk5g7h9j1k3l5z7x9c1v3bn`
- `redirect_uri` (string, required): Where the provider sends you back. Example: `https://acme.com/domains/done`

## Returns

- **200**: url, width and height.

## Errors

| Status | Code | When |
|---|---|---|
| 404 | [not_found](https://docs.dispralabs.com/errors.md#not_found) | No such object in the key's project (or environment). |
| 409 | [domain_connect_unsupported](https://docs.dispralabs.com/errors.md#domain_connect_unsupported) | The provider doesn't support Domain Connect. |

## Request samples

### Dispra Cloud CLI

```bash
dcloud api POST /v1/cloud/domains/dom_01jdk5g7h9j1k3l5z7x9c1v3bn/connect --data '{"redirect_uri":"https://acme.com/domains/done"}'
```

### cURL

```bash
curl -X POST "https://devapi.dispralabs.com/v1/cloud/domains/dom_01jdk5g7h9j1k3l5z7x9c1v3bn/connect" \
  -H "Authorization: Bearer dsp_live_YOUR_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"redirect_uri":"https://acme.com/domains/done"}'
```

### Node

```javascript
const res = await fetch("https://devapi.dispralabs.com/v1/cloud/domains/dom_01jdk5g7h9j1k3l5z7x9c1v3bn/connect", {
  method: "POST",
  headers: { Authorization: "Bearer dsp_live_YOUR_KEY", "Idempotency-Key": crypto.randomUUID(), "Content-Type": "application/json" },
  body: JSON.stringify({
    "redirect_uri": "https://acme.com/domains/done"
  }),
});
console.log(await res.json());
```

### Python

```python
import uuid, requests
res = requests.request("POST", "https://devapi.dispralabs.com/v1/cloud/domains/dom_01jdk5g7h9j1k3l5z7x9c1v3bn/connect", headers={"Authorization": "Bearer dsp_live_YOUR_KEY", "Idempotency-Key": str(uuid.uuid4())}, json={
  "redirect_uri": "https://acme.com/domains/done"
})
print(res.json())
```

### Go

```go
body := strings.NewReader(`{"redirect_uri":"https://acme.com/domains/done"}`)
req, _ := http.NewRequest("POST", "https://devapi.dispralabs.com/v1/cloud/domains/dom_01jdk5g7h9j1k3l5z7x9c1v3bn/connect", body)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer dsp_live_YOUR_KEY")
req.Header.Set("Idempotency-Key", uuid.NewString())
res, _ := http.DefaultClient.Do(req)
```

## Responses

### 200

```json
{}
```

### 404 not_found

```json
{
  "error": {
    "code": "not_found",
    "message": "No such object in the key's project (or environment).",
    "request_id": "req_7f3a9c21d84be056"
  }
}
```

### 409 domain_connect_unsupported

```json
{
  "error": {
    "code": "domain_connect_unsupported",
    "message": "The provider doesn't support Domain Connect.",
    "request_id": "req_7f3a9c21d84be056"
  }
}
```
