Skip to main content
TroopyDocs
Open Troopy
Troopy

API reference / Customers

Save a segment of customers

Saves some rules that pick customers. A customer is in the segment when every rule is true for it. A workspace keeps 50 segments.

post/api/v1/customer-segments

Authorization

HeaderAuthorization: Bearer <API key>
Or the headerX-API-Key: <API key>
API keyMake one in Troopy under Settings > API keys. It acts as you, in its workspace.

Other ways to call it

CLItroopy customers segment-add
MCP toolNone. Call it over REST or with the CLI.
Rate limit30 calls in 60 seconds, for each key
RetriesSend an Idempotency-Key header. A retry with the same key gets the first answer back, and the operation runs one time.

Body

application/json
name*string

At least 1 characters · At most 60 characters

rules*array<object>

At most 6 items

3 properties
field*enum<string>

statusplanriskpayingactivatedsteadychannelsourcecountrytrait

keystring

For trait: the name of the trait

values*array<string>

The customer has one of these values. For paying, activated and steady: yes or no

At most 20 items

sharedboolean

false: only the person who made it sees it

Default true

Response

201 · application/json
data*object
7 properties
id*string

A 24-character id

name*string
rules*array<object>

A customer is in the segment when every rule is true for it

3 properties
field*enum<string>

statusplanriskpayingactivatedsteadychannelsourcecountrytrait

keystring

For trait: the name of the trait

values*array<string>

The customer has one of these values. For paying, activated and steady: yes or no

At most 20 items

shared*boolean

true: everyone in the workspace sees it. false: only the person who made it

by*object

Who made it

2 properties
type*string
name*string | null
customers*integer

The customers in the segment now

createdAt*string

ISO 8601 date and time

Errors

400 invalid_inputFix the field named in detail. Each operation's schema is in /api/v1/openapi.json.
401 unauthorizedSend an API key as `Authorization: Bearer tr_live_...`. Create one in Troopy under Settings.
403 forbiddenThe key lacks a scope this operation needs, or its owner lacks the role. detail says which; create a key with the scope, or ask an organization owner or admin.
409 conflictThis Idempotency-Key was used for a different request, or that request is still running. Use a new key for a new request.
429 rate_limitedWait the number of seconds in Retry-After, then retry.