Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
321 changes: 299 additions & 22 deletions source/includes/rest/_broadcasts.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,10 @@ const body = await response.json();
}
```

Single-Email Campaigns created via the API start in the `draft` status, with an audience of
everyone eligible to receive them. [Set the audience](#set-the-audience) to narrow it, then
[schedule](#schedule-a-single-email-campaign) it.
Single-Email Campaigns created via the API start in the `draft` status, with no audience chosen.
[Set the audience](#set-the-audience) before you
[schedule](#schedule-a-single-email-campaign) it; to send to everyone eligible, set the filter
`[[]]`.

### HTTP Endpoint

Expand Down Expand Up @@ -1158,6 +1159,21 @@ const body = await response.json();
}
```

> To combine condition types, for example people tagged "VIP" on the gold plan who have not
> opened any of their last 5 emails:

```json
{
"filter": [
[
{ "type": "tags", "properties": { "operator": "include", "value": "VIP" } },
{ "type": "custom_fields", "properties": { "operator": "equals", "identifier": "plan", "value": "gold" } },
{ "type": "emails_inactive", "properties": { "unopened_email_count": "5" } }
]
]
}
```

> If the campaign already has an audience and `confirm=true` was not sent, responds with a <code>409 Conflict</code>:

```json
Expand All @@ -1178,22 +1194,44 @@ true of a person, and a person matching any inner list is included. So
`[[A, B], [C]]` means "(A and B) or C".

`[[]]` means everyone eligible to receive it, and is how you clear an audience. An empty
filter, `[]`, is rejected.
filter, `[]`, is rejected. Both levels are required even for one condition, so a single rule
is `[[{...}]]`; `[{...}]` is rejected rather than wrapped for you. An empty inner list is
allowed only as the whole filter `[[]]`. A filter takes at most 10 AND-sets of at most 10
conditions each.

Today the only condition type available is `segments`, with the operators `in` and
`not_in`. The `segment_id` is the `id` from the Segments API. More condition types will follow.
These condition types are available, each described under
[Audience conditions](#audience-conditions): `segments`, `tags`, `campaigns`,
`broadcast_emails`, `custom_fields`, `date_subscribed`, `lead_score`, `emails_inactive` and
`days_inactive`. A condition is written exactly as the Drip app's segment builder stores it. Any
other type is rejected with a `422` naming it. More types will follow.

`segment_id` takes one id, never a list: `["4815162"]` is rejected. For several segments, use
one condition each. Two conditions in the same inner list mean "in both"; two in separate
inner lists mean "in either".
Values are refused rather than reinterpreted. A rule Drip would read as "everyone" when sending,
or would read differently than it is written, such as a blank tag, an empty list or a
malformed date, is rejected with a `422` naming the key and the shape that would be accepted.

Replacing an audience requires `confirm=true` whenever the current audience is anything other
than everyone, because what is being replaced cannot be recovered through the API. Read the
audience first if you need to keep it.

Every problem with a filter is reported in a single response. Each error's `attribute` is a
JSON Pointer to the condition that caused it, so you can fix a request once rather than once
per round trip.
JSON Pointer to the condition that caused it, such as `/filter/0/1/properties/value` for the
second condition of the first AND-set, so you can fix a request once rather than once per round
trip. The exception is a condition whose type or operator is unknown: nothing else about it can
be checked, so that is the only error reported for it.

A malformed filter is a `422`; a filter naming a segment, campaign or broadcast the account
cannot use is a `404`. The two never share a response.

| Code | Status | Means |
|------|--------|-------|
| `missing_property` | 422 | `filter`, a condition's `properties`, or a required key is missing or blank. |
| `invalid_value` | 422 | A value has the wrong shape, a condition sits directly in the outer list, or the filter is past its size limits. |
| `empty_condition_set` | 422 | `[]`, or an empty AND-set inside a larger filter. |
| `nesting_too_deep` | 422 | A list where a condition was expected: a filter is exactly two levels deep. |
| `unknown_condition_type` | 422 | A `type` this API does not take. |
| `unknown_operator` | 422 | An operator its type does not have. The message lists the valid ones. |
| `unknown_property` | 422 | A key its condition does not take. |
| `not_found_error` | 404 | A segment, campaign or broadcast that does not exist on this account, or cannot be used. |

An audience set here appears in the Drip app as the campaign's recipients, the same as one
chosen there.
Expand Down Expand Up @@ -1267,23 +1305,30 @@ const body = await response.json();
{
"audience": {
"message": "This filter includes unsupported criteria and cannot be returned as a filter.",
"summary": "People who are tagged with \"vip\"",
"unsupported_types": ["tags"]
"summary": "People who have a lifetime value greater than 100",
"unsupported_types": ["lifetime_value"]
}
}
```

`filter` comes back in the same shape it is set in, so reading an audience and writing it
straight back changes nothing.

`filter` is present only when writing it again would be accepted. Most audiences built in the
Drip app use rules that have no form here yet, and those come back described instead:
`summary` is plain-English display text, and `unsupported_types` names the condition types in
the way. Expect that until more condition types are available.
A draft whose audience has never been set also reads as `[[]]`, and its `derived.audience` says
`All people`, but it is not ready to send:
[scheduling](#schedule-a-single-email-campaign) it responds with a `409 Conflict` until you
[set the audience](#set-the-audience), even to `[[]]`.

`filter` is present only when writing it again would be accepted. An audience built in the
Drip app with a rule that has no form here yet, such as lifetime value or order activity,
comes back described instead: `summary` is plain-English display text, and
`unsupported_types` names the condition types in the way. The same happens to an audience past
the size limits, or holding a value this API would refuse; `unsupported_types` is then left out
when every type in it is available.

A present `filter` is not a promise that its segments still exist. That is not checked on
read, so an audience naming a segment deleted since it was set reads back intact and responds
with a `404 Not Found` when written again.
A present `filter` is not a promise that the segments, campaigns and broadcasts it names still
exist. That is not checked on read, so an audience naming one deleted since it was set reads
back intact and responds with a `404 Not Found` when written again.

### HTTP Endpoint

Expand All @@ -1293,6 +1338,235 @@ with a `404 Not Found` when written again.

None.

## Audience conditions

> A condition is a `type` and a `properties` object:

```json
{ "type": "tags", "properties": { "operator": "include", "value": "VIP" } }
```

Each condition in a [filter](#set-the-audience) is one rule about a person: a `type`, and a
`properties` object holding the operator and the values that operator needs. Nothing else
belongs at the top level of a condition, and a key its type does not take is rejected with a
`422` naming it.

Write ids and numbers as strings, such as `"4815162"` and `"30"`. This is how the Drip app
stores the condition, so a filter read from [Fetch the audience](#fetch-the-audience) can be
written back unchanged.

### Segment conditions

> People in the "VIP customers" segment who are not in the "Unengaged" segment:

```json
[[
{ "type": "segments", "properties": { "operator": "in", "segment_id": "4815162" } },
{ "type": "segments", "properties": { "operator": "not_in", "segment_id": "2342108" } }
]]
```

Whether the person is in a saved segment.

| Operator | Means |
|----------|-------|
| `in` | in the segment |
| `not_in` | not in the segment |

`segment_id` is the `id` from [List all segments](#list-all-segments), and must be an active,
permanent segment on this account; anything else responds with a `404`. It takes one id, never a
list: `["4815162"]` is rejected. For several segments, use one condition each. Two in the same
AND-set mean "in both"; two in separate AND-sets mean "in either".

### Tag conditions

> People tagged with either "VIP" or "Wholesale":

```json
[[
{ "type": "tags", "properties": { "operator": "include_any", "value": ["VIP", "Wholesale"] } }
]]
```

Whether the person has a tag, by name, as
[List all tags used in an account](#list-all-tags-used-in-an-account) returns it. Matching ignores case and repeated spaces, so `"VIP"`
and `" vip "` are the same tag. A tag does not need to exist on the account yet: one no person
has matches no one, or, negated, everyone.

| Operator | `value` | Means |
|----------|---------|-------|
| `include` | one tag | has the tag |
| `not_include` | one tag | does not have the tag |
| `contains` | text | has a tag whose name contains the text |
| `include_any` | a list of tags | has at least one of them |
| `include_all` | a list of tags | has every one of them |
| `not_include_any` | a list of tags | has none of them |
| `not_include_all` | a list of tags | is missing at least one of them |
| `no_tags` | omitted, or `""` | has no tags at all |

A blank tag, an empty list, or a blank entry in a list is rejected, because each can quietly
change who the campaign reaches. Sending a list to `include`, `not_include` or `contains` is rejected
too.

### Email Series Campaign conditions

> People currently subscribed to an Email Series Campaign:

```json
[[
{ "type": "campaigns", "properties": { "operator": "subscribed_to", "campaign_id": "123456789", "campaign_ids": [] } }
]]
```

> People subscribed to at least one of two:

```json
[[
{ "type": "campaigns", "properties": { "operator": "subscribed_to_any", "campaign_id": "", "campaign_ids": ["123456789", "987654321"] } }
]]
```

Whether the person is, was, or never was in an
[Email Series Campaign](#list-all-email-series-campaigns), by its `id`. The type is
`campaigns`.

| Operator | Means |
|----------|-------|
| `subscribed_to` | currently subscribed |
| `not_subscribed_to` | not currently subscribed |
| `has_completed` | finished it |
| `has_not_completed` | has not finished it |
| `never_subscribed_to` | never subscribed |
| `removed_from` | removed from it |
| `unsubscribed_from` | unsubscribed from it |
| `subscribed_to_any` | subscribed to at least one of `campaign_ids` |

Both `campaign_id` and `campaign_ids` are required, as the Drip app writes them. Every operator
but `subscribed_to_any` takes one id in `campaign_id`, with `campaign_ids: []`.
`subscribed_to_any` takes a non-empty list in `campaign_ids`, with `campaign_id: ""`. A campaign
that has been deleted, or belongs to another account, responds with a `404`.

### Single-Email Campaign activity

> People who opened a Single-Email Campaign:

```json
[[
{ "type": "broadcast_emails", "properties": { "operator": "opened", "broadcast_id": "123456789" } }
]]
```

What the person did with one [Single-Email Campaign](#list-all-single-email-campaigns), by its
`id`. The type is `broadcast_emails`.

| Operator | Means |
|----------|-------|
| `received` / `not_received` | received it, or not |
| `opened` / `not_opened` | opened it, or not |
| `clicked` / `not_clicked` | clicked a link in it, or not |
| `failed_to_send` | it could not be sent to them |

A campaign that has been deleted, or belongs to another account, responds with a `404`.

### Custom field conditions

> People whose `plan` field is "gold" or "platinum":

```json
[[
{ "type": "custom_fields", "properties": { "operator": "equals_any", "identifier": "plan", "value": ["gold", "platinum"] } }
]]
```

> People with any value for `birthday`:

```json
[[
{ "type": "custom_fields", "properties": { "operator": "is_set", "identifier": "birthday", "value": "" } }
]]
```

A custom field's value. `identifier` is the field's identifier, as
[List all custom field identifiers](#list-all-custom-field-identifiers-used-in-an-account)
returns it: letters, numbers and underscores, at most 255 characters. The field does not need
to exist yet.

| Operator | `value` |
|----------|---------|
| `equals`, `not_equals`, `contains`, `not_contain` | a non-blank string |
| `equals_any` | a non-empty list of non-blank strings |
| `greater_than`, `greater_than_or_equal_to`, `less_than`, `less_than_or_equal_to` | a number as a string, such as `"10"` or `"-2.5"`. Thousands commas are ignored, so `"1,000"` is 1000. |
| `is_set`, `not_set` | omitted, or `""`. These ask whether the person has any value for the field. |

`value` may use Liquid, which renders when the campaign sends, with only `now` in scope, such
as `{{ now | date: "%Y-%m-%d" }}`. Person and account variables render blank, and a value that
renders blank is rejected.

### Date subscribed

> People who subscribed in the last 30 days:

```json
[[
{ "type": "date_subscribed", "properties": { "operator": "in_the_last", "interval": "30", "units": "days" } }
]]
```

> People who subscribed before March 1, 2026, Chicago time:

```json
[[
{ "type": "date_subscribed", "properties": { "operator": "is_before", "date": "2026-03-01", "time_zone": "America/Chicago" } }
]]
```

When the person subscribed.

| Operator | Properties |
|----------|------------|
| `is_before`, `is_after` | `date`, as `YYYY-MM-DD`, and `time_zone`, an IANA name such as `"America/Chicago"`, or `""` for UTC. Both are required. |
| `in_the_last`, `not_in_the_last` | `interval`, a whole number from 1 as a string, and `units`: `minutes`, `hours` or `days`. |

### Lead score

> People with a lead score above 50:

```json
[[
{ "type": "lead_score", "properties": { "operator": "greater_than", "value": "50" } }
]]
```

| Operator | `value` |
|----------|---------|
| `greater_than`, `less_than` | a whole number from 0, as a string |
| `is_potential_lead`, `not_potential_lead` | `"0"`, as the Drip app writes it. These ask whether the person is a prospect. |

### Email inactivity

> People who have not opened or clicked any of their last 5 emails:

```json
[[
{ "type": "emails_inactive", "properties": { "unopened_email_count": "5" } }
]]
```

> People sent an email in the last 30 days who opened or clicked none of them:

```json
[[
{ "type": "days_inactive", "properties": { "days_inactive": "30" } }
]]
```

Two types, neither with an operator:

| Type | Property | Means |
|------|----------|-------|
| `emails_inactive` | `unopened_email_count`, 1 to 20, as a string | has not opened or clicked any of their last that many emails |
| `days_inactive` | `days_inactive`, 1 or more, as a string | received an email in the last that many days, and opened or clicked none |

## Schedule a Single-Email Campaign

> To send a Single-Email Campaign at 9:00 in each person's own time zone:
Expand Down Expand Up @@ -1424,8 +1698,11 @@ Only a `draft` can be scheduled. To change when a scheduled campaign sends, unsc
then schedule it again. A campaign that is already scheduled, sending, or sent, or whose account
cannot send right now, responds with a `409 Conflict` that says which.

The audience is not checked here. A campaign with no audience set goes to everyone eligible to
receive it, the same as in the Drip app. Read `derived.audience` first if that matters.
The audience has to be chosen first, the same as the Drip app's recipients step. A draft whose
audience was never set responds with a `409 Conflict` asking for one; to send to everyone
eligible, [set the audience](#set-the-audience) to `[[]]`. A draft built in the Drip app with
its recipients chosen schedules as it is. Read `derived.audience` first to confirm who it goes
to.

With `auto_resend`, a second copy goes to people who did not open the first, `resend_delay`
whole days later.
Expand Down