Updating a User Field with Zendesk Api | Community
Skip to main content

Updating a User Field with Zendesk Api

  • June 6, 2022
  • 5 replies
  • 0 views

Juan21

Hi, I want to use Zendesk Api to update a user field in the profile. In order words, I would like to pass from a blank or "-" value to a new value that i want to specify within the Put request. I do not know if Zendesk provides a command for doing so. Currently, I have found the doc for managing user fields with the API and I see comands for (Update User Field, create or update user field option, etc), but I am not sure which one should I use to update a blank space in that user field and set it to a new value. 

https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#update-user-field

Note: The user field type is drop-down

5 replies

Juan21
  • Author
  • June 6, 2022

Hi Ahmed! thanks for your help. So in order to specify the user field to be changed, I replace "user_field_key_1" with the user field ID or I should put it in another part of that code block?


Nicole17
  • June 6, 2022

Thanks for jumping in to problem solve, @ahmed11!


Hello everybody,

I am currently working on the idea of a contact counter in the user profile, with which one can track how often a customer has been contacted.

The function should look something like this: Lightagents try to contact users. With each attempt, the light agents leave an internal comment with a certain keyword. This keyword activates a trigger with a webhook that updates the user field (contact attempt).

I have copied the above-mentioned suggestion as a basis. However, I would now need a function that increases the value in the user field by 1 for each contact attempt. 

Does anyone have an idea how to implement this?

So in principle:

curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}.json \
-d '{"user": {"user_fields": {"counter": "increase value by 1"}}}' \
-H "Content-Type: application/json" -X PUT \
-v -u {user}:{api_key}

Hi Ahmed, thank you for your reply :)

I would use a Zendesk webhook. How would it work with a liquid placeholder?


Hello Ahmed,

It took a while to get back to this issue.

Yes, this code works exactly as it should! Thanks again for your help :)