---
title: "Add a domain"
description: "Adds a domain to a workspace and returns the DNS records to create at your DNS provider."
canonical_url: https://docs.markdrop.in/api/domains/add-a-domain
last_updated: 2026-10-30
site: "Markdrop Docs"
index: https://docs.markdrop.in/llms.txt
---

# Add a domain

`POST https://api.markdrop.in/api/v1/workspaces/{workspace_id}/domains`

Adds a domain to a workspace and returns the DNS records to create at your DNS provider.

- **Authentication:** API token required: `Authorization: Bearer mdk_…`.
- **Rate limit:** 20 per minute per IP address.
- **Guide:** [Custom domain](https://docs.markdrop.in/workspaces/custom-domain)

## Path parameters

- `workspace_id` (string, required): The workspace's id, from the address of its settings page (`markdrop.in/settings/workspaces/<workspace-id>`) or from [List workspaces](https://docs.markdrop.in/api/workspaces/list-workspaces).

## Request body

`application/json`, required.

- `host` (string, required): The full hostname, like `docs.acme.com`. 3–253 characters.
- `kind` ("app" | "cdn", required): `app` serves documents and files; `cdn` serves files only.

## Responses

- `201`: Created.
  - `id` (string)
  - `host` (string)
  - `kind` ("app" | "cdn")
  - `status` ("pending" | "verified" | "failed" | "lapsed")
  - `created_at` (string (date-time)): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `verified_at` (string (date-time) | null): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `last_checked_at` (string (date-time) | null): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `last_error` (string | null)
  - `attached` (boolean): Default `false`.
  - `is_primary` (boolean): Default `false`.
  - `dns_record_name` (string | null)
  - `dns_record_type` (string | null): Default `"TXT"`.
  - `dns_record_value` (string | null)
  - `dns_target_name` (string | null)
  - `dns_target_type` (string | null)
  - `dns_target_value` (string | null)
  - `warning` (string | null)
  - `live` (boolean): Default `false`.
  - `routing_ok` (boolean | null)
  - `txt_ok` (boolean | null)
  - `failures` (integer): Default `0`.
  - `first_failed_at` (string (date-time) | null): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `lapsed_at` (string (date-time) | null): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `expires_at` (string (date-time) | null): ISO 8601, for example `2026-11-30T12:00:00Z`.
  - `apex_certain` (boolean | null): Default `true`.
  - `dns_routing_options` (array of object)
    - `type` (string)
    - `name` (string)
    - `value` (string)
- `401`: No token, or the token is revoked or mistyped.
- `422`: The request didn't validate. `detail` lists each problem, with where it is (`loc`) and why (`msg`).
- `429`: Too many requests from your IP address. Wait the seconds in `Retry-After`.

## Examples

**curl**

```bash
curl -X POST https://api.markdrop.in/api/v1/workspaces/WORKSPACE_ID/domains \
  -H "Authorization: Bearer $MARKDROP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"host":"docs.acme.com","kind":"app"}'
```

**JavaScript**

```javascript
const res = await fetch("https://api.markdrop.in/api/v1/workspaces/WORKSPACE_ID/domains", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MARKDROP_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "host": "docs.acme.com",
    "kind": "app"
  }),
});
const data = await res.json();
```

**Python**

```python
import os

import requests

r = requests.post(
    "https://api.markdrop.in/api/v1/workspaces/WORKSPACE_ID/domains",
    headers={"Authorization": f"Bearer {os.environ['MARKDROP_TOKEN']}"},
    json={"host": "docs.acme.com", "kind": "app"},
)
r.raise_for_status()
print(r.json())
```
