# Organizations and workspaces in the Beplan API

Beplan data lives in organizations, and most of it in their workspaces. Paths name both by id, and a token only reaches the ones it was given.

## Organizations and workspaces

An **organization** is a team in Beplan: its members and their roles, its plan, its policy for integrations. A **workspace** is a brand or client inside it, with its own social accounts, calendar, posts, media library and insights. A person can belong to several organizations.

Every path of the API names its organization, and most name a workspace:

```text
https://api.beplan.io/v1/organizations/{organizationId}/workspaces/{workspaceId}/posts
```

Organization ids are opaque strings; workspace ids are UUIDs. Never build one yourself: read them from the API.

## Start with GET /v1/me

[GET /v1/me](https://beplan.io/docs/api/identity/#identity.get) needs no id and only [`profile:read`](https://beplan.io/docs/oauth/scopes/#scope-profile-read), which every token has. It answers who the token acts for, the connection behind it, and every organization it was given:

- `state`: `active`, `pending` (an admin of that organization must approve the connection first; calls there answer [`INTEGRATION_PENDING_APPROVAL`](https://beplan.io/docs/api/errors/#INTEGRATION_PENDING_APPROVAL)) or `blocked` (with a `reason`, the same values as `details.reason` of [`INTEGRATION_BLOCKED_BY_ORGANIZATION`](https://beplan.io/docs/api/errors/#INTEGRATION_BLOCKED_BY_ORGANIZATION)).
- `allWorkspaces`: whether the connection reaches every workspace the person can see there, including ones created later, or only a list.
- `workspaces`: the ones it reaches, each with `id`, `name` and `timezone`.

Call it when your integration starts and whenever an organization or workspace answers `404`: the person may have changed what your connection reaches.

Example (A personal token given one organization), `GET /me`:

```bash
curl -X GET "https://api.beplan.io/v1/me" \
  -H "Authorization: Bearer beplan_pat_…"
```

```typescript
const response = await fetch("https://api.beplan.io/v1/me", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import requests

response = requests.get(
    "https://api.beplan.io/v1/me",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": {
    "user": {
      "id": "user_2x8Kq",
      "name": "Alex Martin"
    },
    "connection": {
      "id": "3c9d1e2f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
      "kind": "personal_token",
      "name": "n8n weekly report",
      "clientId": null,
      "scopes": [
        "profile:read",
        "posts:read",
        "media:read"
      ],
      "expiresAt": "2027-02-17T10:00:00.000Z"
    },
    "organizations": [
      {
        "id": "org_8Hq2LmN4",
        "name": "Studio Halden",
        "state": "active",
        "reason": null,
        "allWorkspaces": true,
        "workspaces": [
          {
            "id": "5d2e8f14-3a6b-4c7d-9e0f-1a2b3c4d5e60",
            "name": "Studio Halden",
            "timezone": "Europe/Paris"
          }
        ]
      }
    ]
  }
}
```

## Workspaces and time zones

[`GET …/workspaces`](https://beplan.io/docs/api/workspaces/#workspaces.list) lists an organization's workspaces your token can reach, each with its `timezone` (an IANA name). A workspace's calendar, posting slots and "Thursday at 9:00" live in that zone; the API's dates are ISO 8601 instants. Convert a wall time in the workspace's zone to an instant before you send it, and back before you show it.

Example (One workspace), `GET /organizations/{organizationId}/workspaces`:

```bash
curl -X GET "https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces" \
  -H "Authorization: Bearer beplan_pat_…"
```

```typescript
const response = await fetch("https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
```

```python
import requests

response = requests.get(
    "https://api.beplan.io/v1/organizations/Yx0k2N7mQf3bA9cRz1LwP/workspaces",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
```

Answers 200:

```json
{
  "data": [
    {
      "id": "3f6c2a8e-91b4-4d7e-a2c5-7e0b9d1f4a62",
      "name": "Northwind",
      "avatarUrl": null,
      "timezone": "Europe/Paris",
      "defaultAccountIds": []
    }
  ]
}
```

## What a narrowed connection sees

When a person gives your connection some workspaces of an organization rather than all of them:

- A workspace outside the list answers `404` [`WORKSPACE_NOT_FOUND`](https://beplan.io/docs/api/errors/#WORKSPACE_NOT_FOUND), exactly like a workspace that does not exist.
- Organization-level lists (workspaces, people pickers, team workspaces, Deals across workspaces) show only the workspaces in the list, on top of what the person's teams let them see.
- Workspace ids you send in a body are checked against the list.
- Organization-wide writes ([`members:write`](https://beplan.io/docs/oauth/scopes/#scope-members-write), [`roles:write`](https://beplan.io/docs/oauth/scopes/#scope-roles-write), [`organization:write`](https://beplan.io/docs/oauth/scopes/#scope-organization-write), [`workspaces:manage`](https://beplan.io/docs/oauth/scopes/#scope-workspaces-manage), which creates and deletes workspaces, and the organization's Deals settings, companies and contacts) answer [`INTEGRATION_SELECTION_TOO_NARROW`](https://beplan.io/docs/api/errors/#INTEGRATION_SELECTION_TOO_NARROW). Deals in the chosen workspaces still work with [`deals:write`](https://beplan.io/docs/oauth/scopes/#scope-deals-write).
- The organization's usage meters ([`GET …/usage`](https://beplan.io/docs/api/organizations/#organizations.usage.get)) stay organization-wide: they are the plan's allowance, and name no workspace.

A person's teams apply too: even with "all workspaces", a connection reaches only the workspaces its person can see.

### Design for it

- Treat a `404` on an organization or workspace as "not available to this connection", not as an error to retry or report. Read [GET /v1/me](https://beplan.io/docs/api/identity/#identity.get) again and update what you show.
- Don't cache the list of workspaces forever. People narrow and widen their connections from **Integrations** in their settings, admins revoke them, workspaces are created and deleted. An app hears about it through [`connection.updated`](https://beplan.io/docs/webhooks/events/#event-connection.updated) and [`connection.revoked`](https://beplan.io/docs/webhooks/events/#event-connection.revoked) ([webhooks](https://beplan.io/docs/guides/webhooks/)).
- If your feature needs an organization-wide scope, ask the person for all workspaces of that organization and say why.
- One connection can span several organizations on different plans. Each organization's plan sets its own [rate limits](https://beplan.io/docs/guides/rate-limits/) and features: a `402` [`PLAN_UPGRADE_REQUIRED`](https://beplan.io/docs/api/errors/#PLAN_UPGRADE_REQUIRED) in one organization says nothing about another.

## Roles still apply

The connection is the most a token can do; the person's role decides what they can do now. A member whose role can't publish gets `403` [`MISSING_PERMISSION`](https://beplan.io/docs/api/errors/#MISSING_PERMISSION) from [`POST …/posts/{postId}/schedule`](https://beplan.io/docs/api/posts/#posts.schedule) through the API exactly as in the app, whatever the token's scopes. Role changes take effect on the next request.

## Related

- [How access works](https://beplan.io/docs/concepts/access/): the four locks and every refusal.
- [`GET /organizations/{organizationId}`](https://beplan.io/docs/api/organizations/#organizations.get) and [`GET …/members/me`](https://beplan.io/docs/api/organizations/#organizations.currentMember.get): the organization, and the person's own membership and role there.

---
HTML version: https://beplan.io/docs/concepts/organizations/
