Use the email engagement API to log and manage emails on CRM records.
POST
request to /crm/v3/objects/emails
.
In the request body, add email details in a properties object. You can also add an associations object to associate your new email with an existing record (e.g., contacts, companies).
Field | Description |
---|---|
hs_timestamp | Required. This field marks the email’s time of creation and determines where the email sits on the record timeline. You can use either a Unix timestamp in milliseconds or UTC format. |
hubspot_owner_id | The ID of the owner associated with the email. This field determines the user listed as the email creator on the record timeline. |
hs_email_direction | The direction the email was sent in. Possible values include:EMAIL : the email was sent from the CRM or sent and logged to the CRM with the BCC address.INCOMING_EMAIL : the email was a reply to a logged outgoing email. FORWARDED_EMAIL : the email was forwarded to the CRM. |
hs_email_html | The body of an email if it is sent from a CRM record. |
hs_email_status | The send status of the email. The value can be BOUNCED , FAILED , SCHEDULED , SENDING , or SENT . |
hs_email_subject | The subject line of the logged email. |
hs_email_text | The body of the email. |
hs_attachment_ids | The IDs of the email’s attachments. Multiple attachment IDs are separated by a semi-colon. |
hs_email_headers | The email’s headers. The value for this property will automatically populate certain read only email properties. Learn how to set email headers. |
hs_email_headers
value.
Field | Description |
---|---|
hs_email_from_email | The email address of the email’s sender. |
hs_email_from_firstname | The email sender’s first name. |
hs_email_from_lastname | The email sender’s last name. |
hs_email_to_email | The email addresses of the email’s recipients. |
hs_email_to_firstname | The first names of the email’s recipients. |
hs_email_to_lastname | The last names of the email recipient. |
From
and Sender
. These are often the same, but because Sender
identifies what actually submitted an email, there are scenarios where the values may differ. For example, if an email is sent from an email alias, the From
value will refer to the user’s actual email address, and the Sender
value will refer to the email alias.hs_email_headers
value, you can use a JSON escaped string with the following data:
Field | Description |
---|---|
to | The record you want to associate with the email, specified by its unique id value. |
types | The type of the association between the email and the record. Include the associationCategory and associationTypeId . Default association type IDs are listed here, or you can retrieve the value for custom association types (i.e. labels) via the associations API. |
GET
request to /crm/v3/objects/emails/{emailId}
. You can also include the following parameters in the request URL:
Parameter | Description |
---|---|
properties | A comma separated list of the properties to be returned. If a requested property isn’t defined, it won’t be included in the response. If a requested property is defined but an email doesn’t have a value, it will be returned as null . |
associations | A comma separated list of object types to retrieve associated IDs for. Any specified associations that don’t exist will not be returned in the response. Learn more about the associations API. |
GET
request to crm/v3/objects/emails
. You can include the following parameters in the request URL:
Parameter | Description |
---|---|
limit | The maximum number of results to display per page. |
properties | A comma separated list of the properties to be returned.If a requested property isn’t defined, it won’t be included in the response. If a requested property is defined but an email doesn’t have a value, it will be returned as null . |
PATCH
request to /crm/v3/objects/emails/{emailId}
.
In the request body, include the email properties that you want to update. For example, your request body might look similar to the following:
PUT
request to /crm/v3/objects/emails/{emailId}/associations/{toObjectType}/{toObjectId}/{associationTypeId}
. The request URL contains the following fields:
Field | Description |
---|---|
emailId | The ID of the email. |
toObjectType | The type of object that you want to associate the email with (e.g., contact or company) |
toObjectId | The ID of the record that you want to associate the email with. |
associationTypeId | A unique identifier to indicate the association type between the email and the other object. The ID can be represented numerically or in snake case (e.g., email_to_contact ). You can retrieve the value through the associations API. |
https://api.hubspot.com/crm/v3/objects/emails/17691787884/associations/contact/104901/198
DELETE
request to the same URL as above:
/crm/v3/objects/emails/{emailId}/associations/{toObjectType}/{toObjectId}/{associationTypeId}
id
in the hs_pinned_engagement_id
field when creating or updating a record via the object APIs. Learn more about using the companies,contacts, deals, tickets, and custom objects APIs.
DELETE
request to /crm/v3/objects/emails/{emailId}
.
Learn more about deleting emails by checking out the reference documentation.