Contact Activity

Hi! I’m trying to add activity log like this (with instructions from whom)

I have already tried doing it through /crm/v3/objects/Communications endpoint
request body:

{'associactions': { 'to': { 'id': {contact_id} }, 'types': [ { 'associationCategory': 'HUBSPOT_DEFINED', 'associationTypeId': 81 } ]},'properties': { 'hs_communication_channel_type': 'WHATS_APP', 'hs_communication_logged_from': 'CRM', 'hs_communication_body': text, 'hs_timestamp': {str timestamp}, 'hubspot_owner_id': {owner_id}}}

But in this endpoint there is no parameter “From” and it doesn’t work for me (“From” not filled). I got the result:

Hi @AOsmanov,

You should be able to do this by passing through a valid owner ID in your request (which you seem to be doing). I was successfully able to do so. See below:

POST https://api.hubapi.com/crm/v3/objects/communications
BODY
{
 "properties": {
 "hs_communication_channel_type": "WHATS_APP",
 "hs_communication_logged_from": "CRM",
 "hs_communication_body": "This was created via the API",
 "hs_timestamp": "2023-08-30T13:40:00Z",
 "hubspot_owner_id": 1147024111
 },
 "associations": [
 {
 "to": {
 "id": 101
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 81
 }
 ]
 }
 ]
}
RESPONSE
{
 "id": "19847492314",
 "properties": {
 "hs_all_owner_ids": "1147024111",
 "hs_body_preview": "This was created via the API",
 "hs_body_preview_html": "<html>\n <head></head>\n <body>\n This was created via the API\n </body>\n</html>",
 "hs_body_preview_is_truncated": "false",
 "hs_communication_body": "This was created via the API",
 "hs_communication_channel_type": "WHATS_APP",
 "hs_communication_logged_from": "CRM",
 "hs_createdate": "2023-08-30T12:41:39.482Z",
 "hs_lastmodifieddate": "2023-08-30T12:41:39.482Z",
 "hs_object_id": "19847492314",
 "hs_object_source": "INTEGRATION",
 "hs_object_source_id": "1914406",
 "hs_timestamp": "2023-08-30T13:40:00Z",
 "hs_user_ids_of_all_owners": "4592290",
 "hubspot_owner_assigneddate": "2023-08-30T12:41:39.482Z",
 "hubspot_owner_id": "1147024111"
 },
 "createdAt": "2023-08-30T12:41:39.482Z",
 "updatedAt": "2023-08-30T12:41:39.482Z",
 "archived": false
}

The value supplied to “hubspot_owner_id” can be retrieved by using the Owners API. Specifically GET /crm/v3/owners (see below):

GET https://api.hubapi.com/crm/v3/owners/
RESPONSE
{
 "results": [
 {
 "id": "1147024111",
 "email": "jackcoldrick90@gmail.com",
 "firstName": "Jack",
 "lastName": "Coldrick",
 "userId": 4592290,
 "createdAt": "2023-07-17T14:35:51.734Z",
 "updatedAt": "2023-08-28T20:42:50.533Z",
 "archived": false
 }
 ]
}

Notice in the response above the presence of both an “id” and a “userId” attribute. You must use the “id” attribute to create the communication. If you use the “userId” it will not work. The final output can be seen below:

If you are still facing issues can you please share the response that you get back from HubSpot?

I hope this helps!