Segments
Create and manage Segments
Retrieve a list of segments
GET /segments
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Number of items to return. |
after | string | no | Return items after this cursor. |
before | string | no | Return items before this cursor. |
Example
curl -X GET "$SESAMESEND_URL/segments" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"object": "list",
"has_more": true,
"data": [
{
"id": "string",
"name": "string",
"audience_id": "string",
"created_at": "2023-10-06 23:47:56.678+00"
}
]
}Create a new segment
POST /segments
Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | The name of the segment. |
audience_id | string | no | The ID of the audience this segment belongs to. |
filter | object | no | Filter conditions for the segment. |
Example
curl -X POST "$SESAMESEND_URL/segments" \
-H "Authorization: Bearer $OPENSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "string"
}'Responses
| Status | Description |
|---|---|
201 | OK |
{
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"object": "segment"
}Retrieve a single segment
GET /segments/{id}
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Segment ID. |
Example
curl -X GET "$SESAMESEND_URL/segments/<id>" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"object": "segment",
"name": "Active Users",
"audience_id": "string",
"filter": {},
"created_at": "2023-10-06 23:47:56.678+00"
}Update an existing segment
PATCH /segments/{id}
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Segment ID. |
Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | The name of the segment. |
Example
curl -X PATCH "$SESAMESEND_URL/segments/<id>" \
-H "Authorization: Bearer $OPENSEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "string"
}'Responses
| Status | Description |
|---|---|
200 | OK |
{
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"object": "segment"
}Remove an existing segment
DELETE /segments/{id}
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Segment ID. |
Example
curl -X DELETE "$SESAMESEND_URL/segments/<id>" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"id": "78261eea-8f8b-4381-83c6-79fa7120f1cf",
"object": "segment",
"deleted": true
}Retrieve a list of contacts in a segment
GET /segments/{id}/contacts
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The Segment ID. |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Number of items to return. |
after | string | no | Return items after this cursor. |
before | string | no | Return items before this cursor. |
Example
curl -X GET "$SESAMESEND_URL/segments/<id>/contacts" \
-H "Authorization: Bearer $OPENSEND_API_KEY"Responses
| Status | Description |
|---|---|
200 | OK |
{
"object": "list",
"has_more": false,
"data": [
{
"id": "e169aa45-1ecf-4183-9955-b1499d5701d3",
"email": "ada@example.com",
"first_name": "Ada",
"last_name": "Lovelace",
"created_at": "2023-10-06 23:47:56.678+00",
"unsubscribed": false
}
]
}