# You and your workspace (API)

> API endpoints for who a token acts as, the workspace's organization ID, finding members (and integration accounts) by name or e-mail, and turning user IDs into names.

Source: https://docs.sofiaspace.uz/api/me-and-workspace/

Before an integration creates or assigns anything, it usually needs three facts: **which workspace** it's in (the organization ID most paths contain), **who it acts as** (the token owner's user ID — yours, or an integration account's), and **who the other people are** (to set an assignee from a name or e-mail in your CRM). These endpoints answer them.

**Scope:** a full-access scope, as listed per endpoint (`tasks:read` or `docs:read` cover all of them). Personal and integration-account tokens work the same here. Script-scope tokens (`task:create`, `doc:create`) can't call these; copy the organization ID from **Settings → My account → Security → API tokens** instead.

## Get your workspace and your user ID

`GET /api/v1/orgs/by-subdomain/{subdomain}`

**Scope:** `tasks:read`, `docs:read`, `dashboards:read` or `home:write`.

`{subdomain}` is the first part of your workspace address: `acme` for `acme.sofiaspace.uz`.

```bash
curl https://acme.sofiaspace.uz/api/v1/orgs/by-subdomain/acme \
  -H "Authorization: Bearer $SOFIA_TOKEN"
```

```json
{
  "organization": {
    "id": "6b1f0c3e-2a4d-4c55-9a51-0d3f6a1e7b20",
    "name": "Acme Trading",
    "subdomain": "acme",
    "status": "ACTIVE",
    "createdAt": "2026-03-02T08:00:00Z",
    "avatarVersion": null
  },
  "roleName": "Member",
  "isOrgAdmin": false,
  "userId": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21",
  "canCreateProjects": false
}
```

| Field | Meaning |
| --- | --- |
| `organization.id` | The **organization ID** used in paths like `/orgs/{orgId}/projects` |
| `organization.status` | `ACTIVE`, or for example `ARCHIVED` (read-only) |
| `roleName`, `isOrgAdmin` | The token owner's role in this workspace |
| `userId` | The token owner's **user ID** — use it as `assigneeId` to assign tasks to yourself (or to the integration account) |
| `canCreateProjects` | Whether the owner may create projects: Org Admins, and roles allowed to create projects. `null` if it couldn't be checked |

The response also has a few fields that are always empty for a token (for example `existingAccount: false`, and member counts set to `null`); ignore them.

Errors: `403` ("This token belongs to a different organization") if the subdomain isn't the token's own workspace or doesn't exist.

## Check the token's scopes

`GET /api/v1/agent/scopes` — any full-access scope. Returns the scopes this token can use now, the owner's role ceiling (personal tokens only) and the owner's user ID. See [Authentication and scopes](https://docs.sofiaspace.uz/api/authentication.md#check-what-a-token-can-do).

## Find members by name or e-mail

`GET /api/v1/orgs/{orgId}/members/search?q={text}`

**Scope:** `tasks:read`, `docs:read` or `dashboards:write`.

| Parameter | In | Required | Meaning |
| --- | --- | --- | --- |
| `orgId` | path | yes | Organization ID |
| `q` | query | no | Text to look for in first name, last name or e-mail (case-insensitive, one piece of text). Empty returns the first members alphabetically |
| `includeIntegrations` | query | no | `true` to include integration accounts in the results. Default `false` |

Matches active members only (not people who haven't activated their account or accepted their invitation yet), sorted by first name, last name and e-mail, at most **20** per call. Integration accounts are left out unless you ask for them with `includeIntegrations=true`.

```bash
curl -G https://acme.sofiaspace.uz/api/v1/orgs/6b1f0c3e-2a4d-4c55-9a51-0d3f6a1e7b20/members/search \
  -H "Authorization: Bearer $SOFIA_TOKEN" \
  --data-urlencode "q=malika@acme.uz"
```

```json
{
  "members": [
    {
      "userId": "8e4d2b19-6c7a-4f3e-b1d0-3a5c9e8f7d62",
      "email": "malika@acme.uz",
      "firstName": "Malika",
      "lastName": "Yusupova",
      "roleName": "Member",
      "status": "ACTIVE",
      "provisionedAt": "2026-03-04T10:12:00Z",
      "activatedAt": "2026-03-04T10:40:00Z",
      "avatarVersion": null,
      "jobTitle": "Account manager",
      "teamIds": [],
      "isGuest": false,
      "integration": false,
      "activationExpiresAt": null
    }
  ]
}
```

| Field | Meaning |
| --- | --- |
| `userId` | Use it as `assigneeId`, `reporterId` and the like |
| `roleName`, `isGuest` | The member's workspace role, and whether it's a guest role |
| `teamIds` | The active teams the member is in |
| `integration` | `true` for an integration account (only with `includeIntegrations=true`) |
| `activationExpiresAt` | For members who haven't activated yet, when their activation link expires. Search returns only active members, so here it is always `null` |

**Tip:** the text is matched as one piece. `q=Malika Yusupova` finds nobody, because no single name contains both words. Search for `Malika`, then pick the one whose `lastName` matches — or, better, search by e-mail, which is unique.

An integration account's `firstName` is its name (for example "1C ERP"), its `lastName` is empty, and its `email` is a placeholder that receives no mail.

## Turn user IDs into names

`POST /api/v1/users/batch-get`

**Scope:** `tasks:read`, `docs:read` or `dashboards:read`.

Tasks, comments and pages return people as user IDs (`assigneeId`, `authorId`, `createdBy`). Send the IDs, get names and e-mails back.

```bash
curl -X POST https://acme.sofiaspace.uz/api/v1/users/batch-get \
  -H "Authorization: Bearer $SOFIA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"userIds":["8e4d2b19-6c7a-4f3e-b1d0-3a5c9e8f7d62","4f7a1c2e-9b3d-4e6f-a8c1-2d5e7f9a1b3c"]}'
```

```json
{
  "users": [
    { "userId": "8e4d2b19-6c7a-4f3e-b1d0-3a5c9e8f7d62", "email": "malika@acme.uz", "firstName": "Malika", "lastName": "Yusupova", "avatarVersion": null, "integration": false },
    { "userId": "4f7a1c2e-9b3d-4e6f-a8c1-2d5e7f9a1b3c", "email": "integration-5d0c8e72-3a1f-4b9e-8c6d-0e2f4a6b8c1d@integrations.sofiaspace.invalid", "firstName": "1C ERP", "lastName": "", "avatarVersion": null, "integration": true }
  ]
}
```

- `integration: true` marks an integration account: show its `firstName` as the name, and don't send e-mail to its address.
- You only get people in **this workspace**: the token's owner, and active members of the workspace the token belongs to (integration accounts included). Anyone else — people in other workspaces, people who have left, people who haven't activated their account yet, and deleted accounts — is left out, the same as an unknown ID. Show such an ID as an unknown person.
- Up to **200** different IDs per call; more are ignored. Unknown or malformed IDs are left out without an error, and the order of `users` isn't the order you sent — match on `userId`.

Cache the result: people's names rarely change.

## What you can't do

- You can't list every member with a token (the full member list, with people who haven't activated yet, is for Org Admins in the app), invite people, resend activation links or change roles.
- You can't create, change or remove integration accounts or their tokens through the API.
- You can't read another person's profile beyond name, e-mail and avatar.
- You can't switch workspace: a token belongs to the workspace it was created in.

## Related

- [Authentication and scopes](https://docs.sofiaspace.uz/api/authentication.md)
- [Tasks](https://docs.sofiaspace.uz/api/tasks.md) — assigning tasks
- [Integrations API](https://docs.sofiaspace.uz/api/integrations.md) — assign by e-mail when creating a task by project key
- [Members and invites](https://docs.sofiaspace.uz/admin/members-and-invites.md)
- [Integration accounts](https://docs.sofiaspace.uz/integrations/integration-accounts.md)
