Apply a JSON Patch (RFC 6902) to the specified profile or create one if a profile doesn't already exist.

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": "[email protected]",
  "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": "[email protected]"}

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

[{"op": "replace", "path": "/email", "value": "[email protected]"}]

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

[
  {"op": "replace", "path": "/email", "value": "[email protected]"},
  {"op": "replace", "path": "/phone_number", "value": "[email protected]"}
]

More Examples

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

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

The above with result with:

{
  "status": "SUCCESS"
}

📘

For more details about JSON Patch syntax:

Language
Authentication
Response
Click Try It! to start a request and see the response here!