Create, update, delete, and query Tickets.
Table Specific Information
SelectThe following queries are processed server side.
SELECT * FROM Tickets SELECT * FROM Tickets WHERE Id = '123' SELECT * FROM Tickets WHERE Id IN ('123', '456') SELECT * FROM Tickets WHERE UserId = '123' SELECT * FROM Tickets WHERE OrganizationId = '123' SELECT * FROM Tickets WHERE ViewId = '123'
The following ticket property keywords (columns/pseudo-columns) from the Search API are supported in the WHERE clause: created (CreatedAt), updated (UpdatedAt), due_date (DueAt), assignee, submitter, requester, via, subject, description, status, priority, ticket_type (Type), group, tags, commenter, cc, has_attachment.
The supported search operators are: =, <, >, <=, >=. For example:
SELECT * FROM Tickets WHERE CreatedAt='2017-02-15' SELECT * FROM Tickets WHERE CreatedAt>'2017-02-15 10:15:00 AM' AND Status='open'
Other filters are processed client side within the driver. You can turn off the client-side execution of the query by setting SupportEnhancedSQL to false in which case any other search criteria will be ignored and an unfiltered response will be returned.
The Description or Comment fields are required to insert. Any other Custom Field of the ticket may be required to insert. Allowed for Agents.
INSERT INTO Tickets(Subject, Description) VALUES('My printer is on fire!', 'The smoke is very colorful.')
To insert multiple tickets, see Batch Processing for an example.
You must specify the Id of the ticket to update it. All fields that are not read-only (readonly="false" in the table) are optional. Allowed for Agents.
UPDATE Tickets SET Subject='updated', Status='Open' WHERE Id='123'
You can create a new ticket comment by updating the ticket:
UPDATE Tickets SET Comment='this is a new comment' WHERE Id='123'
To make the same change to multiple tickets, use the following SQL statement:
UPDATE Tickets SET Status='Open' WHERE Id IN ('123','456')
To make different changes to multiple tickets, see Batch Processing for an example.
You must specify the Id of the ticket to delete it. Allowed for Admins.
DELETE FROM Tickets WHERE Id='123'
You can delete many tickets simultaneously by providing their ids:
DELETE FROM Tickets WHERE Id IN ('123','456')
You can also delete many tickets simultaneously by using Batch Processing.
To get the Ids of deleted tickets run this query:
GETDELETED FROM Tickets
To delete a ticket permanently use the DeleteTicketsPermanently stored procedure.
Automatically assigned when the ticket is created.
The value of the subject field for this ticket. When used in WHERE clause: The text in the ticket's subject
The dynamic content placeholder, if present, or the subject value, if not.
The first comment on the ticket. When used in WHERE clause: The text in the ticket's description and comments
The type of this ticket. Possible values: problem, incident, question or task.
The urgency with which the ticket should be addressed. Possible values: urgent, high, normal, low.
The state of the ticket. Possible values: new, open, pending, hold, solved, closed.
The original recipient e-mail address of the ticket.
Is true of this ticket has been marked as a problem, false otherwise.
If this is a ticket of type task it has a due date. Due date format uses ISO 8601 format.
The user who requested this ticket.
The user who submitted the ticket. The submitter always becomes the author of the first comment on the ticket.
The agent currently assigned to the ticket.
The organization of the requester. You can only specify the ID of an organization associated with the requester.
The group this ticket is assigned to. When used in WHERE clause: The assigned agent's group name.
The ids of users currently cc-ed on the ticket.
Agents currently following the ticket.
The topic this ticket originated from, if any.
For tickets of type incident, the ID of the problem the incident is linked to.
An id you can use to link Zendesk Support tickets to local records.
Closed tickets only. The ids of the followups created from this ticket.
POST requests only. The id of a closed ticket when creating a follow-up ticket..
POST requests only. List of macro IDs to be recorded in the ticket audit.
Enterprise only. The id of the ticket form to render for the ticket.
Enterprise only. The id of the brand this ticket is associated with.
The array of tags applied to this ticket.
This tells you how the ticket or event was created. Examples: web, mobile, rule, system.
The ticket's source.
Custom fields for the ticket.The values of custom field are set and get dynamically
The satisfaction rating of the ticket, if it exists, or the state of satisfaction, 'offered' or 'unoffered'.
The ids of the sharing agreements used for this ticket.
Is false if channelback is disabled, true otherwise. Only applicable for channels framework ticket.
Is true if any comments are public, false otherwise.
When this record was created.
When this record last got updated.
The API url of this ticket.
Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.
Used to create a comment on the ticket, when creating or updating a ticket..
The view that tickets belong to.
The user that tickets belong to.
The assigned agent or other entity. You can specify 'none', 'me', user name (full name or partial), email address, user ID, or phone number
The assigned agent's group name.
The ticket requester. You can specify 'none', 'me', user name (full name or partial), email address, user ID, or phone number.
The ticket submitter. This may be different than the requester if the ticket was submitted by an agent on behalf of the requester. You can specify 'none', 'me', user name (full name or partial), email address, user ID, or phone number. .
Search for a specific Brand on a ticket.
The ticket's source, which can be any of the following:mail, api, phone, etc.
The date the ticket was set to solved.
People who have added comments to tickets. You can specify 'none', 'me', user name (full name or partial), email address, user ID, or phone number.
People who have been CC'd on tickets. You can specify 'none', 'me', user name (full name or partial), email address, user ID, or phone number.
Search for all tickets with or without attachments using 'true' or 'false'.
Used when creating a comment on the ticket. Set this to true to add a public comment and false to add an internal note.