# Create a workspace for one of your tenants

`POST /v1/workspaces`

Requires an API key with the `workspaces:manage` scope. [About keys and scopes](/docs/api/authentication)

Partner keys only. Creates a child workspace for one tenant of your product, identified by your own `externalId`, so you never need to store ours. From then on, any `/v1` call with the header `Kirora-Workspace: <externalId>` acts in that workspace with your key: load its contacts, verify its sending domain, send. The workspace has no members and bills to your account. A repeated `externalId` is 409 `ALREADY_EXISTS`. While your own workspace is being deleted this is 403 `WORKSPACE_DELETION_PENDING`; cancel the deletion to create workspaces again.

## Request body

- `name` (string, required, 1–200 characters)
- `externalId` (string, required) — Your own id for the tenant (up to 128 letters, digits, `.`, `:`, `_`, `-`); unique among your workspaces.
- `country` (string, required) — Two-letter ISO 3166-1 country code.
- `timezone` (string, optional, 1–64 characters) — IANA timezone, such as `Europe/Berlin`.

## Returns

Returns `201 Created` with a `Workspace` in `data`. Otherwise returns an error; [Errors](/docs/api/errors) lists every code and which to retry.

- `id` (string, required, uuid)
- `externalId` (string, required) — Your own id for the tenant.
- `name` (string, required)
- `country` (string, required, 2–2 characters) — Two-letter ISO 3166-1 country code.
- `timezone` (string, required) — IANA timezone; decides local-time sends and report days.
- `status` (string, required, one of `active`, `suspended`, `deleting`) — `suspended` refuses every send in the workspace until it is resumed; `deleting` refuses them too, and the workspace is purged unless the deletion is cancelled.
- `suspendedAt` (string | null, required, date-time) — When it was suspended; null if not.
- `deletionRequestedAt` (string | null, required, date-time) — When deletion was asked for; null if not.
- `createdAt` (string, required, date-time)

## Example

```bash
curl -X POST https://api.kirora.io/v1/workspaces \
  -H "Authorization: Bearer $KIRORA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Weekend specials",
    "externalId": "user_8812",
    "country": "GB"
  }'
```

Response `201`:

```json
{
  "data": {
    "id": "018f2a4e-6b1c-7d3e-9f40-37386ae05a6b",
    "externalId": "user_8812",
    "name": "Weekend specials",
    "country": "GB",
    "timezone": "Europe/London",
    "status": "active",
    "suspendedAt": "2030-03-14T09:30:00Z",
    "deletionRequestedAt": "2030-03-14T09:30:00Z",
    "createdAt": "2030-03-14T09:30:00Z"
  }
}
```
