Adding tags to tickets without overwriting existing tags

If you use the Update API to add one or more tags to a ticket, the new tags overwrite any existing tags. It can be a problem if you want to keep the existing tags. The solution is to use the Update Many API. It lets you add tags without overwriting existing ones. You can also remove old tags without affecting existing tags.

The update many API is expressed as follows:

PUT /api/v2/tickets/update_many.json?ids={ids}

It accepts a comma-separated list of up to 100 ticket ids. The updated data is sent in a ticket object with the properties to be updated. Example:

curl https://{subdomain}.zendesk.com/api/v2/tickets/update_many.json?ids=1,2,3 \  -d '{"ticket": {"status": "solved"}}' \  -H "Content-Type: application/json" \  -v -u {email_address}:{password} -X PUT \

To add or remove tags, include the additional_tags or the remove_tags property, as described in the following sections.

Add tags

To add tags to tickets, include the additional_tags property in the ticket object. The property takes an array of tags. Examples:

Bulk updates

curl https://{subdomain}.zendesk.com/api/v2/tickets/update_many.json?ids=1,2,3 \  -d '{"ticket": {"additional_tags":["new_tag_1"]}}' \  -H "Content-Type: application/json" \  -v -u {email_address}:{password} -X PUT

Batch updates

curl https://{subdomain}.zendesk.com/api/v2/tickets/update_many.json \  -d '{"tickets": [{ "id": 123, "additional_tags": "a_new_tag" }, { "id": 456, "additional_tags": "another_new_tag" }]}' \   -H "Content-Type: application/json" \  -v -u {email_address}:{password} -X PUT \

Remove tags

To remove selected tags from tickets, include the remove_tags property. Example:

curl https://{subdomain}.zendesk.com/api/v2/tickets/update_many.json?ids=1,2,3 \  -d '{"ticket": {"remove_tags":["old_tag_1"]}}' \  -H "Content-Type: application/json" \  -v -u {email_address}:{password} -X PUT