Tickets: create, read, update, comment, merge and tag; list with cursor pagination; ticket fields; satisfaction ratings; and the cursor-based incremental ticket export for syncing changes.
Context Vars
zendesk.subdomain
Functions
add-comment
fn (id: Any, body: Str, public: Bool): Any
fn (id: Any, body: Str, public: Bool, options: Map): Any
fn (id: Any, body: Str, public: Bool, options: Map, opts: Map): Any
PUT /tickets/{id} with a comment - Add a public reply (public: true)
or internal note (public: false). options: author_id, html_body,
uploads; plus ticket changes to apply in the same update via
update-ticket.
Example
::zendesk::tickets/add-comment(35436, "We rolled back the deploy.", true)
::zendesk::tickets/add-comment(35436, "Rollback finished at 14:05.", false, {author_id: 1900000001})
add-ticket-tags
fn (id: Any, tags: Vec): Any
fn (id: Any, tags: Vec, opts: Map): Any
PUT /tickets/{id}/tags - Add tags, keeping existing ones. Returns the ticket's tags.
Example
out ::zendesk::tickets/add-ticket-tags(35436, ["vip", "escalated"])
out.tags
build-comment-body
fn (body: Str, public: Bool, options: Map): Map
Comment update body {ticket: {comment: {body, public, ...options}}}.
options: author_id, html_body (sent instead of the plain body when
set), uploads (attachment tokens). Exposed for testing.
Example
::zendesk::tickets/build-comment-body("Thanks", true, {}) // {ticket: {comment: {body: "Thanks", public: true}}}
::zendesk::tickets/build-comment-body("Thanks", false, {html_body: "<p>Thanks</p>"}) // {ticket: {comment: {html_body: "<p>Thanks</p>", public: false}}}
build-create-body
fn (subject: Str, body: Str, options: Map): Map
Build the create body {ticket: {subject, comment: {body}, ...options}}. Unset options are omitted. Exposed for testing.
Example
::zendesk::tickets/build-create-body("Login down", "500s on /login", {priority: "urgent"}) // {ticket: {priority: "urgent", subject: "Login down", comment: {body: "500s on /login"}}}
build-merge-body
fn (source-ids: Vec, options: Map): Map
Merge body: ids (source tickets) plus options (target_comment,
source_comment, target_comment_is_public,
source_comment_is_public). Unset options are omitted. Exposed for
testing.
Example
::zendesk::tickets/build-merge-body([123, 456], {target_comment: "Merged"}) // {target_comment: "Merged", ids: [123, 456]}
create-ticket
fn (subject: Str, body: Str): Any
fn (subject: Str, body: Str, options: Map): Any
fn (subject: Str, body: Str, options: Map, opts: Map): Any
POST /tickets - Open a ticket. options: priority
("low"/"normal"/"high"/"urgent"), type
("problem"/"incident"/"question"/"task"), status, tags (Vec),
requester ({name, email}) or requester_id, assignee_id,
group_id, organization_id, custom_fields ([{id, value}]),
external_id. Returns {ticket, audit}.
Example
out ::zendesk::tickets/create-ticket("Login page down", "Customers report 500s on /login.", {
priority: "urgent",
type: "incident",
requester: {name: "Ada Lovelace", email: "ada@example.com"},
tags: ["login", "outage"]
})
out.ticket.id
delete-ticket
fn (id: Any): Any
fn (id: Any, opts: Map): Any
DELETE /tickets/{id} - Move a ticket to Deleted tickets (recoverable for 30 days). Returns null.
Example
::zendesk::tickets/delete-ticket(35436)
export-tickets
fn (start-time: Int): Any
fn (start-time: Int, options: Map): Any
fn (start-time: Int, options: Map, opts: Map): Any
GET /incremental/tickets/cursor?start_time= - Start a cursor-based
incremental export of every ticket changed since start-time (Unix
seconds, at least a minute in the past). Returns {tickets, after_cursor, end_of_stream}; continue with export-tickets-next
until end_of_stream is true, then keep the last after_cursor for
the next sync. Admins only; rate-limited to 10 requests a minute.
options: include (e.g. "users,groups"), exclude_deleted.
Example
batch ::zendesk::tickets/export-tickets(sub(::hot::time/epoch-seconds(), 86400))
next ::zendesk::tickets/export-tickets-next(batch.after_cursor)
export-tickets-next
fn (cursor: Str): Any
fn (cursor: Str, options: Map): Any
fn (cursor: Str, options: Map, opts: Map): Any
GET /incremental/tickets/cursor?cursor= - The next batch of an
incremental ticket export, from the previous batch's after_cursor.
Example
batch ::zendesk::tickets/export-tickets(1780000000, {exclude_deleted: true})
following if(batch.end_of_stream, null, ::zendesk::tickets/export-tickets-next(batch.after_cursor))
get-ticket
fn (id: Any): Any
fn (id: Any, opts: Map): Any
GET /tickets/{id} - One ticket: {ticket}.
Example
out ::zendesk::tickets/get-ticket(35436)
out.ticket.status
list-all-comments
fn (id: Any, limit: Int): Vec
fn (id: Any, limit: Int, options: Map): Vec
fn (id: Any, limit: Int, options: Map, opts: Map): Vec
Collect a ticket's whole conversation (up to limit comments) across
cursor pages. Returns a Vec.
Example
comments ::zendesk::tickets/list-all-comments(35436, 200)
length(comments)
list-all-tickets
fn (limit: Int): Vec
fn (limit: Int, options: Map): Vec
fn (limit: Int, options: Map, opts: Map): Vec
Collect up to limit tickets across cursor pages. Returns a Vec. For
syncing every ticket that changed, prefer export-tickets.
Example
tickets ::zendesk::tickets/list-all-tickets(500, {sort: "-updated_at"})
length(tickets)
list-comments
fn (id: Any): Any
fn (id: Any, options: Map): Any
fn (id: Any, options: Map, opts: Map): Any
GET /tickets/{id}/comments - One cursor page of a ticket's comments,
oldest first: {comments, meta, links}. options: page_size (max
100), after, sort ("created_at" or "-created_at"), include
("users"), include_inline_images.
Example
page ::zendesk::tickets/list-comments(35436, {page_size: 50, sort: "-created_at"})
map(page.comments, %.body)
list-satisfaction-ratings
fn (): Any
fn (options: Map): Any
fn (options: Map, opts: Map): Any
GET /satisfaction_ratings - One cursor page of CSAT ratings (admins
only): {satisfaction_ratings, meta, links}. options: score
("good", "bad", "received", "bad_with_comment", ...),
start_time/end_time (Unix seconds), page_size, after.
Example
page ::zendesk::tickets/list-satisfaction-ratings({score: "bad_with_comment", page_size: 50})
map(page.satisfaction_ratings, %.comment)
list-tags
fn (): Any
fn (options: Map): Any
fn (options: Map, opts: Map): Any
GET /tags - The account's most used tags with counts: one cursor page
{tags, meta, links}. options: page_size, after.
Example
page ::zendesk::tickets/list-tags({page_size: 50})
map(page.tags, %.name)
list-ticket-fields
fn (): Any
fn (options: Map): Any
fn (options: Map, opts: Map): Any
GET /ticket_fields - System and custom ticket fields
({ticket_fields}), with the ids that custom_fields entries use
and, for dropdowns, custom_field_options. options: locale,
creator.
Example
out ::zendesk::tickets/list-ticket-fields({locale: "en-US"})
map(out.ticket_fields, %.title)
list-ticket-tags
fn (id: Any): Any
fn (id: Any, opts: Map): Any
GET /tickets/{id}/tags - A ticket's tags: {tags}.
Example
out ::zendesk::tickets/list-ticket-tags(35436)
out.tags
list-tickets
fn (): Any
fn (options: Map): Any
fn (options: Map, opts: Map): Any
GET /tickets - One cursor page of tickets: {tickets, meta: {has_more, after_cursor}, links}. options: page_size (max 100),
after (the previous page's cursor, via
::zendesk::api/next-after), sort (id, updated_at,
created_at, status, ...; prefix - for descending),
external_id. Use list-all-tickets to collect several pages.
Example
page ::zendesk::tickets/list-tickets({page_size: 50, sort: "-updated_at"})
next-page ::zendesk::tickets/list-tickets({page_size: 50, after: ::zendesk::api/next-after(page)})
map(page.tickets, %.subject)
merge-tickets
fn (target-id: Any, source-ids: Vec): Any
fn (target-id: Any, source-ids: Vec, options: Map): Any
fn (target-id: Any, source-ids: Vec, options: Map, opts: Map): Any
POST /tickets/{id}/merge - Merge source-ids into the target
ticket. The work runs as a background job: returns {job_status};
poll GET /job_statuses/{id} with ::zendesk::api/request.
Zendesk recommends a private comment on both sides.
Example
::zendesk::tickets/merge-tickets(111, [123, 456], {
target_comment: "Combining duplicates #123 and #456",
source_comment: "Closing in favor of #111"
})
remove-ticket-tags
fn (id: Any, tags: Vec): Any
fn (id: Any, tags: Vec, opts: Map): Any
DELETE /tickets/{id}/tags - Remove the given tags from a ticket.
Example
out ::zendesk::tickets/remove-ticket-tags(35436, ["escalated"])
out.tags
set-ticket-tags
fn (id: Any, tags: Vec): Any
fn (id: Any, tags: Vec, opts: Map): Any
POST /tickets/{id}/tags - Replace all of a ticket's tags.
Example
out ::zendesk::tickets/set-ticket-tags(35436, ["billing"])
out.tags
show-many-tickets
fn (ids: Vec): Any
fn (ids: Vec, opts: Map): Any
GET /tickets/show_many?ids= - Up to 100 tickets by id in one call:
{tickets}.
Example
out ::zendesk::tickets/show-many-tickets([35436, 35437])
map(out.tickets, %.id)
update-ticket
fn (id: Any, changes: Map): Any
fn (id: Any, changes: Map, opts: Map): Any
PUT /tickets/{id} - Update ticket fields (status, priority,
assignee_id, group_id, tags (replaces), custom_fields,
comment, ...). Unset fields are omitted. Add safe_update: true and
updated_stamp to fail with 409 on a concurrent change.
Example
out ::zendesk::tickets/update-ticket(35436, {status: "pending", priority: "high"})
out.ticket.status