customers toolset
save_segment
Create or update a segment. Creates a segment (no id: name and rules) or updates one (id). Rules use the filter DSL over user and company fields; preview_segment shows who matches first. Membership is evaluated live, so it follows changes to users and companies. Nobody is emailed. Managers and owners.
- Toolset
- customers
- Who can call it
- OwnersManagersAPI keys
- REST
POST /api/v1/w/{workspace}/segments- Behavior
- changes dataidempotentaccepts idempotency_key
Input
| Field | Type | Description |
|---|---|---|
id | string | The segment's ID or name, to update it. |
name | string | |
description | string or null | |
rules | object | Filter DSL (Appendix A) over user and company fields: email, email_domain, company, mrr, renewal_date, renewal_risk, created_at, last_active_at, attr.<key>. Company fields match any of the user's companies. Example: {"all":[{"field":"mrr","op":"gte","value":1000},{"field":"attr.plan","op":"eq","value":"enterprise"}]} |
expected_version | integer | The segment's version from your last read; the call fails if it changed since. |
idempotency_key | string | Retry-safe key. Repeating a call with the same key returns the first result. |
Output
| Field | Type | Description |
|---|---|---|
segmentrequired | object | |
createdrequired | boolean |
Calling it
// MCP: tools/call
{ "name": "save_segment", "arguments": {} }
// Typed client
await carechannel.save_segment({});