# Create and patch engagement

**URL:** <https://community.hubspot.com/t/create-and-patch-engagement/29021>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, contacts\
**Created:** [December 10, 2020, 4:01pm UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021 "2020-12-10T16:01:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SycoLTH](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sycolth/32/31184_2.png) [@SycoLTH](https://community.hubspot.com/u/SycoLTH)\
**Post date:** [December 10, 2020, 4:01pm UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021/1 "2020-12-10T16:01:17Z")

</div>

Hi,

I’m having some issues understanding the engagement api.

Here’s what I’m doing with the results of each call:

I start from this situation, the filter has only CALLS selected:

 ![35248i742819140D1F62CB.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/3/3a1bf5ceeb24951bb3653d626f825cf17e0be655.png)

I then POST a request to create a new CALL engagement:

```lia-code-sample
curl -X 'POST' -H 'Content-Type: application/json' "https://api.hubapi.com/engagements/v1/engagements?hapikey=${APIKEY}" --data '{
 "engagement": {
 "type": "CALL"
 },
 "associations": {
 "contactIds": [
 51
 ],
 "ownerIds": [
 1
 ]
 },
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "IN_PROGRESS"
 }
}'

{
 "associationCreateFailures": [],
 "engagement": {
 "id": 10141331606,
 "portalId": 8642268,
 "active": true,
 "createdAt": 1607615292658,
 "lastUpdated": 1607615292658,
 "type": "CALL",
 "timestamp": 1607615292658,
 "allAccessibleTeamIds": [],
 "queueMembershipIds": [],
 "gdprDeleted": false
 },
 "associations": {
 "contactIds": [
 51
 ],
 "companyIds": [],
 "dealIds": [],
 "ownerIds": [
 1
 ],
 "workflowIds": [],
 "ticketIds": [],
 "contentIds": [],
 "quoteIds": []
 },
 "attachments": [],
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "IN_PROGRESS"
 }
}

```

I refresh the page and this is what I see (up to this point is all as expected):

 ![35249i5D4E2CBF25FCA433.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/d/cd5e78e77d9edcebb722a7a795d0a304358cca70.png)

After a few seconds I send a PATCH request:

```lia-code-sample
curl -X 'PATCH' -H 'Content-Type: application/json' "https://api.hubapi.com/engagements/v1/engagements/10141331606?hapikey=${APIKEY}" --data '{
 "metadata": {
 "status": "COMPLETED",
 "durationMilliseconds": "29000"
 }
}'

{
 "engagement": {
 "id": 10141331606,
 "portalId": 8642268,
 "active": true,
 "createdAt": 1607615292658,
 "lastUpdated": 1607615332412,
 "type": "CALL",
 "timestamp": 1607615292658,
 "allAccessibleTeamIds": [],
 "queueMembershipIds": [],
 "gdprDeleted": false
 },
 "associations": {
 "contactIds": [],
 "companyIds": [],
 "dealIds": [],
 "ownerIds": [
 1
 ],
 "workflowIds": [],
 "ticketIds": [],
 "contentIds": [],
 "quoteIds": []
 },
 "attachments": [],
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "COMPLETED",
 "durationMilliseconds": 29000
 }
}

```

I then refresh the page again and here’s the problem:

 ![35250iEB70DFE2531A5C45.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/7/278fffb7f9f1ddd2af4c90ba09dcdd086217aa02.png)

It appears that the PATCH requests creates another call instead of updating the existing one.

Can someone help?

Thanks.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [December 11, 2020, 2:30pm UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021/2 "2020-12-11T14:30:43Z")

</div>

Hey @SycoLTH ,

I am going to try to replicate this on my end an

---

<div class="post-metadata">

**Author:** ![SycoLTH](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sycolth/32/31184_2.png) [@SycoLTH](https://community.hubspot.com/u/SycoLTH)\
**Post date:** [December 14, 2020, 10:18am UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021/3 "2020-12-14T10:18:17Z")

</div>

Hi,

Thanks for looking into this.

I just found out that it does the same wihtout the second step:

This query also creates 2 calls engagements for me, one with the right owner and duration, and the other one with the default admin as owner.

```lia-code-sample
curl -s -X POST -H 'Content-Type: application/json' --data '{
 "engagement": {
 "active": true,
 "type": "CALL",
 "ownerId": 55175625
 },
 "associations": {
 "contactIds": [1],
 "ownerIds": [55175625]
 },
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "COMPLETED",
 "durationMilliseconds": "29000"
 }
}' "https://api.hubapi.com/engagements/v1/engagements?hapikey=${APIKEY}" | jq .

```

 ![35324i20363B6DBE83AE4F.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/3/38392b91563c9d075aff70ff65d7ef90a7f93b71.png)

A

---

<div class="post-metadata">

**Author:** ![SycoLTH](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sycolth/32/31184_2.png) [@SycoLTH](https://community.hubspot.com/u/SycoLTH)\
**Post date:** [December 14, 2020, 10:26am UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021/4 "2020-12-14T10:26:15Z")

</div>

Also (and then I’ll stop posting and let you investigate the issue), if I exec that curl command multiple times, let’s say 3 times, I get 3 valid call engagements, and 1 phantom call at the top.

Note that I don’t have any other engagement for this account before testing this (this could also be a factor).

Thanks

---

<div class="post-metadata">

**Author:** ![SycoLTH](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sycolth/32/31184_2.png) [@SycoLTH](https://community.hubspot.com/u/SycoLTH)\
**Post date:** [March 18, 2021, 11:27am UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021/5 "2021-03-18T11:27:55Z")

</div>

Hi, any update on this?  
I still see 1 phantom call at the top of every contact.

Thanks

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [March 18, 2021, 3:49pm UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021/6 "2021-03-18T15:49:50Z")

</div>

@SycoLTH

First of all, apologies for not getting back to you on this.

Secondly, I am not able to reproduce it and I used the exact code blocks that you posted 🤔

@RMones (apolgies for the numerous tags today), are you able to replicate this issue?

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [March 18, 2021, 4:09pm UTC](https://community.hubspot.com/t/create-and-patch-engagement/29021/7 "2021-03-18T16:09:33Z")

</div>

Hehe no problem @dennisedson! There will be a day then I aks you for a Hubspot T-shirt 😂

I tried it also with the latest code example you send, But changed only the following fields:  
FROM “ownerId”: 55175625 TO “ownerId”: 1

FROM: “contactIds”: [1] TO “contactIds”: [55175625],  
FROM “ownerIds”: [55175625] TO “ownerIds”: [1] “ownerId”: 55175625

And then the result is as expected (one call of 29 seconds):

 ![39648i0F5C26FA3CAB14C7.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/5/f/5fb8c64d9db646993cdc7fbf30419440ff565d34.png)

 ![39649iC65382E0FD7CA87E.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/f/ef1de3df01826b1798900c3041047de1e4a9bf45.png)

Regards Ronald
