# Error while creating email via API

**URL:** <https://community.hubspot.com/t/error-while-creating-email-via-api/62442>\
**Category:** APIs & Integrations\
**Tags:** email\
**Created:** [August 5, 2022, 7:29am UTC](https://community.hubspot.com/t/error-while-creating-email-via-api/62442 "2022-08-05T07:29:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IHaida](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ihaida/32/195582_2.png) [@IHaida](https://community.hubspot.com/u/IHaida)\
**Post date:** [August 5, 2022, 7:29am UTC](https://community.hubspot.com/t/error-while-creating-email-via-api/62442/1 "2022-08-05T07:29:24Z")

</div>

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](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”  
}

Can somebody help with this?

---

<div class="post-metadata">

**Author:** ![coldrickjack](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/coldrickjack/32/6684_2.png) [@coldrickjack](https://community.hubspot.com/u/coldrickjack)\
**Post date:** [August 5, 2022, 12:26pm UTC](https://community.hubspot.com/t/error-while-creating-email-via-api/62442/2 "2022-08-05T12:26:27Z")

</div>

Hi @IHaida,

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](https://developers.hubspot.com/docs/api/marketing/marketing-emails). It’s true you can create marketing emails via API but this is done using the [v1 endpoint here](https://legacydocs.hubspot.com/docs/methods/cms_email/create-a-new-marketing-email) 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.

`{"ab": false,"abHoursToWait": 4,"abSampleSizeDefault": null,"abSamplingDefault": null,"abSuccessMetric": null,"abTestPercentage": 50,"abVariation": false,"absoluteUrl": "http://xxxxxx.hs-sites-eu1.com/-temporary-slug-bc511b85-a54d-40dd-933a-b77f16bd2956","allEmailCampaignIds": [],"analyticsPageId": "51526178296","analyticsPageType": "email","archived": false,"archivedAt": 0,"archivedInDashboard": false,"audienceAccess": "PUBLIC","blogRssSettings": null,"canSpamSettingsId": 51418157807,"categoryId": 2,"contentAccessRuleIds": [],"contentAccessRuleTypes": [],"contentTypeCategory": 2,"createPage": false,"created": 1659701891943,"createdById": 46163190,"currentState": "DRAFT","currentlyPublished": false,"customReplyTo": "","customReplyToEnabled": false,"domain": "","emailBody": "{% content_attribute \"email_body\" %}{{ default_email_body }}{% end_content_attribute %}","emailNote": "","emailTemplateMode": "DESIGN_MANAGER","emailType": "BATCH_EMAIL","feedbackSurveyId": null,"flexAreas": {},"freezeDate": 1659701891943,"fromName": "","hasContentAccessRules": false,"htmlTitle": "","id": 51526178296,"isGraymailSuppressionEnabled": true,"isPublished": false,"isRecipientFatigueSuppressionEnabled": null,"language": "en","layoutSections": {},"liveDomain": "xxxxxxx.hs-sites-eu1.com","mailingListsExcluded": [],"mailingListsIncluded": [],"maxRssEntries": 5,"metaDescription": "","name": "My first API marketing email!","pageExpiryEnabled": false,"pageRedirected": false,"pastMabExperimentIds": [],"portalId":xxxxxxx,"previewKey": "VsCBuisB","processingStatus": "","publishDate": 1659701892042,"publishImmediately": true,"publishedUrl": "","replyTo": "","resolvedDomain": "xxxxxxx.hs-sites-eu1.com","rssEmailByText": "By","rssEmailClickThroughText": "Read more »","rssEmailCommentText": "Comment »","rssEmailEntryTemplateEnabled": false,"rssEmailImageMaxWidth": 0,"rssEmailUrl": "","sections": {},"securityState": "NONE","slug": "-temporary-slug-bc511b85-a54d-40dd-933a-b77f16bd2956","smartEmailFields": null,"state": "DRAFT","styleSettings": null,"subcategory": "batch","subject": "Sample subject line","subscription": 148019002,"subscriptionName": "test","teamPerms": [],"templatePath": "","transactional": false,"translations": {},"unpublishedAt": 0,"updated": 1659701891943,"updatedById": 46163190,"url": "http://xxxxxxx.hs-sites-eu1.com/-temporary-slug-bc511b85-a54d-40dd-933a-b77f16bd2956","useRssHeadlineAsSubject": false,"userPerms": [],"vidsExcluded": [],"vidsIncluded": [],"widgets": {}}`

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 8, 2022, 1:44am UTC](https://community.hubspot.com/t/error-while-creating-email-via-api/62442/3 "2022-08-08T01:44:43Z")

</div>

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

 ![user_ID.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/3/33b41f06634a458b297281af53a13b9f8dc82ea5.png)

Owner ID

 ![owner_ID.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/1/016aeb5e7df15464b9b43d5220a641efc5481bb1.png)

Request (not successful)

```lia-code-sample
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

```lia-code-sample
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

```lia-code-sample
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

```lia-code-sample
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:](https://developers.hubspot.com/docs/api/crm/owners)

`GET /crm/v3/owners/`

I hope this helps get you moving forward.

Have fun coding! — Jaycee
