Skip to the page

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]
Needs the scopeemails:send
Reaches outside the workspace

Flags

  • --emailsobject[]Required

    The emails to send, up to 100. Each takes the same fields as one email, without attachments or a schedule.

  • emails[].fromstring

    The 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[]Required

    Who the email is for: one address, or up to 50. A test address, such as delivered@opensend.test or bounced@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[].replyTostring

    The 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[].subjectstring

    The subject line. Needed unless a template gives one. Up to 500 characters.

  • emails[].htmlstring

    The message as HTML. Up to 200,000 characters.

  • emails[].textstring

    The 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[].templateobject

    A published template to build the email from, in place of subject, html and text. Its sender and reply address are used when you give none.

  • emails[].template.idstringRequired

    The 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.

  • --validationstring

    What one refused email does to the others: strict refuses the whole batch and sends nothing, permissive sends the rest and lists the refused one with its reason. Without it you get strict.

    One ofstrictpermissive

  • --idempotency-keystring

    A key of your own that makes a repeat of this request answer with the first result and send nothing. The Idempotency-Key header 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[].indexinteger

    The position of this email in the list you sent, from 0.

  • data[].idstring | null

    The id of the email, or null when it was refused.

  • data[].statusstring | null

    The status of the email, or null when it was refused.

    One ofqueuedsentdelivereddelayedbouncedopenedclickedcomplainedfailedscheduledcanceled

  • data[].modestring | null

    live for a real email, test for an email of the sandbox, or null when it was refused.

    One oflivetest

  • data[].errorobject | null

    Why it was refused, or null.

  • data[].error.codestring

    The code of the refusal.

  • data[].error.messagestring

    The refusal in words.

  • sentinteger

    How many were accepted.

  • failedinteger

    How many were refused.