/v1/workspaces/{workspace_id}/segments/previewAuthPreview a segment rule
Counts the contacts a rule selects and returns the newest few, without saving anything.
Path parameters
workspace_id*string · uuidId of the workspace.
Request body
rule*objectmatch*object`all`: every condition must hold (AND). `any`: at least one (OR).
conditions*arrayThe conditions; a contact matches when it meets all of them.
Response · 200
metrics*objectsegment_id*string · uuidNull on a preview.
contact_count*numberContacts in the segment now.
Example: 1240
unsubscribed_count*numberOf those, globally unsubscribed.
Example: 31
unsubscribed_share*number`unsubscribed_count / contact_count`, 0 to 1 (4 decimals); 0 for an empty segment.
Example: 0.025
consented_count*numberOf those, with a recorded marketing consent.
Example: 1100
computed_at*string · date-timeWhen the counts were taken (rule segments change as contacts do).
sample*arrayUp to 5 matching contacts, newest first.
Example
Request
POST https://api.mail.productcraft.co/v1/workspaces/{workspace_id}/segments/preview
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"rule": {
"match": {},
"conditions": [
{
"field": "plan",
"operator": {},
"value": "pro"
}
]
}
}Response
{
"metrics": {
"segment_id": "00000000-0000-0000-0000-000000000000",
"contact_count": 1240,
"unsubscribed_count": 31,
"unsubscribed_share": 0.025,
"consented_count": 1100,
"computed_at": "2026-01-01T00:00:00.000Z"
},
"sample": [
{
"id": "00000000-0000-0000-0000-000000000000",
"email": "ada@example.com",
"first_name": "string",
"last_name": "string",
"unsubscribed": false,
"unsubscribed_at": "2026-01-01T00:00:00.000Z",
"properties": {
"company": "Acme"
},
"consented_at": "2026-01-01T00:00:00.000Z",
"consent_source": "signup-form-2026",
"created_via": {},
"created_at": "2026-01-01T00:00:00.000Z",
"updated_at": "2026-01-01T00:00:00.000Z"
}
]
}