Create and send a one-time send
Create a one-time send (referred to as a "newsletter" in our APIs) and optionally schedule it or send it immediately.
Set the audience with either recipients (a filter over segments and profile attributes) or recipient_file_url (a CSV of recipients). One of the two is required, and a request carrying both is rejected.
To send it immediately, set send_now to true. To schedule for later, set scheduled_at to a Unix timestamp in the future. If you don't set either, it's created as a draft.
If you set send_now or scheduled_at and a recipient segment is still building, Customer.io accepts the request and holds the send until the segment finishes. The send and schedule endpoints describe what the one-time send reports while Customer.io holds it.
A recipient_file_url audience resolves in the background, so you can't send or schedule in the same request. Poll Get a one-time send until recipient_file_status is done, then call send or schedule.
There's no endpoint that updates a one-time send, so name, the audience, and deduped are fixed once you create it. To change them on a draft, delete it and create a new one. You can still edit content through the variant endpoints until it sends.
If you enabled a subscription center in your workspace, subscription_topic_id is required. Use the subscription center endpoint to find IDs.
Use standard HTML/CSS for the body of an email; this endpoint can't pull in global style variables or render our Design Studio's component syntax. You can create Design Studio emails through other endpoints. All requests must be less than 1 MB.
When you create an email, include
subjectandbody. Set eitherfromorfrom_id, but not both. If you set neither, Customer.io uses your oldest verified sending address.- Type: object · Email
- typeDiscriminatorenumconst:emailrequired
The channel type for the one-time send.
values- email
- bodyType: stringrequired
The HTML body content of the email. Use standard HTML/CSS, not syntax unique to Design Studio.
- nameType: stringmax length:190required
The name of the one-time send.
- subjectType: stringrequired
The subject line of the email.
- bodyType: string
_plain The plaintext body of the email. If provided, this overwrites the auto-generated plaintext.
- dedupedType: boolean
When
true, Customer.io sends only one message per email address or phone number, even when several profiles share it. Supported onemail,twilio, andsmsone-time sends. If the send's address is an identifier in your workspace (email foremailsends, phone number fortwilioandsmssends), Customer.io returns a 422 when you setdedupedtotrue, because no two profiles can share an identifier and there's nothing to dedupe. Leave it out to use the default for your workspace's identifier configuration. No endpoint changes this later, so set it here if you don't want the default. - expiresType: integer
_after min:0max:2592000A send window in seconds, or
0for no expiry. Customer.io stops delivering the one-time send once the window closes, so a delayed message doesn't arrive when it's no longer useful. Set it here only alongsidesend_noworscheduled_at, because the window runs from the send. On a plain draft, set it on the send or schedule call instead. - fromType: string
The address to send the email from, in the format
Name <email@domain.com>. You can setfromorfrom_id, but not both. Use one of theaddressvalues from List sender identities. - fromType: integer
_id The identifier of the
fromaddress, commonly known as the "sender". Use List sender identities to find valid IDs. - layoutType: integer
_id The ID of the layout you want to use for the email. If you don't set one, the email uses your workspace's default layout. Find a layout's ID in its URL.
- preheaderType: string
_text Also known as "preview text", this is the small block of text shown in an email inbox next to or underneath the subject line.
- rateType: integer
_limit _email _rate min:1Maximum number of messages per time period. NOTE: Though this states
email_rate, you can use this for other message channels. Only fixed rate limits are supported, not daily ramp limits. - rateType: boolean
_limit _spread When
true, spreads messages evenly across the time period. Otherwise, it sends as fast as possible up to the limit in each period. - rateType: integer enum
_limit _time _period Time period in seconds for rate limiting. Must be one of 60 (minute), 3600 (hour), or 86400 (day).
values- 60
- 3600
- 86400
- recipientType: string Format: uri
_file _url A URL pointing to a CSV of recipients, used instead of the
recipientsfilter. Customer.io resolves the file in the background, so this request can't also send or schedule. Poll Get a one-time send untilrecipient_file_statusisdone, then call send or schedule. - recipientsType: object
Filter conditions that define the one-time send's recipients. In
recipients, you can combinesegmentandattributeconditions withand,or, andnotoperators.This endpoint enforces a strict shape:
- The outermost object must be a single
andarray. - Every operator or condition object takes exactly one key:
and,or,not,segment, orattribute. An object with two keys—likenotalongsideand—is rejected with an "Invalid filter spec" error. - Segment conditions must be wrapped in an
orarray, even for a single segment—andorarrays can contain only segment conditions. - To exclude segments,
notmust contain anorof segment conditions and sit as its own item inside theandarray. - Attribute conditions sit directly in the
andarray, unwrapped. To negate an attribute condition, setinverse: trueon the attribute itself—notcan't contain attribute conditions.
The email example on this operation shows or-wrapped segments combined with a negated attribute; for the common "include segment A, exclude segment B" pattern, see the include one segment, exclude another request example. See Format API-triggered broadcasts for general operator behavior.
- The outermost object must be a single
- scheduledType: integer Format: unix timestamp
_at A Unix timestamp indicating when to send the one-time send. The time must be in the future. You cannot set both
send_nowandscheduled_at. - sendType: boolean
_now If
true, the one-time send is sent immediately after creation. You cannot set bothsend_nowandscheduled_at. - subscriptionType: integer
_topic _id The one-time send audience's subscription topic ID. Required when subscription center is enabled; otherwise sends to globally subscribed profiles.
- tagType: array integer[]
_ids The IDs of the tags you want to apply to the one-time send. Each tag must already exist.
- application/json
- application/json
- application/json
- application/json
{
"type": "email",
"body": "<html><body><h1>Product Updates</h1><p>Here's what we shipped this week...</p></body></html>",
"name": "Weekly Product Update",
"subject": "What's new this week, {{ customer.first_name }}",
"from": "Product Team <updates@example.com>",
"preheader_text": "Check out our latest features and improvements",
"rate_limit_email_rate": 500,
"rate_limit_spread": true,
"rate_limit_time_period": 60,
"recipients": {
"and": [
{
"or": [
{
"segment": {
"id": 42
}
},
{
"segment": {
"id": 99
}
}
]
},
{
"attribute": {
"field": "plan",
"operator": "eq",
"value": "enterprise"
}
}
]
},
"send_now": true,
"subscription_topic_id": 5
}
{
"newsletter": {
"content_ids": [
45
],
"created": 1481653919,
"deduplicate_id": "128275:1481653929",
"id": 128275,
"name": "Weekly Product Update",
"recipient_segment_ids": [
42,
99
],
"scheduled_at": null,
"send_state": "sent",
"sent_at": 1481653929,
"subscription_topic_id": 5,
"tags": [
"Product Updates"
],
"type": "email",
"updated": 1481653929
}
}Returns the newly created one-time send.