how to create messages via api belonging the contact ,just created via api as well?

Hello

I researched engagements api.

I created contact from apis and can be able to view in hubspot, ver well.

my aim is , I want to create message(s) based on that contact.

before creating message, I think, I have to create thread. after that, I have to create messages belonging that thread. but thread does not have userId(s) .

I am little bit confused with the architecture.

could you tell me the right way to have api(s) to create the messages for the contact I have just created?

Hi @TKucur,

Thank you for your post!

I’ll invite a couple of API experts to this conversation as I’m not very familiar with this topic myself:

hi @coldrickjack, @klloyd__1, @Ismail, do you have any tips for @TKucur? Thank you! :star:

Cheers
Mia, Community Team

Thanks for the tag @MiaSrebrnjak

Hi @TKucur , happy to try and help here. In your original message’s error response I am seeing it state “INVALID_AUTHENTICATION”. Since you’re using the hapikey in your URL request, this is referring to that key being invalid. I would first recommend following the instructions in this developer documentation to migrate your script away from using hapikeys, and instead use Private Apps. HubSpot is sunsetting the ability to use hapikeys as authentication at the end of this month.

Once you’ve replaced the authentication method, double check that you’ve also included a JSON Body with your HTTP request, stating the association type and definition

--data ‘[
{
“associationCategory”: “HUBSPOT_DEFINED”,
“associationTypeId”: 0
}
]’

To find the associationTypeId for Contacts and notes, you can use the GET Association types endpoint .

1) I created a contact via api. Success.

2) I created a note via api. Success.

3) I tried to associate note with contact, but not success.

request (HttpPut)

https://api.hubspot.com/crm/v4/objects/notes/14538348530/associations/contact/251/?hapikey=pat-eu1-88925b2f-1972-4960-9ca1-9c57a732ba60

response

{

"status": "error",

"message": "The API key provided is invalid. View or manage your API key here: https://app.hubspot.com/l/api-key/",

"correlationId": "05fa4630-8980-4204-955d-a0959298dfbe",

"category": "INVALID\_AUTHENTICATION",

"links": {

    "api key": "https://app.hubspot.com/l/api-key/"

}

}

1) I created a contact via api. Success.

2) I created a note via api. Success.

3) I tried to associate note with contact, but not success.

I use httpput

hello

I fixed problem