Skip to main content

PATCH /profiles/:recipient_id

Unlike a PUT request, a PATCH request will update only a portion of a recipient's profile. PATCH syntax is a little more complicated. Courier uses the JSON Patch syntax described below.

Imagine that we have a profile with an email and phone_number. We want to update only the email address.

"profile": {
"email": "normanosborn@oscorp.com",
"phone_number": "555-555-5555",
}

Our patch request body will be JSON. The first key in a JSON Patch object will be op, which stands for the operation you are to perform. This is assigned a value of add, remove, replace, move, copy, or test. We already have an email address present, so we will use replace.

We list the value to be replaced by pointing to it using the path key. This path takes a value pointing to the key we want to target. The path is built using "/" characters. Our email key is one level deep, so we will use "/email". We then have a value key that is assigned the value we want to replace our existing email with. The entire line looks like this:

{ "op": "replace", "path": "/email", "value": "test@example.com" }

To send the PATCH request, we send an array with our JSON Patch objects.

[{ "op": "replace", "path": "/email", "value": "test@example.com" }]

If you want to update multiple values, your patch will look like this:

[
{ "op": "replace", "path": "/email", "value": "test@example.com" },
{ "op": "replace", "path": "/phone_number", "value": "test@example.com" }
]

More Examples

The following types of requests will not change the body of an existing Profile:

JSON
// Empty Patch Array
{
"patch": []
}

The above will result with:

200
{
"status": "SUCCESS"
}
info

For more details about JSON Patch syntax:

PATCHhttps://api.courier.com/profiles/:recipient_id
Apply a JSON Patch (RFC 6902) to the specified profile or create one if a profile doesn't already exist.
PATH PARAMS
recipient_idstringrequired
A unique identifier representing the recipient associated with the requested profile.
BODY PARAM
patcharray
An array of patch operations. Learn more
Responses
AUTH TOKEN
curl --request PATCH \
--url https://api.courier.com/profiles/0460766e-8463-4905-ae98-b72c7aef41d6 \
--header 'Accept: application/json'
Response Example
{
"status": "SUCCESS"
}

Example

Method: PATCH

URL: https://api.courier.com/profiles/abcdefgh12345678

Body: ​

{
[
{
"op": "replace",
"path": "/email",
"value": "test@example.com"
},
{
"op": "add",
"path": "/phone_number",
"value": "1234567890"
}
]
}