# API: Workspaces

| Method | Path | What it does | Scope |
|---|---|---|---|
| GET | `/v1/workspaces` | List workspaces (brands) in the organization | `settings:read` |
| POST | `/v1/workspaces` | Create a workspace (owner) | `settings:write` |
| DELETE | `/v1/workspaces/:id` | Delete a workspace (owner) | `settings:write` |
| PATCH | `/v1/workspaces/:id` | Rename a workspace (owner) | `settings:write` |
| PUT | `/v1/workspaces/:id/members` | Limit people to this workspace's records (with their other workspaces); an empty list clears it (owner) (web app only) | `members:write` |
| DELETE | `/v1/workspaces/limits/:userId` | Lift a person's workspace limit (they see every workspace's records) (owner) (web app only) | `settings:write` |

## Examples

### GET /v1/workspaces

List workspaces (brands) in the organization

```bash
curl -s "https://api.closefinch.com/v1/workspaces" \
  -H "Authorization: Bearer $RA_API_KEY"
```

```js
const res = await fetch(`https://api.closefinch.com/v1/workspaces`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}` },
});
const data = await res.json();
```

### POST /v1/workspaces

Create a workspace (owner)

```bash
curl -s -X POST "https://api.closefinch.com/v1/workspaces" \
  -H "Authorization: Bearer $RA_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.closefinch.com/v1/workspaces`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

### DELETE /v1/workspaces/$ID

Delete a workspace (owner)

```bash
curl -s -X DELETE "https://api.closefinch.com/v1/workspaces/$ID" \
  -H "Authorization: Bearer $RA_API_KEY"
```

```js
const res = await fetch(`https://api.closefinch.com/v1/workspaces/${id}`, {
  method: "DELETE",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}` },
});
const data = await res.json();
```

### PATCH /v1/workspaces/$ID

Rename a workspace (owner)

```bash
curl -s -X PATCH "https://api.closefinch.com/v1/workspaces/$ID" \
  -H "Authorization: Bearer $RA_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
```

```js
const res = await fetch(`https://api.closefinch.com/v1/workspaces/${id}`, {
  method: "PATCH",
  headers: { authorization: `Bearer ${process.env.RA_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();
```

Request and response schemas: [https://www.closefinch.com/openapi.json](https://www.closefinch.com/openapi.json). All resources: [API reference](https://www.closefinch.com/docs/api).
