When I create the email via API I have to add hubspot_owner_id, which is reflected as email author in the interface.
Today I faced the issue, that no matten which hubspot_owner_id I post, I receive the error.
Here is the sample request and response
curl --request POST \ --url https://api.hubspot.com/crm/v3/objects/emails \ --header 'Authorization: Bearer *********************************' \ --header 'Content-Type: application/json' \ --data '{ "properties": { "hs_timestamp": "2019-10-30T03:30:17.883Z", "hubspot_owner_id": "28420727", "hs_email_direction": "EMAIL", "hs_email_status": "SENT", "hs_email_subject": "Lets talk", "hs_email_text": "Thanks for your interest lets find a time to connect" } }'
Response:
{ "status": "error", "message": "Property values were not valid: [{\"isValid\":false,\"message\":\"28420727 was not a valid owner ID\",\"error\":\"INVALID_OWNER_ID\",\"name\":\"hubspot_owner_id\"}]", "correlationId": "1734a9c2-db7d-4396-ae86-51883ac201a9", "category": "VALIDATION_ERROR" }
Hey, @IHaida👋 Thanks for the interesting question. For this engagement endpoint, you need to make sure you are using the Owner ID and not the User ID when you send your request. It got me on my first test as well. Here's what I did:
First I tried using the User ID (not remembering these are two separate values) 🙃 User ID
Owner ID
Request (not successful)
curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/emails \
--header 'authorization: Bearer MY_PRIVATE_APP' \
--header 'content-type: application/json' \
--data '{
"properties": {
"hs_timestamp": "2019-10-30T03:30:17.883Z",
"hubspot_owner_id": "10029778",
"hs_email_direction": "EMAIL",
"hs_email_status": "SENT",
"hs_email_subject": "Lets talk",
"hs_email_text": "Thanks for your interest. Lets find a time to connect about cats"
}
}'
Response
HTTP 400
{
"status": "error",
"message": "Property values were not valid: [{\"isValid\":false,\"message\":\"10029778 was not a valid owner ID\",\"error\":\"INVALID_OWNER_ID\",\"name\":\"hubspot_owner_id\"}]",
"correlationId": "5d58e23b-3e6e-4899-962f-d2cd9aa3e088",
"category": "VALIDATION_ERROR"
}
But when I switched to Owner ID
curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/emails \
--header 'authorization: Bearer MY_PRIVATE_APP' \
--header 'content-type: application/json' \
--data '{
"properties": {
"hs_timestamp": "2019-10-30T03:30:17.883Z",
"hubspot_owner_id": "199431518",
"hs_email_direction": "EMAIL",
"hs_email_status": "SENT",
"hs_email_subject": "Lets talk",
"hs_email_text": "Thanks for your interest. Lets find a time to connect about cats"
}
}'
Response
HTTP 201
{
"id": "24364730256",
"properties": {
"hs_all_owner_ids": "199431518",
"hs_body_preview": "Thanks for your interest. Lets find a time to connect about cats",
"hs_body_preview_html": "Thanks for your interest. Lets find a time to connect about cats",
"hs_body_preview_is_truncated": "false",
"hs_createdate": "2022-08-08T00:48:19.468Z",
"hs_email_attached_video_opened": "false",
"hs_email_attached_video_watched": "false",
"hs_email_direction": "EMAIL",
"hs_email_status": "SENT",
"hs_email_subject": "Lets talk",
"hs_email_text": "Thanks for your interest. Lets find a time to connect about cats",
"hs_lastmodifieddate": "2022-08-08T00:48:19.468Z",
"hs_object_id": "24364730256",
"hs_timestamp": "2019-10-30T03:30:17.883Z",
"hs_user_ids_of_all_owners": "10029778",
"hubspot_owner_assigneddate": "2022-08-08T00:48:19.468Z",
"hubspot_owner_id": "199431518"
},
"createdAt": "2022-08-08T00:48:19.468Z",
"updatedAt": "2022-08-08T00:48:19.468Z",
"archived": false
}
Please note, if you need to access the owner IDs via API, we offer the Owners API:
Hey, @IHaida👋 Thanks for the interesting question. For this engagement endpoint, you need to make sure you are using the Owner ID and not the User ID when you send your request. It got me on my first test as well. Here's what I did:
First I tried using the User ID (not remembering these are two separate values) 🙃 User ID
Owner ID
Request (not successful)
curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/emails \
--header 'authorization: Bearer MY_PRIVATE_APP' \
--header 'content-type: application/json' \
--data '{
"properties": {
"hs_timestamp": "2019-10-30T03:30:17.883Z",
"hubspot_owner_id": "10029778",
"hs_email_direction": "EMAIL",
"hs_email_status": "SENT",
"hs_email_subject": "Lets talk",
"hs_email_text": "Thanks for your interest. Lets find a time to connect about cats"
}
}'
Response
HTTP 400
{
"status": "error",
"message": "Property values were not valid: [{\"isValid\":false,\"message\":\"10029778 was not a valid owner ID\",\"error\":\"INVALID_OWNER_ID\",\"name\":\"hubspot_owner_id\"}]",
"correlationId": "5d58e23b-3e6e-4899-962f-d2cd9aa3e088",
"category": "VALIDATION_ERROR"
}
But when I switched to Owner ID
curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/emails \
--header 'authorization: Bearer MY_PRIVATE_APP' \
--header 'content-type: application/json' \
--data '{
"properties": {
"hs_timestamp": "2019-10-30T03:30:17.883Z",
"hubspot_owner_id": "199431518",
"hs_email_direction": "EMAIL",
"hs_email_status": "SENT",
"hs_email_subject": "Lets talk",
"hs_email_text": "Thanks for your interest. Lets find a time to connect about cats"
}
}'
Response
HTTP 201
{
"id": "24364730256",
"properties": {
"hs_all_owner_ids": "199431518",
"hs_body_preview": "Thanks for your interest. Lets find a time to connect about cats",
"hs_body_preview_html": "Thanks for your interest. Lets find a time to connect about cats",
"hs_body_preview_is_truncated": "false",
"hs_createdate": "2022-08-08T00:48:19.468Z",
"hs_email_attached_video_opened": "false",
"hs_email_attached_video_watched": "false",
"hs_email_direction": "EMAIL",
"hs_email_status": "SENT",
"hs_email_subject": "Lets talk",
"hs_email_text": "Thanks for your interest. Lets find a time to connect about cats",
"hs_lastmodifieddate": "2022-08-08T00:48:19.468Z",
"hs_object_id": "24364730256",
"hs_timestamp": "2019-10-30T03:30:17.883Z",
"hs_user_ids_of_all_owners": "10029778",
"hubspot_owner_assigneddate": "2022-08-08T00:48:19.468Z",
"hubspot_owner_id": "199431518"
},
"createdAt": "2022-08-08T00:48:19.468Z",
"updatedAt": "2022-08-08T00:48:19.468Z",
"archived": false
}
Please note, if you need to access the owner IDs via API, we offer the Owners API:
I don't think the endpoint you are calling is valid. Or at least it's certainly not one that I am familiar with. I cannot find it documented anywhere on the HubSpot Developer site. It's true you can create marketing emails via API but this is done using the v1 endpoint here and it does not require you to specify an owner ID. For instance:
curl --location --request POST 'https://api.hubapi.com/marketing-emails/v1/emails' --header 'Authorization: Bearer XXXXXXXXXXXX' --header 'Content-Type: application/json' --data-raw '{ "name": "My first API marketing email!", "subject": "Sample subject line" }'
Returns the below and for the most part if you include any of the below in your initial POST request you can set create the email with various pieces of information preset and ready to go.