Skip to content

Segments — CRUD & Evaluation

Create, read, update, and delete segments, plus duplicate them and evaluate their membership (preview, clients, passes, size, count). See the overview for the segment model and Filters for filter config.

Auth: Bearer token — workspace member. List / create are workspace-scoped by path; all other routes resolve the workspace from the segment row.


List Segments

GET /wallethero-api/workspace/:workspaceId/segments

Lists every segment in the workspace, newest first (sorted by -date_created).

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/segments" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{
  "data": [
    {
      "id": "22222222-2222-2222-2222-222222222222",
      "workspace_id": "WORKSPACE_ID",
      "name": "VIP Members",
      "description": "Gold and Platinum tiers",
      "filters": [],
      "date_created": "2026-01-10T08:00:00Z"
    }
  ]
}

SDK

typescript
const { data } = await wh.segments.list({
  filter: { workspace_id: { _eq: "WORKSPACE_ID" } },
});
// or:
const { data: byWs } = await wh.segments.getByWorkspace("WORKSPACE_ID");

Create Segment

POST /wallethero-api/workspace/:workspaceId/segments

Creates a segment. Filters are validated and each gets an id assigned.

Auth: Bearer token — workspace member.

Path Parameters

ParameterTypeDescription
workspaceIdstring (UUID)Workspace identifier

Request Body

FieldTypeRequiredDescription
namestringYesSegment name
descriptionstringNoFree-text description
filtersSegmentFilter[]NoFilter objects (default []). See Filters

Example Request

bash
curl -X POST "https://api.wallethero.app/wallethero-api/workspace/WORKSPACE_ID/segments" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "VIP Members",
    "filters": [
      {
        "filter_type": "custom_field",
        "filter_config": {
          "custom_field_filters": {
            "tier": { "operator": "_in", "value": ["Gold", "Platinum"] }
          }
        }
      }
    ]
  }'

Response (201)

json
{
  "data": {
    "id": "22222222-2222-2222-2222-222222222222",
    "workspace_id": "WORKSPACE_ID",
    "name": "VIP Members",
    "filters": [
      { "id": "f1", "filter_type": "custom_field", "filter_config": { "custom_field_filters": { "tier": { "operator": "_in", "value": ["Gold", "Platinum"] } } } }
    ]
  }
}

SDK

typescript
const { data: segment } = await wh.segments.create({
  workspace_id: "WORKSPACE_ID",
  name: "VIP Members",
  filters: [
    {
      filter_type: "custom_field",
      filter_config: {
        custom_field_filters: { tier: { operator: "_in", value: ["Gold", "Platinum"] } },
      },
    },
  ],
});

Get Segment

GET /wallethero-api/segments/:id

Fetches a single segment by ID.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Example Request

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

Response (200)

json
{
  "data": { "id": "SEGMENT_ID", "workspace_id": "WORKSPACE_ID", "name": "VIP Members", "filters": [] }
}

SDK

typescript
const { data: segment } = await wh.segments.get("SEGMENT_ID");

Update Segment

PATCH /wallethero-api/segments/:id

Updates a segment. Any workspace_id in the body is stripped. Supplying filters replaces the existing filter array.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Request Body

FieldTypeRequiredDescription
namestringNoNew name
descriptionstringNoNew description
filtersSegmentFilter[]NoReplacement filter array

Example Request

bash
curl -X PATCH "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Super VIP Members" }'

Response (200)

json
{ "data": { "id": "SEGMENT_ID", "name": "Super VIP Members", "filters": [] } }

SDK

typescript
const { data } = await wh.segments.update("SEGMENT_ID", { name: "Super VIP Members" });

Delete Segment

DELETE /wallethero-api/segments/:id

Deletes a segment.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Example Request

bash
curl -X DELETE "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{ "message": "Segment deleted" }

SDK

typescript
await wh.segments.delete("SEGMENT_ID");

Duplicate Segment

POST /wallethero-api/segments/:id/duplicate

Creates a copy of the segment, including its filters.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier to copy

Request Body

FieldTypeRequiredDescription
namestringNoName for the new segment

Example Request

bash
curl -X POST "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID/duplicate" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "name": "VIP Members (copy)" }'

Response (200)

json
{ "data": { "id": "44444444-4444-4444-4444-444444444444", "name": "VIP Members (copy)", "filters": [] } }

SDK

typescript
const segment = await wh.segments.duplicate("SEGMENT_ID", "VIP Members (copy)");

Calculate Segment Size

POST /wallethero-api/segments/:id/calculate

Computes the number of clients matching the segment's filters.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Example Request

bash
curl -X POST "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID/calculate" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{ "data": { "total": 1542 } }

SDK

typescript
const size = await wh.segments.calculateSize("SEGMENT_ID");
console.log(size.total);

Count Segment Clients

GET /wallethero-api/segments/:id/client-count

Returns the matching client count — the same result as Calculate Segment Size, via a GET.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Example Request

bash
curl "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID/client-count" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{ "data": { "total": 1542 } }

SDK

No SDK method — call the REST endpoint directly, or use segments.calculateSize().


Preview Segment Clients

GET /wallethero-api/segments/:id/preview

Returns a sample of the clients in the segment.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Query Parameters

ParameterTypeRequiredDefaultDescription
limitnumberNo100Max clients to return

Example Request

bash
curl "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID/preview?limit=50" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{
  "data": [
    { "id": "client-1", "first_name": "Jane", "last_name": "Doe", "email": "[email protected]" }
  ]
}

SDK

typescript
const clients = await wh.segments.preview("SEGMENT_ID", 50);

Get Segment Clients

GET /wallethero-api/segments/:id/clients

Returns the clients in the segment (same evaluation as preview; intended for fetching the full list).

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Query Parameters

ParameterTypeRequiredDefaultDescription
limitnumberNo100Max clients to return

Example Request

bash
curl "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID/clients?limit=500" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{
  "data": [
    { "id": "client-1", "first_name": "Jane", "last_name": "Doe", "email": "[email protected]" }
  ]
}

SDK

typescript
const clients = await wh.segments.getClients("SEGMENT_ID", 500);

Get Segment Passes

GET /wallethero-api/segments/:id/passes

Returns the clients in the segment. Functionally identical to Get Segment Clients; kept for backward compatibility.

Auth: Bearer token — workspace member (resolved from the segment row).

Path Parameters

ParameterTypeDescription
idstring (UUID)Segment identifier

Query Parameters

ParameterTypeRequiredDefaultDescription
limitnumberNo100Max items to return

Example Request

bash
curl "https://api.wallethero.app/wallethero-api/segments/SEGMENT_ID/passes?limit=100" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response (200)

json
{ "data": [ { "id": "client-1", "first_name": "Jane", "email": "[email protected]" } ] }

SDK

typescript
// Deprecated — prefer getClients()
const passes = await wh.segments.getPasses("SEGMENT_ID", 100);

WalletHero Documentation