Skip to content

Create & Retrieve Workspaces

Create a new workspace, list the workspaces the current user belongs to, and fetch a single workspace.


Create Workspace

POST /wallethero-api/workspace/create

Creates a workspace, adds the caller as workspace admin, and seeds the default data-model fields. Name and slug are checked for uniqueness.

Auth: Bearer token — system admins only (directus_users.system_admin). Other callers receive 403 { "error": "forbidden" }. Regular onboarding goes through POST /system/workspaces, which can assign or invite an owner.

Request Body

FieldTypeRequiredDescription
namestringYesWorkspace display name (1–100 characters)
slugstringYesURL-friendly identifier (1–100 characters, must match ^[a-z_]+$ — lowercase letters and underscores only)

Example Request

bash
curl -X POST "https://api.wallethero.app/wallethero-api/workspace/create" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Acme Coffee Rewards", "slug": "acme_coffee" }'

Response (200)

json
{
  "message": "Workspace created successfully",
  "workspace": {
    "id": "11111111-1111-1111-1111-111111111111",
    "name": "Acme Coffee Rewards",
    "slug": "acme_coffee",
    "date_created": "2024-01-15T10:30:00Z",
    "date_updated": null,
    "user_created": "22222222-2222-2222-2222-222222222222"
  }
}

SDK

typescript
// The SDK adapts the response to { data: Workspace }.
const { data: workspace } = await wh.workspaces.create({
  name: "Acme Coffee Rewards",
  slug: "acme_coffee",
});

List My Workspaces

GET /wallethero-api/workspaces/mine

Lists the workspaces the authenticated user is a member of, newest first.

Auth: Bearer token — scoped to the caller's memberships.

Example Request

bash
curl "https://api.wallethero.app/wallethero-api/workspaces/mine" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{
  "data": [
    {
      "id": "11111111-1111-1111-1111-111111111111",
      "name": "Acme Coffee Rewards",
      "slug": "acme_coffee",
      "date_created": "2024-01-15T10:30:00Z",
      "date_updated": "2024-02-01T09:00:00Z",
      "user_created": "22222222-2222-2222-2222-222222222222"
    }
  ]
}

SDK

typescript
const { data: workspaces } = await wh.workspaces.list();

Get Workspace

GET /wallethero-api/workspace/:workspaceId

Fetches a single workspace by ID. The caller must be a member.

Auth: Bearer token — workspace member.

Path Parameters

ParameterTypeDescription
workspaceIdstring (UUID)Workspace identifier

Example Request

bash
curl "https://api.wallethero.app/wallethero-api/workspace/WORKSPACE_ID" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{
  "data": {
    "id": "11111111-1111-1111-1111-111111111111",
    "name": "Acme Coffee Rewards",
    "slug": "acme_coffee",
    "date_created": "2024-01-15T10:30:00Z",
    "date_updated": "2024-02-01T09:00:00Z",
    "user_created": "22222222-2222-2222-2222-222222222222"
  }
}

A missing workspace returns 404 with { "error": "Workspace not found" }.

SDK

typescript
const { data: workspace } = await wh.workspaces.get("WORKSPACE_ID");

WalletHero Documentation