Name an audience, optionally defined by a filter over your contacts.
Body
Body| Field | Type | Description |
|---|
name* | string | Up to 200 characters, unique among live segments. |
filter | object | null | { all | any | not: [ … ] } over { field, op, value } and { topic, subscription } conditions. Omit it for a segment with explicit membership only. |
curl -X POST "https://api.rasket.com/segments" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0" \
-H "Content-Type: application/json" \
-d '{
"name": "Trial accounts",
"filter": {
"all": [
{
"field": "properties.plan",
"op": "eq",
"value": "trial"
},
{
"field": "created_at",
"op": "gte",
"value": "2026-09-01T00:00:00Z"
}
]
}
}'
const response = await fetch("https://api.rasket.com/segments", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Trial accounts",
filter: {
all: [
{
field: "properties.plan",
op: "eq",
value: "trial"
},
{
field: "created_at",
op: "gte",
value: "2026-09-01T00:00:00Z"
}
]
}
}),
});
const { id } = await response.json();
import os
import requests
response = requests.post(
"https://api.rasket.com/segments",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
json={
"name": "Trial accounts",
"filter": {
"all": [
{
"field": "properties.plan",
"op": "eq",
"value": "trial"
},
{
"field": "created_at",
"op": "gte",
"value": "2026-09-01T00:00:00Z"
}
]
}
},
)
id = response.json()["id"]
Response 201
{
"object": "segment",
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf"
}
- The filter is checked against your contact properties when the segment is created: an undeclared property, or an operator that does not suit its type, is
422 validation_error with one errors[] entry per condition. - Membership is evaluated when it is read and when a broadcast is sent, never stored — a contact that starts matching is in the segment from that moment.
Every live segment, newest first.
Query parameters
Query parameters| Field | Type | Description |
|---|
limit | integer | How many items to return, 1–100. Defaults to 20. |
after | string | Return the page that follows this item ID. Mutually exclusive with before. |
before | string | Return the page that precedes this item ID. Mutually exclusive with after. |
curl -X GET "https://api.rasket.com/segments" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0"
const response = await fetch("https://api.rasket.com/segments", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
},
});
const data = await response.json();
import os
import requests
response = requests.get(
"https://api.rasket.com/segments",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
)
print(response.json())
Response 200
{
"object": "list",
"has_more": false,
"data": [
{
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"name": "Trial accounts",
"created_at": "2026-09-08T22:22:17.595Z"
}
]
}
- List items carry no
filter; retrieve a segment for it.
One segment, with its filter.
Path parameters
Path parameters| Field | Type | Description |
|---|
segment* | string | The segment's ID. |
curl -X GET "https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0"
const response = await fetch("https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
},
});
const { id } = await response.json();
import os
import requests
response = requests.get(
"https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
)
id = response.json()["id"]
Response 200
{
"object": "segment",
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"name": "Trial accounts",
"filter": {
"all": [
{
"field": "properties.plan",
"op": "eq",
"value": "trial"
},
{
"field": "created_at",
"op": "gte",
"value": "2026-09-01T00:00:00Z"
}
]
},
"created_at": "2026-09-08T22:22:17.595Z"
}
filter is null for a segment with explicit membership only.
Change the name. The filter is fixed.
Path parameters
Path parameters| Field | Type | Description |
|---|
segment* | string | The segment's ID. |
Body
Body| Field | Type | Description |
|---|
name* | string | The new name. |
curl -X PATCH "https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0" \
-H "Content-Type: application/json" \
-d '{
"name": "Trials, September"
}'
const response = await fetch("https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf", {
method: "PATCH",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Trials, September"
}),
});
const { id } = await response.json();
import os
import requests
response = requests.patch(
"https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
json={
"name": "Trials, September"
},
)
id = response.json()["id"]
Response 200
{
"object": "segment",
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf"
}
- A
filter in the body is 422 invalid_parameter rather than silently dropped. A different audience is a new segment, so that a sent broadcast's report keeps naming the audience it went to.
Retire the segment and free its name.
Path parameters
Path parameters| Field | Type | Description |
|---|
segment* | string | The segment's ID. |
curl -X DELETE "https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0"
const response = await fetch("https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
},
});
const { id } = await response.json();
import os
import requests
response = requests.delete(
"https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
)
id = response.json()["id"]
Response 200
{
"object": "segment",
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"deleted": true
}
- The segment is
404 from that moment. Past broadcasts that went to it keep their report; a draft that names it cannot be sent until it names another.
How many contacts the segment resolves to right now.
Path parameters
Path parameters| Field | Type | Description |
|---|
segment* | string | The segment's ID. |
curl -X GET "https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf/metrics" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0"
const response = await fetch("https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf/metrics", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
},
});
const data = await response.json();
import os
import requests
response = requests.get(
"https://api.rasket.com/segments/78261eea-8f8b-4381-83c6-79fa7120f1cf/metrics",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
)
print(response.json())
Response 200
{
"object": "segment_metrics",
"segment_id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"contacts": 1240,
"subscribed": 1197,
"unsubscribed": 43
}
- One pass over the same membership
/contacts lists, split on the global unsubscribe.
How many contacts a filter matches right now, without creating a segment.
Body
Body| Field | Type | Description |
|---|
filter* | object | A filter exactly as POST /segments takes it. |
curl -X POST "https://api.rasket.com/segments/preview" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0" \
-H "Content-Type: application/json" \
-d '{
"filter": {
"all": [
{
"field": "properties.plan",
"op": "eq",
"value": "trial"
},
{
"field": "created_at",
"op": "gte",
"value": "2026-09-01T00:00:00Z"
}
]
}
}'
const response = await fetch("https://api.rasket.com/segments/preview", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
"Content-Type": "application/json",
},
body: JSON.stringify({
filter: {
all: [
{
field: "properties.plan",
op: "eq",
value: "trial"
},
{
field: "created_at",
op: "gte",
value: "2026-09-01T00:00:00Z"
}
]
}
}),
});
const data = await response.json();
import os
import requests
response = requests.post(
"https://api.rasket.com/segments/preview",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
json={
"filter": {
"all": [
{
"field": "properties.plan",
"op": "eq",
"value": "trial"
},
{
"field": "created_at",
"op": "gte",
"value": "2026-09-01T00:00:00Z"
}
]
}
},
)
print(response.json())
Response 200
{
"object": "segment_preview",
"contacts": 1284
}
- Nothing is stored. A filter
POST /segments would refuse is 422 validation_error here, with the same errors[] paths.