williamcodes
williamcodes

Reputation: 7246

Remove email and phone number from customer in Kustomer

I'm having trouble deleting the emails and phones keys from customers.

When I have to re-create a customer, I get an error message because the first record has the same phone and email address. I tried simply removing them from the old record but it gives me a 400 bad request. It says I need to specify an email and phone.

This wouldn't be surprising, especially since the documentation specifies that they are required fields. What's strange is that I can create customers without emails and phones just fine. It's just that once they have them, I can't get rid of them. Is there some workaround that would allow me to re-create a customer?

Upvotes: 1

Views: 79

Answers (1)

John
John

Reputation: 30

The way to currently remove an email or phone number from a customer is to update the customer object with the emails you want to keep.

For an example, if you have a customer object that looks like:

{
  "data": {
    "type": "customer",
    "id": "58863fe94aa1701100efcb1d",
    "attributes": {
      "name": "Joe Cornelius Schmoe III",
      "displayName": "Joe Cornelius Schmoe III",
      "displayColor": "teal",
      "displayIcon": "broom",
      "externalId": "user-3",
      "externalIds": [
        {
          "externalId": "user-3",
          "verified": true
        }
      ],
      "firstName": "Joe",
      "lastName": "Schmoe",
      "sharedExternalIds": [],
      "emails": [
        {
          "email": "[email protected]",
          "verified": false,
          "type": "home"
        },
        {
          "email": "[email protected]",
          "verified": false,
          "type": "home"
        }
      ],
      ....
}

In cases where you would like to remove the email associated with home (works the same way for phones array.)

PUT /v1/customers/{customerId}

{
    "emails": [
        {
          "email": "[email protected]",
          "verified": false,
          "type": "home"
        }
    ]
}

The customer record will now be updated to only include the specified email.

{
  "data": {
    "type": "customer",
    "id": "58863fe94aa1701100efcb1d",
    "attributes": {
      "name": "Joe Cornelius Schmoe III",
      "displayName": "Joe Cornelius Schmoe III",
      "displayColor": "teal",
      "displayIcon": "broom",
      "externalId": "user-3",
      "externalIds": [
        {
          "externalId": "user-3",
          "verified": true,
          "id": null
        }
      ],
      "firstName": "Joe",
      "lastName": "Schmoe",
      "sharedExternalIds": [],
      "emails": [
        {
          "email": "[email protected]",
          "verified": false,
          "type": "home",
          "id": null
        }
      ]
      .....
}

Upvotes: 1

Related Questions