New: every plan now includes free incoming texts and rollover credits. See pricing →
Search Help Center Documentation

API reference

Segments

Saved filters over your contacts (area code, name, email, status, source, list, when added, custom fields), worked out each time they are used. Use them as campaign audiences, to enroll people in workflows, or to filter contacts. See SegmentRule for the rule format.

List segments

GET/v1/segments

All your segments, newest first, each with how many contacts match it now.

Request

curl https://app.smsblast.net/v1/segments \
  -H "Authorization: Bearer $SMSBLAST_API_KEY"
const res = await fetch('https://app.smsblast.net/v1/segments', {
  headers: {
    Authorization: `Bearer ${process.env.SMSBLAST_API_KEY}`,
  },
});
console.log(res.status, await res.json());
import os

import requests

res = requests.get(
    "https://app.smsblast.net/v1/segments",
    headers={
        "Authorization": f"Bearer {os.environ['SMSBLAST_API_KEY']}",
    },
)
print(res.status_code, res.json())
Response · 200
{
  "segments": [
    {
      "id": "4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53",
      "account_id": "5d0c6a2e-8f43-4b8a-9c1d-2e7f4a6b3c10",
      "name": "San Francisco sourdough fans",
      "description": null,
      "match": "all",
      "rules": [
        {
          "field": "area_code",
          "op": "is",
          "value": "415, 628"
        },
        {
          "field": "custom",
          "key": "favorite_bread",
          "op": "equals",
          "value": "Sourdough"
        }
      ],
      "created_at": "2026-11-05T19:11:42.250Z",
      "total": 236,
      "subscribed": 229
    }
  ]
}

Needs an API key: Authorization: Bearer sb_... Authentication

Query parameters#

searchstring

Only segments whose name contains this text (ignoring case).

Responses#

200

Your segments.

application/json

segmentsarray of objectsrequired

Newest first.

Fields of each item
idstringuuidrequired

The segment id.

account_idstringuuidrequired

Your account id.

namestringrequired

The segment name.

descriptionstringnullablerequired

A note about the segment.

matchstringrequired

all: a contact must match every rule. any: one rule is enough.

One of "all", "any".

rulesarray of objectsrequired

1 to 20 rules.

Fields of each item

One of these shapes:

field: area_code

Contacts by the area code of their number.

fieldstringrequired

Always "area_code".

opstringrequired

Whether the number is (or is not) in one of the area codes.

One of "is", "is_not".

valuestringrequired

One or more 3-digit area codes, separated by spaces or commas.

field: first_name, last_name, email

Contacts by first name, last name or email.

fieldstringrequired

The contact field.

One of "first_name", "last_name", "email".

opstringrequired

equals and contains ignore case.

One of "is_set", "is_not_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: status

Contacts by subscription status.

fieldstringrequired

Always "status".

opstringrequired

Always "is".

valuestringrequired

The status.

One of "subscribed", "unsubscribed".

field: source

Contacts by how they joined.

fieldstringrequired

Always "source".

opstringrequired

Whether the contact came (or did not come) from this source.

One of "is", "is_not".

valuestringrequired

Where the contact came from. keyword matches every signup keyword and web_form every signup form.

One of "import", "keyword", "sms", "manual", "api", "web_form".

field: list

Contacts by list membership.

fieldstringrequired

Always "list".

opstringrequired

Whether the contact is (or is not) on the list.

One of "in", "not_in".

valuestringuuidrequired

The list id.

field: created

Contacts by when they were added.

fieldstringrequired

Always "created".

opstringrequired

within_days: added in the last N days. after: added on or after the date. before: added before the date.

One of "within_days", "after", "before".

valueinteger or stringrequired

For within_days, a whole number of days from 1 to 3650. For after and before, a date like 2026-11-30.

field: custom

Contacts by a custom field.

fieldstringrequired

Always "custom".

keystringrequired

The custom field name, as in the contact's fields.

opstringrequired

equals and contains ignore case.

One of "is_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: clicked

Contacts by tracked link clicks.

fieldstringrequired

Always "clicked".

opstringrequired

campaign: clicked a tracked link in that campaign. not_campaign: was sent that campaign but clicked none of its links. within_days: clicked any tracked link in the last N days.

One of "campaign", "not_campaign", "within_days".

valuestring or integerrequired

A campaign id for campaign and not_campaign; a whole number of days from 1 to 3650 for within_days.

field: replied

Contacts by whether they text you.

fieldstringrequired

Always "replied".

opstringrequired

within_days: texted you anything in the last N days. never: has never texted you.

One of "within_days", "never".

valueinteger

For within_days, a whole number of days from 1 to 3650.

Limits: 1 to 3650.

created_atstringdate-timerequired

When the segment was created.

totalintegerrequired

Contacts matching the segment now.

subscribedintegerrequired

Of those, subscribed contacts (the ones a campaign would reach).

Response headers
X-Request-Idstring Guide

The id of this request (req_...), on every answer. Quote it when you contact support.

X-RateLimit-Limitinteger Guide

Requests allowed per minute with this API key.

X-RateLimit-Remaininginteger Guide

Requests left in the current minute.

X-RateLimit-Resetinteger Guide

When the current minute ends and the count starts again, in Unix seconds.

401

No API key, or one that is not valid or has been revoked (unauthorized).

429

Too many requests with this API key (rate_limited). Wait for the number of seconds in Retry-After.

Every error has the same body: {"error": {"code", "message", "details", "requestId"}}. See Errors.

Create a segment

POST/v1/segments

Saves a filter over your contacts, such as "area code 415 or 628 and favourite bread is sourdough". A segment is worked out each time it is used, so it always reflects your contacts as they are. Use it as a campaign audience, to enroll people in a workflow, or to filter GET /v1/contacts.

A segment has 1 to 20 rules (see SegmentRule) and match: all (every rule) or any (at least one). Try rules first with POST /v1/segments/preview.

Request

curl -X POST https://app.smsblast.net/v1/segments \
  -H "Authorization: Bearer $SMSBLAST_API_KEY" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "San Francisco sourdough fans",
    "match": "all",
    "rules": [
      {
        "field": "area_code",
        "op": "is",
        "value": "415, 628"
      },
      {
        "field": "custom",
        "key": "favorite_bread",
        "op": "equals",
        "value": "Sourdough"
      }
    ]
  }'
const res = await fetch('https://app.smsblast.net/v1/segments', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SMSBLAST_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'San Francisco sourdough fans',
    match: 'all',
    rules: [
      {
        field: 'area_code',
        op: 'is',
        value: '415, 628',
      },
      {
        field: 'custom',
        key: 'favorite_bread',
        op: 'equals',
        value: 'Sourdough',
      },
    ],
  }),
});
console.log(res.status, await res.json());
import os
import uuid

import requests

res = requests.post(
    "https://app.smsblast.net/v1/segments",
    headers={
        "Authorization": f"Bearer {os.environ['SMSBLAST_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "name": "San Francisco sourdough fans",
        "match": "all",
        "rules": [
            {
                "field": "area_code",
                "op": "is",
                "value": "415, 628",
            },
            {
                "field": "custom",
                "key": "favorite_bread",
                "op": "equals",
                "value": "Sourdough",
            },
        ],
    },
)
print(res.status_code, res.json())
Response · 201
{
  "segment": {
    "id": "4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53",
    "account_id": "5d0c6a2e-8f43-4b8a-9c1d-2e7f4a6b3c10",
    "name": "San Francisco sourdough fans",
    "description": null,
    "match": "all",
    "rules": [
      {
        "field": "area_code",
        "op": "is",
        "value": "415, 628"
      },
      {
        "field": "custom",
        "key": "favorite_bread",
        "op": "equals",
        "value": "Sourdough"
      }
    ],
    "created_at": "2026-11-05T19:11:42.250Z"
  }
}

Needs an API key: Authorization: Bearer sb_... Authentication

Headers#

Idempotency-Keystring Guide

Any unique string up to 200 characters (a UUID works well). If a POST times out or you are not sure it went through, send it again with the same key and the same body: you get the first answer back (with Idempotent-Replayed: true) instead of the work being done twice. Keys are kept for 24 hours per account.

Limits: up to 200 characters.

Example "2b5c4f8e-order-1042".

Request body#

application/json · required

namestringrequired

The segment name, up to 120 characters.

descriptionstringnullable

A note, up to 300 characters. Leaving it out clears it.

matchstring

any to match contacts that meet any rule; anything else means all.

One of "all", "any".

rulesarray of objectsrequired

1 to 20 rules.

Limits: 1 to 20 items.

Fields of each item

One of these shapes:

field: area_code

Contacts by the area code of their number.

fieldstringrequired

Always "area_code".

opstringrequired

Whether the number is (or is not) in one of the area codes.

One of "is", "is_not".

valuestringrequired

One or more 3-digit area codes, separated by spaces or commas.

field: first_name, last_name, email

Contacts by first name, last name or email.

fieldstringrequired

The contact field.

One of "first_name", "last_name", "email".

opstringrequired

equals and contains ignore case.

One of "is_set", "is_not_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: status

Contacts by subscription status.

fieldstringrequired

Always "status".

opstringrequired

Always "is".

valuestringrequired

The status.

One of "subscribed", "unsubscribed".

field: source

Contacts by how they joined.

fieldstringrequired

Always "source".

opstringrequired

Whether the contact came (or did not come) from this source.

One of "is", "is_not".

valuestringrequired

Where the contact came from. keyword matches every signup keyword and web_form every signup form.

One of "import", "keyword", "sms", "manual", "api", "web_form".

field: list

Contacts by list membership.

fieldstringrequired

Always "list".

opstringrequired

Whether the contact is (or is not) on the list.

One of "in", "not_in".

valuestringuuidrequired

The list id.

field: created

Contacts by when they were added.

fieldstringrequired

Always "created".

opstringrequired

within_days: added in the last N days. after: added on or after the date. before: added before the date.

One of "within_days", "after", "before".

valueinteger or stringrequired

For within_days, a whole number of days from 1 to 3650. For after and before, a date like 2026-11-30.

field: custom

Contacts by a custom field.

fieldstringrequired

Always "custom".

keystringrequired

The custom field name, as in the contact's fields.

opstringrequired

equals and contains ignore case.

One of "is_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: clicked

Contacts by tracked link clicks.

fieldstringrequired

Always "clicked".

opstringrequired

campaign: clicked a tracked link in that campaign. not_campaign: was sent that campaign but clicked none of its links. within_days: clicked any tracked link in the last N days.

One of "campaign", "not_campaign", "within_days".

valuestring or integerrequired

A campaign id for campaign and not_campaign; a whole number of days from 1 to 3650 for within_days.

field: replied

Contacts by whether they text you.

fieldstringrequired

Always "replied".

opstringrequired

within_days: texted you anything in the last N days. never: has never texted you.

One of "within_days", "never".

valueinteger

For within_days, a whole number of days from 1 to 3650.

Limits: 1 to 3650.

Example request body
Request body
{
  "name": "San Francisco sourdough fans",
  "match": "all",
  "rules": [
    {
      "field": "area_code",
      "op": "is",
      "value": "415, 628"
    },
    {
      "field": "custom",
      "key": "favorite_bread",
      "op": "equals",
      "value": "Sourdough"
    }
  ]
}

Responses#

201

The new segment.

application/json

segmentobjectrequired

A saved filter over your contacts. It is worked out each time it is used, so it is always current.

Child fields
idstringuuidrequired

The segment id.

account_idstringuuidrequired

Your account id.

namestringrequired

The segment name.

descriptionstringnullablerequired

A note about the segment.

matchstringrequired

all: a contact must match every rule. any: one rule is enough.

One of "all", "any".

rulesarray of objectsrequired

1 to 20 rules.

Fields of each item

One of these shapes:

field: area_code

Contacts by the area code of their number.

fieldstringrequired

Always "area_code".

opstringrequired

Whether the number is (or is not) in one of the area codes.

One of "is", "is_not".

valuestringrequired

One or more 3-digit area codes, separated by spaces or commas.

field: first_name, last_name, email

Contacts by first name, last name or email.

fieldstringrequired

The contact field.

One of "first_name", "last_name", "email".

opstringrequired

equals and contains ignore case.

One of "is_set", "is_not_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: status

Contacts by subscription status.

fieldstringrequired

Always "status".

opstringrequired

Always "is".

valuestringrequired

The status.

One of "subscribed", "unsubscribed".

field: source

Contacts by how they joined.

fieldstringrequired

Always "source".

opstringrequired

Whether the contact came (or did not come) from this source.

One of "is", "is_not".

valuestringrequired

Where the contact came from. keyword matches every signup keyword and web_form every signup form.

One of "import", "keyword", "sms", "manual", "api", "web_form".

field: list

Contacts by list membership.

fieldstringrequired

Always "list".

opstringrequired

Whether the contact is (or is not) on the list.

One of "in", "not_in".

valuestringuuidrequired

The list id.

field: created

Contacts by when they were added.

fieldstringrequired

Always "created".

opstringrequired

within_days: added in the last N days. after: added on or after the date. before: added before the date.

One of "within_days", "after", "before".

valueinteger or stringrequired

For within_days, a whole number of days from 1 to 3650. For after and before, a date like 2026-11-30.

field: custom

Contacts by a custom field.

fieldstringrequired

Always "custom".

keystringrequired

The custom field name, as in the contact's fields.

opstringrequired

equals and contains ignore case.

One of "is_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: clicked

Contacts by tracked link clicks.

fieldstringrequired

Always "clicked".

opstringrequired

campaign: clicked a tracked link in that campaign. not_campaign: was sent that campaign but clicked none of its links. within_days: clicked any tracked link in the last N days.

One of "campaign", "not_campaign", "within_days".

valuestring or integerrequired

A campaign id for campaign and not_campaign; a whole number of days from 1 to 3650 for within_days.

field: replied

Contacts by whether they text you.

fieldstringrequired

Always "replied".

opstringrequired

within_days: texted you anything in the last N days. never: has never texted you.

One of "within_days", "never".

valueinteger

For within_days, a whole number of days from 1 to 3650.

Limits: 1 to 3650.

created_atstringdate-timerequired

When the segment was created.

Response headers
X-Request-Idstring Guide

The id of this request (req_...), on every answer. Quote it when you contact support.

X-RateLimit-Limitinteger Guide

Requests allowed per minute with this API key.

X-RateLimit-Remaininginteger Guide

Requests left in the current minute.

X-RateLimit-Resetinteger Guide

When the current minute ends and the count starts again, in Unix seconds.

Idempotent-Replayedstring Guide

true when this is the stored answer to an earlier request with the same Idempotency-Key, not a new one.

One of "true".

400

The request was refused because something in it is not valid. error.code is one of:

  • invalid_name: name is missing or empty.
  • no_rules: rules is missing or empty.
  • too_many_rules: More than 20 rules.
  • invalid_rule: A rule has an unknown field or operator, or a missing or invalid value. The message says which.
  • invalid_json: The body is not a JSON object.
  • invalid_idempotency_key: The Idempotency-Key header is longer than 200 characters.
401

No API key, or one that is not valid or has been revoked (unauthorized).

409

The request clashes with the current state of things. error.code is one of:

  • idempotency_in_progress: A request with the same Idempotency-Key is still running. Try again in a moment.
422

This Idempotency-Key was already used for a different request (another path or body) in the last 24 hours (idempotency_key_reused). Use a new key for each new request.

429

Too many requests with this API key (rate_limited). Wait for the number of seconds in Retry-After.

Every error has the same body: {"error": {"code", "message", "details", "requestId"}}. See Errors.

Count a segment before saving

POST/v1/segments/preview

Counts the contacts that match some rules, without saving anything. An empty list of rules counts nobody.

Request

curl -X POST https://app.smsblast.net/v1/segments/preview \
  -H "Authorization: Bearer $SMSBLAST_API_KEY" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{
    "match": "any",
    "rules": [
      {
        "field": "area_code",
        "op": "is",
        "value": "415"
      },
      {
        "field": "created",
        "op": "within_days",
        "value": 30
      }
    ]
  }'
const res = await fetch('https://app.smsblast.net/v1/segments/preview', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SMSBLAST_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    match: 'any',
    rules: [
      {
        field: 'area_code',
        op: 'is',
        value: '415',
      },
      {
        field: 'created',
        op: 'within_days',
        value: 30,
      },
    ],
  }),
});
console.log(res.status, await res.json());
import os
import uuid

import requests

res = requests.post(
    "https://app.smsblast.net/v1/segments/preview",
    headers={
        "Authorization": f"Bearer {os.environ['SMSBLAST_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "match": "any",
        "rules": [
            {
                "field": "area_code",
                "op": "is",
                "value": "415",
            },
            {
                "field": "created",
                "op": "within_days",
                "value": 30,
            },
        ],
    },
)
print(res.status_code, res.json())
Response · 200
{
  "total": 312,
  "subscribed": 301
}

Needs an API key: Authorization: Bearer sb_... Authentication

Headers#

Idempotency-Keystring Guide

Any unique string up to 200 characters (a UUID works well). If a POST times out or you are not sure it went through, send it again with the same key and the same body: you get the first answer back (with Idempotent-Replayed: true) instead of the work being done twice. Keys are kept for 24 hours per account.

Limits: up to 200 characters.

Example "2b5c4f8e-order-1042".

Request body#

application/json · required

matchstring

any, or anything else for all.

One of "all", "any".

rulesarray of objects

The rules to count. An empty list counts nobody.

Fields of each item

One of these shapes:

field: area_code

Contacts by the area code of their number.

fieldstringrequired

Always "area_code".

opstringrequired

Whether the number is (or is not) in one of the area codes.

One of "is", "is_not".

valuestringrequired

One or more 3-digit area codes, separated by spaces or commas.

field: first_name, last_name, email

Contacts by first name, last name or email.

fieldstringrequired

The contact field.

One of "first_name", "last_name", "email".

opstringrequired

equals and contains ignore case.

One of "is_set", "is_not_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: status

Contacts by subscription status.

fieldstringrequired

Always "status".

opstringrequired

Always "is".

valuestringrequired

The status.

One of "subscribed", "unsubscribed".

field: source

Contacts by how they joined.

fieldstringrequired

Always "source".

opstringrequired

Whether the contact came (or did not come) from this source.

One of "is", "is_not".

valuestringrequired

Where the contact came from. keyword matches every signup keyword and web_form every signup form.

One of "import", "keyword", "sms", "manual", "api", "web_form".

field: list

Contacts by list membership.

fieldstringrequired

Always "list".

opstringrequired

Whether the contact is (or is not) on the list.

One of "in", "not_in".

valuestringuuidrequired

The list id.

field: created

Contacts by when they were added.

fieldstringrequired

Always "created".

opstringrequired

within_days: added in the last N days. after: added on or after the date. before: added before the date.

One of "within_days", "after", "before".

valueinteger or stringrequired

For within_days, a whole number of days from 1 to 3650. For after and before, a date like 2026-11-30.

field: custom

Contacts by a custom field.

fieldstringrequired

Always "custom".

keystringrequired

The custom field name, as in the contact's fields.

opstringrequired

equals and contains ignore case.

One of "is_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: clicked

Contacts by tracked link clicks.

fieldstringrequired

Always "clicked".

opstringrequired

campaign: clicked a tracked link in that campaign. not_campaign: was sent that campaign but clicked none of its links. within_days: clicked any tracked link in the last N days.

One of "campaign", "not_campaign", "within_days".

valuestring or integerrequired

A campaign id for campaign and not_campaign; a whole number of days from 1 to 3650 for within_days.

field: replied

Contacts by whether they text you.

fieldstringrequired

Always "replied".

opstringrequired

within_days: texted you anything in the last N days. never: has never texted you.

One of "within_days", "never".

valueinteger

For within_days, a whole number of days from 1 to 3650.

Limits: 1 to 3650.

Example request body
Request body
{
  "match": "any",
  "rules": [
    {
      "field": "area_code",
      "op": "is",
      "value": "415"
    },
    {
      "field": "created",
      "op": "within_days",
      "value": 30
    }
  ]
}

Responses#

200

The counts.

application/json

totalintegerrequired

Contacts matching.

subscribedintegerrequired

Of those, subscribed contacts.

Response headers
X-Request-Idstring Guide

The id of this request (req_...), on every answer. Quote it when you contact support.

X-RateLimit-Limitinteger Guide

Requests allowed per minute with this API key.

X-RateLimit-Remaininginteger Guide

Requests left in the current minute.

X-RateLimit-Resetinteger Guide

When the current minute ends and the count starts again, in Unix seconds.

Idempotent-Replayedstring Guide

true when this is the stored answer to an earlier request with the same Idempotency-Key, not a new one.

One of "true".

400

The request was refused because something in it is not valid. error.code is one of:

  • invalid_rule: A rule has an unknown field or operator, or a missing or invalid value.
  • invalid_json: The body is not a JSON object.
  • invalid_idempotency_key: The Idempotency-Key header is longer than 200 characters.
401

No API key, or one that is not valid or has been revoked (unauthorized).

409

The request clashes with the current state of things. error.code is one of:

  • idempotency_in_progress: A request with the same Idempotency-Key is still running. Try again in a moment.
422

This Idempotency-Key was already used for a different request (another path or body) in the last 24 hours (idempotency_key_reused). Use a new key for each new request.

429

Too many requests with this API key (rate_limited). Wait for the number of seconds in Retry-After.

Every error has the same body: {"error": {"code", "message", "details", "requestId"}}. See Errors.

Get a segment

GET/v1/segments/{id}

One segment and how many contacts match it now. To see who, use GET /v1/contacts?segmentId=....

Request

curl https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53 \
  -H "Authorization: Bearer $SMSBLAST_API_KEY"
const res = await fetch('https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53', {
  headers: {
    Authorization: `Bearer ${process.env.SMSBLAST_API_KEY}`,
  },
});
console.log(res.status, await res.json());
import os

import requests

res = requests.get(
    "https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53",
    headers={
        "Authorization": f"Bearer {os.environ['SMSBLAST_API_KEY']}",
    },
)
print(res.status_code, res.json())
Response · 200
{
  "segment": {
    "id": "4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53",
    "account_id": "5d0c6a2e-8f43-4b8a-9c1d-2e7f4a6b3c10",
    "name": "San Francisco sourdough fans",
    "description": null,
    "match": "all",
    "rules": [
      {
        "field": "area_code",
        "op": "is",
        "value": "415, 628"
      },
      {
        "field": "custom",
        "key": "favorite_bread",
        "op": "equals",
        "value": "Sourdough"
      }
    ],
    "created_at": "2026-11-05T19:11:42.250Z"
  },
  "total": 236,
  "subscribed": 229
}

Needs an API key: Authorization: Bearer sb_... Authentication

Path parameters#

idstringuuidrequired

The segment id.

Responses#

200

The segment and its counts.

application/json

segmentobjectrequired

A saved filter over your contacts. It is worked out each time it is used, so it is always current.

Child fields
idstringuuidrequired

The segment id.

account_idstringuuidrequired

Your account id.

namestringrequired

The segment name.

descriptionstringnullablerequired

A note about the segment.

matchstringrequired

all: a contact must match every rule. any: one rule is enough.

One of "all", "any".

rulesarray of objectsrequired

1 to 20 rules.

Fields of each item

One of these shapes:

field: area_code

Contacts by the area code of their number.

fieldstringrequired

Always "area_code".

opstringrequired

Whether the number is (or is not) in one of the area codes.

One of "is", "is_not".

valuestringrequired

One or more 3-digit area codes, separated by spaces or commas.

field: first_name, last_name, email

Contacts by first name, last name or email.

fieldstringrequired

The contact field.

One of "first_name", "last_name", "email".

opstringrequired

equals and contains ignore case.

One of "is_set", "is_not_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: status

Contacts by subscription status.

fieldstringrequired

Always "status".

opstringrequired

Always "is".

valuestringrequired

The status.

One of "subscribed", "unsubscribed".

field: source

Contacts by how they joined.

fieldstringrequired

Always "source".

opstringrequired

Whether the contact came (or did not come) from this source.

One of "is", "is_not".

valuestringrequired

Where the contact came from. keyword matches every signup keyword and web_form every signup form.

One of "import", "keyword", "sms", "manual", "api", "web_form".

field: list

Contacts by list membership.

fieldstringrequired

Always "list".

opstringrequired

Whether the contact is (or is not) on the list.

One of "in", "not_in".

valuestringuuidrequired

The list id.

field: created

Contacts by when they were added.

fieldstringrequired

Always "created".

opstringrequired

within_days: added in the last N days. after: added on or after the date. before: added before the date.

One of "within_days", "after", "before".

valueinteger or stringrequired

For within_days, a whole number of days from 1 to 3650. For after and before, a date like 2026-11-30.

field: custom

Contacts by a custom field.

fieldstringrequired

Always "custom".

keystringrequired

The custom field name, as in the contact's fields.

opstringrequired

equals and contains ignore case.

One of "is_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: clicked

Contacts by tracked link clicks.

fieldstringrequired

Always "clicked".

opstringrequired

campaign: clicked a tracked link in that campaign. not_campaign: was sent that campaign but clicked none of its links. within_days: clicked any tracked link in the last N days.

One of "campaign", "not_campaign", "within_days".

valuestring or integerrequired

A campaign id for campaign and not_campaign; a whole number of days from 1 to 3650 for within_days.

field: replied

Contacts by whether they text you.

fieldstringrequired

Always "replied".

opstringrequired

within_days: texted you anything in the last N days. never: has never texted you.

One of "within_days", "never".

valueinteger

For within_days, a whole number of days from 1 to 3650.

Limits: 1 to 3650.

created_atstringdate-timerequired

When the segment was created.

totalintegerrequired

Contacts matching now.

subscribedintegerrequired

Of those, subscribed.

Response headers
X-Request-Idstring Guide

The id of this request (req_...), on every answer. Quote it when you contact support.

X-RateLimit-Limitinteger Guide

Requests allowed per minute with this API key.

X-RateLimit-Remaininginteger Guide

Requests left in the current minute.

X-RateLimit-Resetinteger Guide

When the current minute ends and the count starts again, in Unix seconds.

401

No API key, or one that is not valid or has been revoked (unauthorized).

404

Something the request names does not exist in your account. error.code is one of:

  • not_found: No segment with that id in your account.
429

Too many requests with this API key (rate_limited). Wait for the number of seconds in Retry-After.

Every error has the same body: {"error": {"code", "message", "details", "requestId"}}. See Errors.

Update a segment

PATCH/v1/segments/{id}

Replaces a segment's name, description, match and rules. Send them all: name and rules are required, and leaving description out clears it. The answer does not include counts.

Request

curl -X PATCH https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53 \
  -H "Authorization: Bearer $SMSBLAST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "San Francisco bread fans",
    "match": "all",
    "rules": [
      {
        "field": "area_code",
        "op": "is",
        "value": "415, 628"
      },
      {
        "field": "custom",
        "key": "favorite_bread",
        "op": "is_set"
      }
    ]
  }'
const res = await fetch('https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53', {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.SMSBLAST_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'San Francisco bread fans',
    match: 'all',
    rules: [
      {
        field: 'area_code',
        op: 'is',
        value: '415, 628',
      },
      {
        field: 'custom',
        key: 'favorite_bread',
        op: 'is_set',
      },
    ],
  }),
});
console.log(res.status, await res.json());
import os

import requests

res = requests.patch(
    "https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53",
    headers={
        "Authorization": f"Bearer {os.environ['SMSBLAST_API_KEY']}",
    },
    json={
        "name": "San Francisco bread fans",
        "match": "all",
        "rules": [
            {
                "field": "area_code",
                "op": "is",
                "value": "415, 628",
            },
            {
                "field": "custom",
                "key": "favorite_bread",
                "op": "is_set",
            },
        ],
    },
)
print(res.status_code, res.json())
Response · 200
{
  "segment": {
    "id": "4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53",
    "account_id": "5d0c6a2e-8f43-4b8a-9c1d-2e7f4a6b3c10",
    "name": "San Francisco bread fans",
    "description": null,
    "match": "all",
    "rules": [
      {
        "field": "area_code",
        "op": "is",
        "value": "415, 628"
      },
      {
        "field": "custom",
        "key": "favorite_bread",
        "op": "is_set"
      }
    ],
    "created_at": "2026-11-05T19:11:42.250Z"
  }
}

Needs an API key: Authorization: Bearer sb_... Authentication

Path parameters#

idstringuuidrequired

The segment id.

Request body#

application/json · required

namestringrequired

The segment name, up to 120 characters.

descriptionstringnullable

A note, up to 300 characters. Leaving it out clears it.

matchstring

any to match contacts that meet any rule; anything else means all.

One of "all", "any".

rulesarray of objectsrequired

1 to 20 rules.

Limits: 1 to 20 items.

Fields of each item

One of these shapes:

field: area_code

Contacts by the area code of their number.

fieldstringrequired

Always "area_code".

opstringrequired

Whether the number is (or is not) in one of the area codes.

One of "is", "is_not".

valuestringrequired

One or more 3-digit area codes, separated by spaces or commas.

field: first_name, last_name, email

Contacts by first name, last name or email.

fieldstringrequired

The contact field.

One of "first_name", "last_name", "email".

opstringrequired

equals and contains ignore case.

One of "is_set", "is_not_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: status

Contacts by subscription status.

fieldstringrequired

Always "status".

opstringrequired

Always "is".

valuestringrequired

The status.

One of "subscribed", "unsubscribed".

field: source

Contacts by how they joined.

fieldstringrequired

Always "source".

opstringrequired

Whether the contact came (or did not come) from this source.

One of "is", "is_not".

valuestringrequired

Where the contact came from. keyword matches every signup keyword and web_form every signup form.

One of "import", "keyword", "sms", "manual", "api", "web_form".

field: list

Contacts by list membership.

fieldstringrequired

Always "list".

opstringrequired

Whether the contact is (or is not) on the list.

One of "in", "not_in".

valuestringuuidrequired

The list id.

field: created

Contacts by when they were added.

fieldstringrequired

Always "created".

opstringrequired

within_days: added in the last N days. after: added on or after the date. before: added before the date.

One of "within_days", "after", "before".

valueinteger or stringrequired

For within_days, a whole number of days from 1 to 3650. For after and before, a date like 2026-11-30.

field: custom

Contacts by a custom field.

fieldstringrequired

Always "custom".

keystringrequired

The custom field name, as in the contact's fields.

opstringrequired

equals and contains ignore case.

One of "is_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: clicked

Contacts by tracked link clicks.

fieldstringrequired

Always "clicked".

opstringrequired

campaign: clicked a tracked link in that campaign. not_campaign: was sent that campaign but clicked none of its links. within_days: clicked any tracked link in the last N days.

One of "campaign", "not_campaign", "within_days".

valuestring or integerrequired

A campaign id for campaign and not_campaign; a whole number of days from 1 to 3650 for within_days.

field: replied

Contacts by whether they text you.

fieldstringrequired

Always "replied".

opstringrequired

within_days: texted you anything in the last N days. never: has never texted you.

One of "within_days", "never".

valueinteger

For within_days, a whole number of days from 1 to 3650.

Limits: 1 to 3650.

Example request body
Request body
{
  "name": "San Francisco bread fans",
  "match": "all",
  "rules": [
    {
      "field": "area_code",
      "op": "is",
      "value": "415, 628"
    },
    {
      "field": "custom",
      "key": "favorite_bread",
      "op": "is_set"
    }
  ]
}

Responses#

200

The segment.

application/json

segmentobjectrequired

A saved filter over your contacts. It is worked out each time it is used, so it is always current.

Child fields
idstringuuidrequired

The segment id.

account_idstringuuidrequired

Your account id.

namestringrequired

The segment name.

descriptionstringnullablerequired

A note about the segment.

matchstringrequired

all: a contact must match every rule. any: one rule is enough.

One of "all", "any".

rulesarray of objectsrequired

1 to 20 rules.

Fields of each item

One of these shapes:

field: area_code

Contacts by the area code of their number.

fieldstringrequired

Always "area_code".

opstringrequired

Whether the number is (or is not) in one of the area codes.

One of "is", "is_not".

valuestringrequired

One or more 3-digit area codes, separated by spaces or commas.

field: first_name, last_name, email

Contacts by first name, last name or email.

fieldstringrequired

The contact field.

One of "first_name", "last_name", "email".

opstringrequired

equals and contains ignore case.

One of "is_set", "is_not_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: status

Contacts by subscription status.

fieldstringrequired

Always "status".

opstringrequired

Always "is".

valuestringrequired

The status.

One of "subscribed", "unsubscribed".

field: source

Contacts by how they joined.

fieldstringrequired

Always "source".

opstringrequired

Whether the contact came (or did not come) from this source.

One of "is", "is_not".

valuestringrequired

Where the contact came from. keyword matches every signup keyword and web_form every signup form.

One of "import", "keyword", "sms", "manual", "api", "web_form".

field: list

Contacts by list membership.

fieldstringrequired

Always "list".

opstringrequired

Whether the contact is (or is not) on the list.

One of "in", "not_in".

valuestringuuidrequired

The list id.

field: created

Contacts by when they were added.

fieldstringrequired

Always "created".

opstringrequired

within_days: added in the last N days. after: added on or after the date. before: added before the date.

One of "within_days", "after", "before".

valueinteger or stringrequired

For within_days, a whole number of days from 1 to 3650. For after and before, a date like 2026-11-30.

field: custom

Contacts by a custom field.

fieldstringrequired

Always "custom".

keystringrequired

The custom field name, as in the contact's fields.

opstringrequired

equals and contains ignore case.

One of "is_set", "equals", "contains".

valuestring

The text to compare with, for equals and contains.

field: clicked

Contacts by tracked link clicks.

fieldstringrequired

Always "clicked".

opstringrequired

campaign: clicked a tracked link in that campaign. not_campaign: was sent that campaign but clicked none of its links. within_days: clicked any tracked link in the last N days.

One of "campaign", "not_campaign", "within_days".

valuestring or integerrequired

A campaign id for campaign and not_campaign; a whole number of days from 1 to 3650 for within_days.

field: replied

Contacts by whether they text you.

fieldstringrequired

Always "replied".

opstringrequired

within_days: texted you anything in the last N days. never: has never texted you.

One of "within_days", "never".

valueinteger

For within_days, a whole number of days from 1 to 3650.

Limits: 1 to 3650.

created_atstringdate-timerequired

When the segment was created.

Response headers
X-Request-Idstring Guide

The id of this request (req_...), on every answer. Quote it when you contact support.

X-RateLimit-Limitinteger Guide

Requests allowed per minute with this API key.

X-RateLimit-Remaininginteger Guide

Requests left in the current minute.

X-RateLimit-Resetinteger Guide

When the current minute ends and the count starts again, in Unix seconds.

400

The request was refused because something in it is not valid. error.code is one of:

  • invalid_name: name is missing or empty.
  • no_rules: rules is missing or empty.
  • too_many_rules: More than 20 rules.
  • invalid_rule: A rule is not valid.
  • invalid_json: The body is not a JSON object.
401

No API key, or one that is not valid or has been revoked (unauthorized).

404

Something the request names does not exist in your account. error.code is one of:

  • not_found: No segment with that id in your account.
429

Too many requests with this API key (rate_limited). Wait for the number of seconds in Retry-After.

Every error has the same body: {"error": {"code", "message", "details", "requestId"}}. See Errors.

Delete a segment

DELETE/v1/segments/{id}

Deletes a segment. Contacts are not affected. Campaign drafts that use it no longer reach anyone through it.

Request

curl -X DELETE https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53 \
  -H "Authorization: Bearer $SMSBLAST_API_KEY"
const res = await fetch('https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53', {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${process.env.SMSBLAST_API_KEY}`,
  },
});
console.log(res.status, await res.json());
import os

import requests

res = requests.delete(
    "https://app.smsblast.net/v1/segments/4f2a8c6e-1d3b-4f5a-9e7c-8b0d2f4a6c53",
    headers={
        "Authorization": f"Bearer {os.environ['SMSBLAST_API_KEY']}",
    },
)
print(res.status_code, res.json())
Response · 200
{
  "ok": true
}

Needs an API key: Authorization: Bearer sb_... Authentication

Path parameters#

idstringuuidrequired

The segment id.

Responses#

200

Deleted.

application/json

okbooleanrequired

Always true.

Response headers
X-Request-Idstring Guide

The id of this request (req_...), on every answer. Quote it when you contact support.

X-RateLimit-Limitinteger Guide

Requests allowed per minute with this API key.

X-RateLimit-Remaininginteger Guide

Requests left in the current minute.

X-RateLimit-Resetinteger Guide

When the current minute ends and the count starts again, in Unix seconds.

401

No API key, or one that is not valid or has been revoked (unauthorized).

404

Something the request names does not exist in your account. error.code is one of:

  • not_found: No segment with that id in your account.
429

Too many requests with this API key (rate_limited). Wait for the number of seconds in Retry-After.

Every error has the same body: {"error": {"code", "message", "details", "requestId"}}. See Errors.