Hello 👋🏼 How can we help?

Update customer

Update data of an existing customer by their id
Written by Konstantine
Updated 5 months ago

You can update any existing data attribute of a customer with this method. It also allows to add missing attributes and Custom Data to the customer profile.

If you want to update a number of customers at once, use Butch update customers method instead. To create a new customer, use Create customer method.

➡️ Request

URL https://api.helpcrunch.com/v1/customers/<customer_id>
Method PUT
Headers Authorization: Bearer <your_api_key>

<customer_id> is the identifier for the customer as given by HelpCrunch. It is required for this method and looks like a combination of numbers, for example 1568834.

Read more about authorization header here.

When updating a customer you can specify all the existing data fields or a part of them in the body of your PUT request. You can find all the available data fields in the Successful Response section below.

Request Body Example

{
    "notes": "He has never heard about magic",
    "source": null,
    "city": "London",
    "locale": "en",
    "regionCode": "London",
    "countryCode": "EN",
    "customData": [
        {
            "property": "Subscription Status",
            "value": "Suspended"
        },
        {
            "property": "Number of payments",
            "value": 13
        }
    ]
}


Tips

  • All dates should be passed in the UNIX timestamp format;
  • Locale filed should be passed as a string according to the ISO 639-1 standard;
  • Tag can be appended to the customer with Tag customer method or removed with Untag customer method. Tag will be automatically created and added to your account if you pass a non-existing one. You can assign any CSS color to the tag. If you don't specify it, the default #c377e0 color will be applied.
  • If you don't specify some fields in your request body, they will stay the same and will not be updated. In order to clear the value of a specific field, you should pass a null value for it in your request body.
Important note about customData 
We do not validate your customData attributes currently. The only error you may get is when you pass the customData not as an Array. Therefore, you should always check the type of data you send and make sure it matches the data type of the attribute.


✅ Successful Response

If your request has succeeded, you'll get a 200 OK success status code together with the following response body. 

{
    "id": 7831827,
    "name": "Hakim Zarakim",
    "email": "hzarakim@example.com",
    "userId": "example_22",
    "company": "example",
    "phone": null,
    "firstSeen": 1593547200,
    "lastSeen": 1593547200,
    "location": {
        "regionCode": "London",
        "countryCode": "EN",
        "city": "London"
    },
    "device": null,
    "unsubscribed": false,
    "blocked": false,
    "source": null,
    "referer": null,
    "locale": "en",
    "notes": "He has never heard about magic",
    "lastPage": null,
    "tags": [
        {
            "name": "Lead",
            "color": "#cсс"
        },
        {
            "name": "Paid",
            "color": "#c377e0"
        }
    ],
    "customData": [
        {
            "property": "Subscription status",
            "value": "Suspended"
        },
        {
            "property": "Number of payments",
            "value": 13
        }
    ]
}

You can get details on every Customer Object field in the Customer model article.

🛑 Error Responses

You may get one of the following error status codes and responses. More info on the errors is available here.

400 Bad Request

{
    "errors": [
        {
            "code": "validation_error",
            "message": "email value is invalid"
        },
        {
            "code": "validation_error",
            "message": "userId value is invalid"
        },
        {
            "code": "validation_error",
            "message": "source value is invalid"
        }
    ]
}

401 Unauthorized

{
    "errors": [
        {
            "code": "invalid_token",
            "message": "Invalid token"
        }
    ]
}

404 Not Found

{
    "errors": [
        {
            "code": "entity_not_found",
            "message": "Customer not found"
        }
    ]
}

429 Too Many Requests

{
    "errors": [
        {
            "code": "too_many_requests",
            "message": "You have exceeded your requests limit"
        }
    ]
}

If you have any questions regarding the REST API, feel free to chat us any time.

👩‍💻 Happy Coding! 👨‍💻

Did this answer your question?