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. Example:

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

Note: The additional_tags and remove_tags properties (see next section) only work with bulk updates, where the tickets are specifiedĀ in the ids parameter in the query string. The properties don't work with batch updates, where the tickets are listed in a tickets array in the data payload. For example, the following request won't work:

curl https://{subdomain}.zendesk.com/api/v2/tickets/update_many.json \  -d '{"tickets": [{"id": 1339, "additional_tags":["new_tag_2"], "status": "pending"}, {"id": 1340, "additional_tags":["new_tag_2"], "status": "pending"}]}'   -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