Loading...
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:

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

The above will result with:

{
"status": "SUCCESS"
}
info

For more details about JSON Patch syntax:

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

Method: PATCH

Path Parameters

recipient_idstringrequired
A unique identifier representing the recipient associated with the requested profile.

Body Parameters

patcharray
An array of patch operations. Learn more
+ Show Properties

Responses

status: 200 OK

statusstring

status: 400 Bad Request

messagestring
A message describing the error that occurred.
typestring
[invalid_request_error] The type of error that occurred.

Request Example

curl --request PATCH \
--url https://api.courier.com/profiles/0460766e-8463-4905-ae98-b72c7aef41d6 \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"patch": [
{
"op": "replace",
"path": "/email",
"value": "test@example.com"
}
]
}
'

Responses Example

{
"status": "SUCCESS"
}
{
"message": "Error Message",
"type": "invalid_request_error"
}