Send emails in a batch
Sends up to a hundred emails in one request. Every email is checked first and one that is refused refuses the whole batch, unless validation is permissive: then the rest are sent and the refused one is listed with its reason. After that each email is accepted or refused by itself, and the answer says which.
opensend emails batch [flags]Flags
--emailsobject[]RequiredThe emails to send, up to 100. Each takes the same fields as one email, without attachments or a schedule.
emails[].fromstringThe sender, on a verified domain. An address, or a name and an address as
Acme <hello@mail.example.com>. Needed unless a template gives one. Up to 500 characters.emails[].tostring | string[]RequiredWho the email is for: one address, or up to 50. A test address, such as
delivered@opensend.testorbounced@opensend.test, reaches nobody and ends the way its name says.emails[].ccstring | string[]Who gets a copy: one address, or up to 50.
emails[].bccstring | string[]Who gets a copy without the others seeing: one address, or up to 50.
emails[].replyTostringThe address replies go to, when it is not the sender. Without it, the one of the template when it has one, then the default of the workspace.
emails[].subjectstringThe subject line. Needed unless a template gives one. Up to 500 characters.
emails[].htmlstringThe message as HTML. Up to 200,000 characters.
emails[].textstringThe message as plain text. Send it with
html, or alone. With a template it replaces the plain text of the template. Up to 200,000 characters.emails[].headersRecord<string, string>Extra headers for the message, by name. Up to 20, and not the ones the platform writes itself.
emails[].tagsRecord<string, string>Labels of your own for the email, by name, such as
{ "campaign": "welcome" }. Up to 10. They come back on the email and in webhooks.emails[].templateobjectA published template to build the email from, in place of
subject,htmlandtext. Its sender and reply address are used when you give none.emails[].template.idstringRequiredThe id or the alias of a published template. Up to 500 characters.
emails[].template.variablesRecord<string, string | number>A value for each
{{NAME}}in the template, by name. A variable with a default in the template can be left out.--validationstringWhat one refused email does to the others:
strictrefuses the whole batch and sends nothing,permissivesends the rest and lists the refused one with its reason. Without it you getstrict.One of
strictpermissive--idempotency-keystringA key of your own that makes a repeat of this request answer with the first result and send nothing. The
Idempotency-Keyheader does the same.
Returns
The command prints the answer: as JSON when its output goes to a file or another program, and as a table or a list of fields in a terminal. When the API refuses, the error goes to the error stream and the command ends with a code that names the failure. Output and scripts lists the codes.
object"list"Always
list.dataobject[]One entry for each email you sent, in the same order.
data[].indexintegerThe position of this email in the list you sent, from 0.
data[].idstring | nullThe id of the email, or
nullwhen it was refused.data[].statusstring | nullThe status of the email, or
nullwhen it was refused.One of
queuedsentdelivereddelayedbouncedopenedclickedcomplainedfailedscheduledcanceleddata[].modestring | nulllivefor a real email,testfor an email of the sandbox, ornullwhen it was refused.One of
livetestdata[].errorobject | nullWhy it was refused, or
null.data[].error.codestringThe code of the refusal.
data[].error.messagestringThe refusal in words.
sentintegerHow many were accepted.
failedintegerHow many were refused.