# Create a workspace

**`POST https://myagentmail.com/v1/workspaces`**

Group: Workspaces
Operation ID: `createWorkspace`

Requires a tenant master key (`tk_...`). Workspaces are isolation containers — inboxes and domains created in one cannot be seen from another.

## Request body

Content-Type: `application/json`

```json
{
  "name": "Recruiter Corp",
  "slug": "recruiter-corp"
}
```

## Responses

### 201 — Created

```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "Recruiter Corp",
  "slug": "recruiter-corp",
  "isDefault": false,
  "inboxCount": 0,
  "domainCount": 0,
  "createdAt": "2026-05-01T08:11:44.571Z"
}
```

### 400 — Request body failed schema validation

```json
{
  "error": "string",
  "code": "VALIDATION_ERROR"
}
```

### 401 — Missing or invalid API key

```json
{
  "error": "string",
  "code": "VALIDATION_ERROR"
}
```

## Code samples

### TypeScript

```typescript
import { MyAgentMail } from "myagentmail";

const client = new MyAgentMail({ apiKey: process.env.MYAGENTMAIL_API_KEY! });

// POST /v1/workspaces
const result = await client.request("post", "/v1/workspaces", { body: {
  "name": "Recruiter Corp",
  "slug": "recruiter-corp"
} });
```

### curl

```bash
curl -X POST 'https://myagentmail.com/v1/workspaces' \
  -H 'X-API-Key: $MYAGENTMAIL_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Recruiter Corp",
  "slug": "recruiter-corp"
}'
```

### Python

```python
import os, requests

r = requests.post(
    "https://myagentmail.com/v1/workspaces",
    headers={"X-API-Key": os.environ["MYAGENTMAIL_API_KEY"]},
    json={
        "name": "Recruiter Corp",
        "slug": "recruiter-corp"
    },
)
r.raise_for_status()
print(r.json())
```
