# Updating a profile via API

**URL:** <https://forum.youcanbook.me/t/updating-a-profile-via-api/2257>\
**Category:** API\
**Created:** [May 23, 2023, 4:32pm UTC](https://forum.youcanbook.me/t/updating-a-profile-via-api/2257 "2023-05-23T16:32:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![caseyo](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@caseyo](https://forum.youcanbook.me/u/caseyo)\
**Post date:** [May 23, 2023, 4:32pm UTC](https://forum.youcanbook.me/t/updating-a-profile-via-api/2257/1 "2023-05-23T16:32:15Z")

</div>

Hi, I’m investigating using the profile API to update profile webhook configurations, but I can’t quite figure out how to use the PATCH command `/v1/:accountId/profiles/:profileId`.

I’m attempting to add missing webhook configs and update misconfigured ones. I’m fetching profiles with a call like this:

```auto
GET /v1/:accountId/profiles/:profileId?fields=id,actions,actions.id,actions.type,actions.anchor,actions.to,actions.body,headers,headers.x-auth-token

```

(We add our webhook auth in a header)

I’m then removing misconfigured `actions` and adding new ones to the end of the list, omitting the `id` field. The set of `actions` is as before but with new/modified ones appended to the end. Doing a PATCH against

```auto
PATCH /v1/:accountId/profiles/:profileId?fields=actions,actions.type,actions.anchor,actions.to,actions.body,actions.headers,actions.headers.x-auth-token

```

This gives me a 400 Bad Request error with response:

```auto
{
    "type": "CaligraphException",
    "code": "caligraph_invalid_payload",
    "message": "Invalid payload",
    "status": "BAD_REQUEST",
    "errors": [],
    "httpStatusCode": 400
}

```

I’m unsure what’s wrong or how to use this API properly.

Do I need to include all existing actions when adding or modifying some?

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.youcanbook.me/ben/32/772_2.png) [@Ben](https://forum.youcanbook.me/u/Ben)\
**Post date:** [May 24, 2023, 9:45pm UTC](https://forum.youcanbook.me/t/updating-a-profile-via-api/2257/2 "2023-05-24T21:45:00Z")

</div>

@caseyo with actions you need to pass in all the actions you have in order to update. For the webhook headers your action for those will look like this:  
{  
“type” : “WEBHOOK”,  
“status” : “TEMPLATE”,  
“anchor” : “BOOKING\_CREATED”,  
“offsetMinutes” : 0,  
“title” : “Booking created API call”,  
“to” : “[https://webhookURL.com](https://webhookURL.com)”,  
“subject” : “POST”,  
“body” : “{ "startsAt": "{START-LOCAL-DATE}",\n"id" : "{ID}",\n"ref": "{REF}",\n"rescheduleLink": "{RESCHEDULE-LINK}",\n"cancellationLink" : "{CANCEL-LINK}",\n "endsAt": "{END-LOCAL-TIME}",\n "timeZone": "{TIMEZONE}", \n"firstName": "{FNAME}", \n"email": "{EMAIL}" \n}”,  
“attachIcs” : false,  
“headers” : {  
“test” : “test1234”,  
“another” : “headerhere”,  
}  
}

Again you need to PATCH in all actions to update any of them. What you pass in will overwrite what is there.

---

<div class="post-metadata">

**Author:** ![caseyo](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@caseyo](https://forum.youcanbook.me/u/caseyo)\
**Post date:** [May 24, 2023, 10:47pm UTC](https://forum.youcanbook.me/t/updating-a-profile-via-api/2257/3 "2023-05-24T22:47:05Z")

</div>

Do I need to specify the `fields` query parameter with the `PATCH`?

Can I submit the existing actions that won’t change as they are read from the API, or do I need to remove any fields (e.g., `id`)?

So if I fetch a profile with the call:

```auto
GET /v1/:accountId/profiles/:profileId?fields=actions,actions.*,actions.headers,actions.headers.*

```

Then PATCH something like this:

```auto
{
  "actions": [
    // All actions that are not webhook actions or which are currently correct, as fetched with the GET call above, unmodified
    ...,
    // Webhooks that are missing or misconfigured
    ...
  ]
}

```

---

<div class="post-metadata">

**Author:** ![caseyo](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@caseyo](https://forum.youcanbook.me/u/caseyo)\
**Post date:** [May 24, 2023, 10:58pm UTC](https://forum.youcanbook.me/t/updating-a-profile-via-api/2257/4 "2023-05-24T22:58:43Z")

</div>

Nevermind! I got it to work! My remaining issue was a typo in the `anchor` values (`CANCELED` vs `CANCELLED`).
