POST
/
api
/
customers
/
upsert
curl --request POST \
  --url https://app.laudspeaker.com/api/customers/upsert \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "primary_key": "<string>",
  "properties": "<any>"
}'
{
  "id":"65a70f3c373d50b91ea57438"
}

The upsert endpoint is designed to allow Luadspeaker users the programmatic ability to add new customers or update existing customers.

The upsert endpoint looks up a customer document using the supplied primary_key, and then adds or changes customer attribute values specified in the properties json object in the request body.

In order to use this endpoint, a primary key must have first been selected via the Laudspeaker UI.

Authentication

Authorization
string
required

Header for authenticating with Laudspeaker. Starts with Api-Key followed by the API key, for example Api-Key M4jxXt6diYz1Dds1YmhHe93KGPAUi24PlXgaiRXi.

Body

primary_key
string
required

This field specifies the primary key value used to uniquely identify users.

properties
json

This is where additional properties are added to the customer object. To delete a property, pass the key with value set to null.

Response

{
  "id":"65a70f3c373d50b91ea57438"
}
id
string
required

The id of the customer object that was created or modified.

Examples

Creating an empty customer document

curl --request POST \
  --url https://app.laudspeaker.com/api/customers/upsert \
  --header 'Authorization: Api-Key M4jxXt6diYz1Dds1YmhHe93KGPAUi24PlXgaiRXi' \
  --header 'Content-Type: application/json' \
  --data '{
  "primary_key": "johnsmith@example.com"
}'

Updating an existing customer document

curl --request POST \
  --url https://app.laudspeaker.com/api/customers/upsert \
  --header 'Authorization: Api-Key M4jxXt6diYz1Dds1YmhHe93KGPAUi24PlXgaiRXi' \
  --header 'Content-Type: application/json' \
  --data '{
  "primary_key": "johnsmith@example.com",
  "properties": {
    "firstName": "John",
    "lastName": "Smith"
  }
}'

Deleting a field from an existing customer document

curl --request POST \
  --url https://app.laudspeaker.com/api/customers/upsert \
  --header 'Authorization: Api-Key M4jxXt6diYz1Dds1YmhHe93KGPAUi24PlXgaiRXi' \
  --header 'Content-Type: application/json' \
  --data '{
  "primary_key": "johnsmith@example.com",
  "properties": {
    "firstName": "John",
    "lastName": null
  }
}'