Search across tickets, users, organizations and groups with Zendesk search syntax (type:ticket status:open priority:urgent, requester:ada@example.com, created>2026-07-01).

Two endpoints, two limits:

  • search (GET /search) pages by offset: at most 100 results a page and 1,000 results per query (page 11 at 100 a page is a 422). Results can repeat between pages.
  • export (GET /search/export) pages by cursor with no total cap, one object type at a time, ordered by created_at. Its cursor expires after an hour and it is rate-limited to 100 requests a minute. search-all uses it.

Context Vars

Optional
  • zendesk.subdomain

Functions

build-export-query

fn (query: Str, object-type: Str, options: Map): Str

Build the GET /search/export query: query, filter[type] (ticket, user, organization or group), and cursor options page_size (default 100, max 1000) and after. Exposed for testing.

Example

::zendesk::search/build-export-query("status:open", "ticket", {page_size: 500})  // "?query=status%3Aopen&filter%5Btype%5D=ticket&page%5Bsize%5D=500"

build-search-query

fn (query: Str, options: Map): Str

Build the GET /search query: query plus options (sort_by: "updated_at"/"created_at"/"priority"/"status"/"ticket_type"; sort_order: "asc"/"desc"; page, per_page, include). Nulls are dropped. Exposed for testing.

Example

::zendesk::search/build-search-query("type:ticket status:open", {sort_by: "created_at"})  // "?query=type%3Aticket+status%3Aopen&sort_by=created_at"

count

fn (query: Str): Any
fn (query: Str, opts: Map): Any

GET /search/count - How many results a query matches: {count}.

Example

out ::zendesk::search/count("type:ticket status:open")
out.count

export

fn (query: Str, object-type: Str): Any
fn (query: Str, object-type: Str, options: Map): Any
fn (query: Str, object-type: Str, options: Map, opts: Map): Any

GET /search/export - One cursor page of a single object type: {results, meta: {has_more, after_cursor}, links}. Don't put type: in the query; pass object-type instead.

Example

page ::zendesk::search/export("status:open", "ticket", {page_size: 500})
following ::zendesk::search/export("status:open", "ticket", {page_size: 500, after: page.meta.after_cursor})
length(following.results)
fn (query: Str): Any
fn (query: Str, options: Map): Any
fn (query: Str, options: Map, opts: Map): Any

GET /search - One offset page of mixed results: {results, count, next_page, previous_page, facets}; each result has a result_type. Capped at 1,000 results per query; use search-all for more.

Example

out ::zendesk::search/search("type:ticket status:open priority:urgent", {sort_by: "created_at", sort_order: "desc", per_page: 50})
map(out.results, %.subject)

search-all

fn (query: Str, object-type: Str, limit: Int): Vec
fn (query: Str, object-type: Str, limit: Int, opts: Map): Vec

Collect up to limit results of one object type through the cursor-based export, past the 1,000-result cap. Returns a Vec.

Example

stale ::zendesk::search/search-all("status:pending updated<2026-06-01", "ticket", 5000)