
# Reassign a domain

Point an existing domain at a different site in the workspace.

```sh
PATCH https://sitepaste.com/api/v1/public/domains/{domainId}
```

Requires the `settings` scope.

## Usage

```bash
curl -X PATCH "https://sitepaste.com/api/v1/public/domains/d8qjx2v7mz4r" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "siteId": "s7k2m0dq1p3z" }'
```

## Authorizations

| Header | Type | Required | Description |
|--------|------|----------|-------------|
| Authorization | string | Yes | Bearer token (`Authorization: Bearer sp_...`). Created in the dashboard under Account > Tokens. See [authentication](/api/authentication). |

## Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| siteId | string | Yes | The site to point the domain at, as a short ID or the literal `default`. |

A domain added as an apex pair moves with its `www.` twin. Reassigning either one moves both.

## Errors

404 when the domain, or the site named in `siteId`, is not one this workspace has. 422 when `siteId` is missing. 400 when `siteId` is neither a short ID nor the literal `default`.

## Response

200 OK with the domain as it now stands, naming the site it points at. Reassigning a domain to the site it already points at changes nothing and answers the same way.

400 when `{domainId}` is malformed; 404 when it is well formed but the workspace has no domain with that ID. 500 when the reassignment did not complete. Retry it, or re-read the domain to see where it stands.