Skip to main content
Automation API

collected_records_send_email

Use this action to send one email for each record in a collection that an earlier action built.

Tip

Read the live config shape of each action type from GET /v1/automation/meta/action before you build on it.

In the automation editor, this action is Send an email to all collected records in the Email & documents family. Its group is action, and it works with every trigger but needs an earlier action that creates the record collection.

Send it in the actions array of Create an automation or Update an automation. An update replaces the whole array, so include the other actions.

Example​

This action reminds the buyer of every collected viewing, using the email field of each record:

{
"type": "collected_records_send_email",
"config": {
"record_collection": { "kind": "variable", "source": "action", "action_type": "record_collection", "app_id": 640 },
"to_address": [{ "kind": "variable", "source": "field", "field_id": 6120, "field_type": "multi_email", "previous": false, "collection": true, "triggering": false }],
"subject": ["Your viewing tomorrow"],
"message_body": ["<p>See you at the property tomorrow. Reply to this email to reschedule.</p>"],
"reply_address": ["juliet@acme.com"],
"smtp_account_id": 812
}
}

Config​

The config matches send_email, plus record_collection and fields_expanded.

PropertyTypeDescriptionExample value
record_collectionreferenceRequired. The collection whose records get one email each, created by an earlier action. The schema lets you save without it, but validation then reports action_invalid.{ "kind": "variable", "source": "action", "action_type": "record_collection", "app_id": 640 }
to_addresstemplate valueRecipient address or addresses. Empty when left out. Without it, Tape skips the action when the automation runs.["romeo@acme.com"]
subjecttemplate valueSubject line. Empty when left out.["Your viewing tomorrow"]
reply_addresstemplate valueReply-to address. Empty when left out.["juliet@acme.com"]
cc_addresstemplate valueCC address or addresses. Empty when left out.["romeo@acme.com"]
bcc_addresstemplate valueBCC address or addresses. Empty when left out.["archive@acme.com"]
from_addresstemplate valueSender address. Empty when left out.["sales@acme.com"]
from_nametemplate valueSender display name. Empty when left out.["Acme Realty"]
message_bodytemplate valueHTML body. Empty when left out.["<p>Hello</p>"]
smtp_account_idintegerID of the SMTP account to send from. Left out, Tape uses the organization's default SMTP account. See Sender address. Same ID as smtp_settings_id of the email endpoint.812
attach_files_variable_defsarray of referencesFile variables Tape can attach: attachment or image fields, file custom variables such as the PDF from create_pdf, or the files of the trigger. Empty when left out.[]
attach_files_match_typeenumWhich of those files Tape attaches. Default all. See Attachment modes."all"
attach_files_match_conditionfilter group | nullLimits the attached files in the filtered and most_recent_filtered modes. An empty AND group when left out or null.null
fields_expandedbooleanEditor only: whether the address fields show expanded in the automation editor. Tape keeps it on read and write. Left out when not set.false

To find smtp_account_id, select the account in this action in the automation editor, then retrieve the automation. The API has no endpoint that lists SMTP accounts.

Attachment modes​

attach_files_match_type takes one of these lower-case tokens:

  • all: attaches every candidate file. Ignores the condition.
  • most_recent: attaches the most recent file. Ignores the condition.
  • filtered: attaches the files that match attach_files_match_condition.
  • most_recent_filtered: attaches the most recent file that matches attach_files_match_condition.

General behavior​

  • Tape sends one email for each record in the collection. A field or meta reference with collection: true reads that record's value, like the email field in the example.
  • Unlike send_email, the schema marks no key as required. Without record_collection, Tape saves the action, and validation reports action_invalid.
  • A record_collection without a matching earlier action fails validation with action_variable_missing.
  • Without to_address, Tape skips the action when the automation runs. Set to_address and subject for a useful email.
  • Every other address, name and body defaults to empty.
  • Every email an automation sends counts against the organization's shared 24-hour send quota.

Requirements​

  • To add or change this action through the API, your token needs the automations:edit capability. See Capabilities.
  • You must administer the workspace that the automation's database app belongs to.
  • An earlier action in the automation must create the collection in record_collection, for example collect_app_records.

Next steps​