curl --request POST \
--url https://api.paigeme.dev/v1/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"filter": {
"opted_in": true,
"tags": [
"<string>"
],
"clicked": "<string>",
"name_contains": "<string>",
"number_contains": "<string>",
"include_ids": [
123
]
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
filter: {
opted_in: true,
tags: ['<string>'],
clicked: '<string>',
name_contains: '<string>',
number_contains: '<string>',
include_ids: [123]
}
})
};
fetch('https://api.paigeme.dev/v1/segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.paigeme.dev/v1/segments"
payload = {
"name": "<string>",
"filter": {
"opted_in": True,
"tags": ["<string>"],
"clicked": "<string>",
"name_contains": "<string>",
"number_contains": "<string>",
"include_ids": [123]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"success": true,
"data": {
"segment": {
"id": "<string>",
"project_id": "<string>",
"name": "<string>",
"filter": {},
"contact_count": 123,
"created_at": "<string>",
"updated_at": "<string>"
}
}
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}Create + save a reusable audience segment
Saves the filter under a name you can reuse as segment_id when assembling a broadcast. A project is capped at 100 segments, and names must be unique (409).
Required scope: broadcasts:manage
curl --request POST \
--url https://api.paigeme.dev/v1/segments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"filter": {
"opted_in": true,
"tags": [
"<string>"
],
"clicked": "<string>",
"name_contains": "<string>",
"number_contains": "<string>",
"include_ids": [
123
]
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
filter: {
opted_in: true,
tags: ['<string>'],
clicked: '<string>',
name_contains: '<string>',
number_contains: '<string>',
include_ids: [123]
}
})
};
fetch('https://api.paigeme.dev/v1/segments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.paigeme.dev/v1/segments"
payload = {
"name": "<string>",
"filter": {
"opted_in": True,
"tags": ["<string>"],
"clicked": "<string>",
"name_contains": "<string>",
"number_contains": "<string>",
"include_ids": [123]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"success": true,
"data": {
"segment": {
"id": "<string>",
"project_id": "<string>",
"name": "<string>",
"filter": {},
"contact_count": 123,
"created_at": "<string>",
"updated_at": "<string>"
}
}
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}{
"success": false,
"error": {
"code": "invalid_request",
"message": "Invalid request body",
"details": {}
},
"request_id": "<string>"
}Authorizations
Project API key issued in Settings → API keys. Send it as Authorization: Bearer pk_live_….
Headers
Target project id, for an MCP OAuth bearer (mcp_at_…) attached to more than one project — get ids from GET /v1/projects. Matched case-insensitively.
Omit it and a READ falls back to the connection's default project; a mutation (any non-GET) on a connection with 2+ projects is rejected with 400 project_required — a write is never defaulted to a guessed project. A connection with exactly one project never needs the header.
Scopes are checked against the SELECTED project only, never a union across the connection.
For a pk_ API key the header selects nothing — one key is one project's context — but it IS validated: omit it and the key's own project is used, send it and it must name that project, otherwise the call is rejected with 403 project_not_attached (a blank value is 400 invalid_project_header, as above).
Body
1 - 255Hide child attributes
Hide child attributes
When true, only opted-in contacts match.
Contacts matching ANY of these tags (max 50).
Contacts who tapped a button/list item, by title/payload/id. String, or { value, since?: ISO date }.
Case-insensitive substring match on contact name.
Case-insensitive substring match on contact phone number.
Hand-picked contact ids (max 500). UNIONed on top of the other criteria — a contact here is targeted even if it matches none of them. IMPORTANT: when include_ids is the ONLY criterion set (no tags, no name_contains/number_contains, no clicked, and opted_in is not false), the audience is EXACTLY these contacts and nothing else. Opted-out and confirmed-not-on-WhatsApp contacts are still excluded either way.
Response
Success.
true Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Pass this as segment_id when assembling a broadcast.
The normalized filter, as stored.
Live count when the segment was written. NULL means the count could not be resolved — the segment is still saved and re-counts on read.
Was this page helpful?
