Skip to navigation
ActivitiesEmails

Create an Email activity

View as Markdown

Create an email activity. Depending on status, this logs an email that was sent or received outside Close, saves a draft, or sends the email from one of the user’s connected email accounts:

  • inbox logs an email that was received.
  • sent logs an email that was already sent.
  • draft saves a draft. You can edit it and send it later with PUT.
  • outbox sends the email right away. To leave time to undo, set send_in to delay sending by up to 60 seconds.
  • scheduled sends the email at date_scheduled.
  • error logs an email that failed to send.

sender is required for every status except draft and sent. For sent, it defaults to the email address of the email’s user. It takes a plain address like john@example.com, or a name and address like "John Smith" <john@example.com>. To send an email, to must contain at least one valid email address.

If you include template_id without body_text or body_html, Close renders the email template for the lead and contact_id, which is then required.

For scheduled, outbox or sent emails, followup_date creates a follow-up task for that date if the lead doesn’t reply.

To include an attachment, first upload the file with the Files API. Then add an object to the attachments array with url, filename, content_type and size. url is the download.url field of the Files API response and must start with https://app.close.com/go/file/.

Returns 400 if validation fails, or if date_scheduled or followup_date is set and your plan doesn’t include scheduled sending or follow-up reminders.

Authentication

AuthorizationBasic
Use your API key as the username and leave the password empty.
OR
AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Query parameters

_fieldsstringOptional

Comma-separated list of fields to include in the response.

Request

This endpoint expects an object.
lead_idstringRequired
ID of the lead the email belongs to. Can't be changed later.
statusenumRequired

Status of the email. Set outbox to send it now, scheduled to send it at date_scheduled, draft to save a draft, or inbox, sent or error to log an email sent or received elsewhere. Only draft, scheduled, outbox and error emails can change status, and only to draft, scheduled or outbox.

activity_atdatetime or nullOptional

When the email happened. Defaults to date_created, and is set to the send time when Close sends the email.

attachmentslist of objects or nullOptional

Files to attach. Upload each file with the Files API first, then pass its download.url as url.

bcclist of strings or nullOptional

Email addresses of the Bcc recipients.

body_htmlstring or nullOptional<=1048576 characters

HTML body. If you send only one of body_text and body_html, Close generates the other.

body_textstring or nullOptional<=1048576 characters

Plain-text body. If you send only one of body_text and body_html, Close generates the other.

cclist of strings or nullOptional

Email addresses of the Cc recipients.

contact_idstring or nullOptional
ID of the lead's contact the email is with.
created_bystring or nullOptional
ID of the user to record as the creator of the email.
date_createddatetime or nullOptional
When the email was created, for importing older emails. Defaults to now. Can't be changed later.
date_scheduleddatetimeOptional

When to send the message. Required when status is scheduled, and ignored otherwise.

email_account_idstring or nullOptional

ID of the connected email account to send the email from, prefixed with emailacct_. If you leave it out for a draft or an email you send, Close picks the user’s account that matches sender.

followup_datedatetime or nullOptional

Date to create a follow-up task on if the lead doesn’t reply. Only used when status is scheduled, outbox or sent, and can’t be before the email is sent.

followup_sequence_add_cc_bccboolean or nullOptional

Whether to also add the cc and bcc recipients to the followup_sequence_id workflow. Requires followup_sequence_id.

followup_sequence_delayinteger or nullOptional>=86400

Seconds to wait after the email is sent before the first step of the followup_sequence_id workflow. At least 86,400 (one day). Required with followup_sequence_id.

followup_sequence_idstring or nullOptional

ID of a workflow to subscribe the recipients to after the email is sent, prefixed with seq_. Required with followup_sequence_delay.

in_reply_to_idstring or nullOptional

ID of the email activity this email replies to. Close sets the In-Reply-To and References headers from it.

openslist of objects or nullOptional

Opens to record. Only allowed when status is sent.

organization_idstring or nullOptional
ID of your organization. Defaults to the organization of your API key or OAuth token.
send_inintegerOptional0-60

Seconds to delay sending, to allow undo. Only used when status is outbox.

senderstring or nullOptional

Sender of the email, either a plain address like john@example.com or a name and address like "John Smith" <john@example.com>. Required unless status is draft or sent. For sent, it defaults to the address of the email’s user.

subjectstring or nullOptional<=1000 characters
Subject of the email.
template_idstring or nullOptional

ID of the email template to use, prefixed with tmpl_. On create, if you leave out body_text and body_html, Close renders the template for contact_id, which is then required, and fills in subject, cc, bcc and attachments you leave empty.

tolist of strings or nullOptional

Email addresses of the To recipients. At least one valid address is required to send the email.

user_idstring or nullOptional
ID of the user the email belongs to. Defaults to you. Setting another user requires the Manage Organization permission and is otherwise ignored. Can only be changed while the email is a draft.

Response

Successful response
_typestring

Type of the activity, e.g. Call, Email or Note.

activity_atdatetime or null

When the activity happened, e.g. when an Email or SMS was sent. Defaults to date_created.

bcclist of strings

Email addresses of the Bcc recipients.

body_htmlstring or null
HTML body of the email.
body_textstring or null

Plain-text body of the email.

bulk_email_action_idstring or null

ID of the bulk email action that sent the email, or null if it wasn’t sent in bulk.

cclist of strings

Email addresses of the Cc recipients.

contact_idstring or null

ID of the Contact the activity is with, or null if it isn’t with a particular Contact.

created_bystring or null

ID of the user who created the activity, or null if it wasn’t created by a user.

date_createddatetime
When the activity was created.
date_scheduleddatetime or null

When the email is scheduled to be sent, or null if it isn’t scheduled.

date_sentdatetime or null

When the email was sent, or null if it hasn’t been sent.

date_updateddatetime
When the activity was last updated.
directionenum or null

Whether the email was sent to the lead (outgoing) or received from the lead (incoming).

Allowed values:
followup_sequence_add_cc_bccboolean

Whether the email’s cc and bcc recipients are also added to the followup_sequence_id workflow.

followup_sequence_delayinteger or null

Seconds to wait after the email is sent before the first step of the followup_sequence_id workflow, or null.

has_replyboolean
Whether a reply to the email was received.
idstring

ID of the activity, e.g. acti_abc123.

in_reply_to_idstring or null

ID of the email activity this email replies to, or null.

lead_idstring or null

ID of the Lead the activity is on. Can be null for Calls and SMS with phone numbers that don’t match any Contact.

message_idslist of strings

Message-ID header values of the email.

need_smtp_credentialsboolean

Always false. Kept for backward compatibility.

opens_summarystring or null

Human-readable summary of opens, e.g. Opened by karen@example.com (2 times, latest 2024-01-31). null if the email hasn’t been opened.

organization_idstring
ID of the organization the activity belongs to.
referenceslist of strings

Message IDs of the earlier emails this email refers to, oldest first, from its References and In-Reply-To headers.

send_as_idstring or null

ID of the user the email is sent on behalf of, when it’s sent as another user. null otherwise.

senderstring or null

Sender of the email, either a plain address like john@example.com or a name and address like "John Smith" <john@example.com>. null if a draft has no sender yet.

statusenum

Status of the email, e.g. draft, scheduled or sent.

subjectstring or null
Subject of the email.
template_idstring or null

ID of the email template the email was written from, prefixed with tmpl_, or null.

thread_idstring or null

ID of the email thread activity the email belongs to, prefixed with acti_.

tolist of strings

Email addresses of the To recipients.

updated_bystring or null

ID of the user who last updated the activity, or null if it wasn’t updated by a user.

user_idstring or null

ID of the user the activity belongs to, e.g. who made the Call or sent the Email. Can be null, e.g. for an incoming SMS to a group number.

userslist of strings
IDs of all users the activity is associated with, e.g. every Close user on an Email Thread or invited to a Meeting.
agent_action_reasonstring or nullOptional

Why an agent created the activity (send_scheduling_link, custom_agent_decision or voice_agent_callback), or null if no agent created it.

ai_draftobject or nullOptional

AI-generated draft of a follow-up to this email, prepared for the user making the request. null if there is none, or once it’s been used or discarded.

attachmentslist of objectsOptional
Files attached to the email.
body_html_quotedlist of objects or nullOptional

body_html split into new content and HTML quoted from earlier messages. null if there is no HTML body.

body_previewstring or nullOptional

First 200 characters of the body, as plain text. null if the email has no body.

body_text_quotedlist of objects or nullOptional

body_text split into new content and text quoted from earlier messages. null if there is no plain-text body.

created_by_agent_idstring or nullOptional

ID of the agent that created the activity, e.g. agentconfig_abc123, or null if no agent created it.

created_by_namestring or nullOptional

Name of the user in created_by.

email_account_idstring or nullOptional

ID of the connected email account the email was sent from or received in, prefixed with emailacct_. null if there is none or the account was deleted.

envelopemap from strings to any or nullOptional

Headers of the email: the original ones for synced emails, or ones Close generates for emails created in Close. Has date, subject, in_reply_to, message_id, is_autoreply, and from, sender, reply_to, to, cc and bcc as lists of {email, name} objects. null if the email has none.

followup_sequence_idstring or nullOptional

ID of the workflow the recipients are subscribed to after the email is sent, prefixed with seq_, or null.

openslist of objectsOptional
Each time a recipient opened the email, oldest first.
send_attemptslist of objectsOptional
Failed or partly failed attempts to send the email, oldest first.
sequence_idstring or nullOptional

ID of the Workflow that created the activity, e.g. seq_abc123, or null.

sequence_namestring or nullOptional

Name of the Workflow in sequence_id.

sequence_subscription_idstring or nullOptional

ID of the Workflow Run, i.e. the Contact’s enrollment in the Workflow, that created the activity, e.g. sub_abc123, or null.

template_namestring or nullOptional

Name of the email template in template_id. Kept after the template is deleted.

updated_by_namestring or nullOptional

Name of the user in updated_by.

user_namestring or nullOptional

Name of the user in user_id.

agent_config_idstring or nullOptionalDeprecated

Deprecated. Use created_by_agent_id instead.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
429
Too Many Requests Error