Updating a profile via API

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:

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

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:

{
    "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?

@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”,
“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.

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:

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

Then PATCH something like this:

{
  "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
    ...
  ]
}

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

1 Like