Create and send a newsletter
Create a newsletter and optionally schedule it or send it immediately.
To send the newsletter 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, the newsletter is created as a draft.
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.- typeDiscriminatorenumconst:emailrequired
The channel type for the newsletter.
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 newsletter.
- recipientsType: objectrequired
Filter conditions that define the newsletter's recipients. Combine
segmentandattributeconditions 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
- 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.
- 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: integerenum
_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
- scheduledType: integerFormat: unix timestamp
_at A Unix timestamp indicating when to send the newsletter. The time must be in the future. You cannot set both
send_nowandscheduled_at. - sendType: boolean
_now If
true, the newsletter is sent immediately after creation. You cannot set bothsend_nowandscheduled_at. - subscriptionType: integer
_topic _id The newsletter audience's subscription topic ID. Required when subscription center is enabled; otherwise sends to globally subscribed profiles.
- application/json
- application/json
- application/json
- 429
Your request is over the 10-per-second limit.
curl https://api.customer.io/v1/newsletters \
--request POST \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--data '{
"name": "Weekly Product Update",
"type": "email",
"recipients": {
"and": [
{
"or": [
{
"segment": {
"id": 42
}
},
{
"segment": {
"id": 99
}
}
]
},
{
"attribute": {
"field": "plan",
"operator": "eq",
"value": "enterprise"
}
}
]
},
"send_now": true,
"subject": "What'\''s new this week, {{ customer.first_name }}",
"preheader_text": "Check out our latest features and improvements",
"body": "<html><body><h1>Product Updates</h1><p>Here'\''s what we shipped this week...</p></body></html>",
"from": "Product Team <updates@example.com>",
"subscription_topic_id": 5,
"rate_limit_email_rate": 500,
"rate_limit_time_period": 60,
"rate_limit_spread": true
}'
{
"newsletter": {
"id": 128275,
"deduplicate_id": "128275:1484870424",
"type": "email",
"content_ids": [
45
],
"name": "Weekly Product Update",
"sent_at": 1481653929,
"created": 1481653919,
"updated": 1481653929,
"recipient_segment_ids": [
42,
99
],
"tags": [
"Product Updates"
],
"subscription_topic_id": 5
}
}Returns the newly created newsletter.