# Custom domains

8 endpoints at `https://api.kosa8.com`, sent with `Authorization: Bearer $KOSA8_API_KEY`. Generated from the API's own [OpenAPI description](https://api.kosa8.com/openapi.json), which a test holds to the router.

## The preview's custom domains[#]

GET`/v1/sandboxes/{id}/previews/{port}/domains`scope sandboxes:read

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

`port`requiredpath · string

The port in the sandbox, 1-65535

Responses

200400401403404

```
curl -s -X GET https://api.kosa8.com/v1/sandboxes/$SBX/previews/$PORT/domains \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Serve the preview at your own hostname[#]

POST`/v1/sandboxes/{id}/previews/{port}/domains`scope sandboxes:write

Through Cloudflare for SaaS custom hostnames: 501 not_available when this kosa8 Cloud has not configured it. A preview has at most 5 custom domains, an organization 50. The domain serves the preview as it is, private (signed link) or public, and follows the sandbox and port across a rotate.

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

`port`requiredpath · string

The port in the sandbox, 1-65535

JSON body

`hostname`requiredstring

A name under your own domain; never one under kosa8's or the preview domain

`ssl_method`"http" | "txt"

How Cloudflare validates the certificate: http (default, once the CNAME points here) or txt

Responses

201400401403404409501502

```
curl -s -X POST https://api.kosa8.com/v1/sandboxes/$SBX/previews/$PORT/domains \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## A custom domain's status, asked of Cloudflare again[#]

GET`/v1/sandboxes/{id}/previews/{port}/domains/{hostname}`scope sandboxes:read

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

`port`requiredpath · string

The port in the sandbox, 1-65535

`hostname`requiredpath · string

The custom domain, such as preview.example.com

Responses

200400401403404

```
curl -s -X GET https://api.kosa8.com/v1/sandboxes/$SBX/previews/$PORT/domains/$HOSTNAME \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Stop serving the preview at the hostname[#]

DELETE`/v1/sandboxes/{id}/previews/{port}/domains/{hostname}`scope sandboxes:write

Parameters

`id`requiredpath · string

Sandbox id (sbx_…)

`port`requiredpath · string

The port in the sandbox, 1-65535

`hostname`requiredpath · string

The custom domain, such as preview.example.com

Responses

200400401403404502

```
curl -s -X DELETE https://api.kosa8.com/v1/sandboxes/$SBX/previews/$PORT/domains/$HOSTNAME \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## The preview's custom domains[#]

GET`/v1/previews/{preview_id}/domains`scope sandboxes:read

Parameters

`preview_id`requiredpath · string

A preview's id, {sandbox_id}:{port} (the id field of a preview)

Responses

200400401403404

```
curl -s -X GET https://api.kosa8.com/v1/previews/$PREVIEW_ID/domains \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Serve the preview at your own hostname[#]

POST`/v1/previews/{preview_id}/domains`scope sandboxes:write

Through Cloudflare for SaaS custom hostnames: 501 not_available when this kosa8 Cloud has not configured it. A preview has at most 5 custom domains, an organization 50. The domain serves the preview as it is, private (signed link) or public, and follows the sandbox and port across a rotate.

Parameters

`preview_id`requiredpath · string

A preview's id, {sandbox_id}:{port} (the id field of a preview)

JSON body

`hostname`requiredstring

A name under your own domain; never one under kosa8's or the preview domain

`ssl_method`"http" | "txt"

How Cloudflare validates the certificate: http (default, once the CNAME points here) or txt

Responses

201400401403404409501502

```
curl -s -X POST https://api.kosa8.com/v1/previews/$PREVIEW_ID/domains \
  -H "Authorization: Bearer $KOSA8_API_KEY" \
  -H 'Content-Type: application/json' -d @body.json
```

## A custom domain's status, asked of Cloudflare again[#]

GET`/v1/previews/{preview_id}/domains/{hostname}`scope sandboxes:read

Parameters

`preview_id`requiredpath · string

A preview's id, {sandbox_id}:{port} (the id field of a preview)

`hostname`requiredpath · string

The custom domain, such as preview.example.com

Responses

200400401403404

```
curl -s -X GET https://api.kosa8.com/v1/previews/$PREVIEW_ID/domains/$HOSTNAME \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

## Stop serving the preview at the hostname[#]

DELETE`/v1/previews/{preview_id}/domains/{hostname}`scope sandboxes:write

Parameters

`preview_id`requiredpath · string

A preview's id, {sandbox_id}:{port} (the id field of a preview)

`hostname`requiredpath · string

The custom domain, such as preview.example.com

Responses

200400401403404502

```
curl -s -X DELETE https://api.kosa8.com/v1/previews/$PREVIEW_ID/domains/$HOSTNAME \
  -H "Authorization: Bearer $KOSA8_API_KEY"
```

---
Source: https://docs.kosa8.com/api/custom-domains/
