# Zendesk Read

> Query the Zendesk REST API for read-only data — tickets, search results, users, organizations, views, macros, or any other GET endpoint. Use when the user asks

- Skill: `rashedripon/zendesk-read` (Agent Skill)
- Install (CLI): `npx get-skill add rashedripon/zendesk-read`
- Raw SKILL.md: https://api.skillmd.com/api/skills/rashedripon/zendesk-read/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: rashedripon (https://skillmd.com/u/rashedripon)
- Updated: 2026-11-29
- Page: https://skillmd.com/skills/rashedripon/zendesk-read

---

---
name: zendesk-read
description: Query the Zendesk REST API for read-only data — tickets, search results, users, organizations, views, macros, or any other GET endpoint. Use when the user asks to look up a ticket, search Zendesk, list tickets, view ticket comments/audits, find users, or run any other Zendesk read operation.
---

# Zendesk Read-Only API Skill

This skill lets Claude query a Zendesk instance via its REST API. **Read operations only** — never call POST, PUT, PATCH, or DELETE endpoints, even if asked.

## Configuration

- **Auth scheme:** HTTP Basic, username is `<email>/token`, password is `<api-token>`
- **Credential storage:** macOS Keychain (handled by this skill, not the user). Three items:
  - `claude-zendesk-subdomain` — the Zendesk subdomain (e.g. `acme` for `acme.zendesk.com`)
  - `claude-zendesk-email` — user's Zendesk login email
  - `claude-zendesk-api-token` — API token generated in Zendesk Admin Center
- **Base URL** is built at call-time from the stored subdomain: `https://<subdomain>.zendesk.com/api/v2`

### What's sensitive vs. what's shareable

- **Sensitive:** API token. Never print, log, write to files, or include in error messages.
- **Shareable:** Subdomain and email. If the user asks "what subdomain/email am I using" or "which account is this," read from Keychain and show the value plainly.

## First-time setup (run automatically)

Before any API call, check whether all three Keychain items exist:

```bash
security find-generic-password -s "claude-zendesk-subdomain" -w 2>/dev/null
security find-generic-password -s "claude-zendesk-email" -w 2>/dev/null
security find-generic-password -s "claude-zendesk-api-token" -w 2>/dev/null
```

**If any of them exits non-zero (missing)**, run the setup flow for only the missing piece(s):

1. **Subdomain** — Ask: "What's your Zendesk subdomain? (the part before `.zendesk.com`, e.g. `acme` for `acme.zendesk.com`)"
2. **Email** — Ask for the Zendesk login email (default to system email if known).
3. **API token** — Point the user to `https://<subdomain>.zendesk.com/admin/apps-integrations/apis/zendesk-api/settings/tokens` → "Add API token" → copy. Ask them to paste it. **Do not echo it back in chat.**

Save each piece to Keychain (use `-U` to overwrite if already present):

```bash
security add-generic-password -a "$USER" -s "claude-zendesk-subdomain"   -w "<subdomain>" -U
security add-generic-password -a "$USER" -s "claude-zendesk-email"       -w "<email>"     -U
security add-generic-password -a "$USER" -s "claude-zendesk-api-token"   -w "<token>"     -U
```

Verify by re-reading each item, then proceed with the user's original request.

## How to call the API

Every API call should fetch fresh credentials from Keychain at call-time:

```bash
ZENDESK_SUBDOMAIN=$(security find-generic-password -s "claude-zendesk-subdomain" -w)
ZENDESK_EMAIL=$(security find-generic-password -s "claude-zendesk-email" -w)
ZENDESK_API_TOKEN=$(security find-generic-password -s "claude-zendesk-api-token" -w)
BASE="https://${ZENDESK_SUBDOMAIN}.zendesk.com/api/v2"

curl -s --max-time 30 -u "${ZENDESK_EMAIL}/token:${ZENDESK_API_TOKEN}" \
  "${BASE}/<ENDPOINT>" \
  | jq .
```

Always pipe through `jq` for readable output. For large responses, filter with `jq` to extract just the fields the user asked about (e.g. `.tickets[] | {id, subject, status, assignee_id}`).

If `jq` is not installed, fall back to `python3 -m json.tool`.

**First time the `security` command runs in a session**, macOS may show a Keychain access prompt asking permission for the terminal to read these items. The user should click "Always Allow" to skip it on future calls.

## Updating or removing credentials

- **Rotate any item** (subdomain, email, or token): re-run `security add-generic-password ... -U` with the new value.
- **Switch Zendesk accounts:** prompt for new subdomain + email + token and overwrite all three with `-U`.
- **Delete all:**
  ```bash
  security delete-generic-password -s "claude-zendesk-subdomain"
  security delete-generic-password -s "claude-zendesk-email"
  security delete-generic-password -s "claude-zendesk-api-token"
  ```
  Trigger this if the user says "forget my Zendesk credentials," "log me out," or similar.

## Safety rules

- **Only GET requests.** Refuse any request that would write, modify, or delete data. If the user asks "update ticket X" or "close this ticket," explain this skill is read-only and stop.
- **Token is the only secret.** Reference `$ZENDESK_API_TOKEN` by variable name in commands; never `echo` it, write it to a file, or include it in any output or error message. If a curl command fails, sanitize the command and output before sharing with the user. Subdomain and email are **not** secrets — read them from Keychain and show them plainly if the user asks "what subdomain/email am I using."
- **Confirm before bulk pulls.** If a request could return more than ~500 records (e.g. `/tickets` with no filter, full audit history of a long-lived ticket), restate the scope in plain English and ask the user to confirm or narrow it first.
- **Return raw data, don't auto-summarize.** Show ticket bodies, comments, user emails, phone numbers, and custom-field values verbatim. Don't redact or summarize on the user's behalf unless they explicitly ask for a summary.
- **Timeouts.** Add `--max-time 30` to every curl call so a hung connection can't stall the session.
- **One call at a time by default.** Don't fan out parallel requests unless the user has approved a bulk export — easy to trip rate limits.
- **Verify intent for "all" queries.** "Show me all tickets" almost never literally means *all*; clarify a time window, status, or assignee before paginating.

## Allowed endpoints

Any documented Zendesk GET endpoint is fair game. The official reference is https://developer.zendesk.com/api-reference/ticketing/introduction/. The categories below are prioritized — start here when matching a user request to an endpoint.

### Tickets (priority)

| Purpose | Endpoint |
|---|---|
| List all tickets | `GET /tickets` |
| Show a single ticket | `GET /tickets/{id}` |
| Show multiple tickets by ID | `GET /tickets/show_many?ids=1,2,3` |
| Ticket comments | `GET /tickets/{id}/comments` |
| Ticket audits (full change history) | `GET /tickets/{id}/audits` |
| Related incidents | `GET /tickets/{id}/incidents` |
| Recently updated tickets | `GET /tickets/recent` |
| Tickets requested by a user | `GET /users/{user_id}/tickets/requested` |
| Tickets CC'd to a user | `GET /users/{user_id}/tickets/ccd` |
| Tickets assigned to a user | `GET /users/{user_id}/tickets/assigned` |
| Tickets in an organization | `GET /organizations/{org_id}/tickets` |
| Ticket metrics | `GET /ticket_metrics` or `GET /tickets/{id}/metrics` |
| Ticket fields | `GET /ticket_fields` |
| Ticket forms | `GET /ticket_forms` |

### Search (priority)

| Purpose | Endpoint |
|---|---|
| General search | `GET /search?query=<URL-encoded query>` |
| Result count only | `GET /search/count?query=<query>` |
| Export (for large result sets) | `GET /search/export?query=<query>&filter[type]=ticket` |

Search query syntax examples (URL-encode before sending):
- `type:ticket status:open assignee:me`
- `type:ticket created>2026-01-01 priority:high`
- `type:user email:alice@example.com`
- `type:organization name:"Acme Corp"`

Full query reference: https://support.zendesk.com/hc/en-us/articles/4408886879258

### Users

| Purpose | Endpoint |
|---|---|
| List users | `GET /users` |
| Show user | `GET /users/{id}` |
| Current user (whoami) | `GET /users/me` |
| Find user by email | `GET /users/search?query=<email>` |
| User's groups | `GET /users/{id}/groups` |
| User's organizations | `GET /users/{id}/organizations` |

### Organizations

| Purpose | Endpoint |
|---|---|
| List organizations | `GET /organizations` |
| Show organization | `GET /organizations/{id}` |
| Organization users | `GET /organizations/{id}/users` |
| Search organizations | `GET /organizations/search?name=<name>` |

### Views, macros, groups, etc.

| Purpose | Endpoint |
|---|---|
| List views | `GET /views` |
| Tickets in a view | `GET /views/{id}/tickets` |
| View execution (counts) | `GET /views/{id}/execute` |
| List macros | `GET /macros` |
| List groups | `GET /groups` |
| List brands | `GET /brands` |
| List custom fields | `GET /ticket_fields` |
| List satisfaction ratings | `GET /satisfaction_ratings` |

### Any other endpoint

If the user names an endpoint not in the tables above, look it up in the official references and call it directly. As long as it's a GET, it's allowed.

**Reference docs (use these to find or correct endpoints):**
- Official API reference: https://developer.zendesk.com/api-reference/
- Postman workspace (live examples): https://www.postman.com/zendesk-redback/workspace/zendesk-public-api

### Endpoint discovery and corrections

If a call returns 404, the described endpoint doesn't exist, or results look wrong:

1. **Don't silently fail.** Tell the user the call didn't work and what HTTP status came back.
2. **Re-check the URL.** Common issues: missing `/api/v2/` prefix, plural vs singular (`/ticket` vs `/tickets`), wrong noun (`/incidents` vs `/problems`).
3. **Suggest the closest valid endpoint** from the official reference. Examples:
   - Asked for `/tickets/{id}/history` → suggest `/tickets/{id}/audits` (full change history) or `/tickets/{id}/comments` (just messages)
   - Asked for `/customers` → suggest `/users?role=end-user`
   - Asked for "ticket activity log" → `/tickets/{id}/audits`
   - Asked to "find all tickets about X" → `/search?query=type:ticket X` rather than listing + filtering client-side
4. **Common alternatives that often work better than the obvious choice:**
   - Large result sets → `/search/export` (cursor-paginated, no 1000-cap) instead of `/search`
   - Historical/backfill data → `/incremental/tickets` instead of paginating `/tickets`
   - User by email → `/users/search?query=email@example.com` (returns 0 or 1) instead of `/search?query=type:user email:...`
   - Tickets in a view → `/views/{id}/tickets` (already filtered) instead of fetching all tickets and filtering client-side
5. **If unsure which endpoint applies**, offer 2–3 candidates with what each returns and let the user pick.

## Cross-endpoint data discovery

A single ticket's information is split across multiple endpoints. When the user asks something about a ticket and the obvious endpoint doesn't have it, **try the related endpoints on your own before reporting "not found."** Don't ask the user to choose endpoints — figure it out.

### What lives where (ticket data map)

| Field / question | Try this endpoint |
|---|---|
| Subject, status, priority, requester, assignee, tags, custom fields, CCs (`collaborator_ids`, `email_cc_ids`, `follower_ids`) | `/tickets/{id}` |
| Public + internal note bodies, attachments | `/tickets/{id}/comments` |
| Full change history — every status / assignee / field / tag change with timestamp + actor | `/tickets/{id}/audits` |
| Why a ticket was reopened, who closed it, when status flipped | `/tickets/{id}/audits` (look for `status` change events) |
| SLA times, first-reply time, full-resolution time, reply count | `/tickets/{id}/metrics` |
| Linked / related tickets (problem ↔ incidents) | `/tickets/{id}/incidents`, `/tickets/{id}/related` |
| Satisfaction rating | `/satisfaction_ratings?ticket_id={id}` |
| Tag history | `/tickets/{id}/audits` (filter for `tags` events) |
| Email headers / raw email source | `/tickets/{id}/audits` (look inside `events[]` for the email channel) |
| Who viewed the ticket | Not exposed by the API — report unavailable |

### Workflow

1. Pick the most likely endpoint for the asked field.
2. Call it. If the field is there, return the raw value.
3. If not, **escalate through the related endpoints automatically** — typical fallback chain is `/tickets/{id}` → `/tickets/{id}/audits` → `/tickets/{id}/comments` → `/tickets/{id}/metrics`.
4. Only if nothing in the obvious candidates has the answer, come back to the user with: "I checked X, Y, Z and didn't find it — want me to look at <less likely candidate>?"
5. Always tell the user **which endpoint(s)** gave you the data, so they learn the mapping over time.

The same principle applies beyond tickets — user data is split across `/users/{id}`, `/users/{id}/identities`, `/users/{id}/groups`, `/users/{id}/organization_memberships`, etc. When in doubt, check the reference and try the next likely place.

## Pagination

Zendesk uses **three pagination styles**, depending on the endpoint:

### Cursor-based (preferred, used by most modern endpoints)

Default and max page size = 100.

```bash
# First page
curl ... "$BASE/tickets?page[size]=100"
# Next page — use the after_cursor from the response's meta object
curl ... "$BASE/tickets?page[size]=100&page[after]=<cursor>"
```

Response includes `meta.has_more` (boolean) and `meta.after_cursor` (string). Loop until `has_more` is false.

### Offset-based (legacy, still used by `/search` and a few others)

`?page=N&per_page=100`, **hard cap of 1000 total results** (10 pages × 100). If a search needs more, switch to `/search/export`.

```bash
curl ... "$BASE/search?query=...&page=1&per_page=100"
```

Response includes `next_page` (a full URL) and `previous_page`. Follow `next_page` until null.

### Incremental exports (for large / historical pulls)

For "all tickets ever" or backfills, **do not paginate `/tickets` end-to-end** — use the incremental export endpoint:

```bash
curl ... "$BASE/incremental/tickets/cursor.json?start_time=1672531200"
```

These support `page[size]` up to **1000** and are explicitly designed for bulk export. Docs: https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/

### General rules

- For one-off requests, fetch one page and summarize.
- Only paginate through all results when the user explicitly says "get all," "every," "export," etc.
- For multi-page requests, **check rate-limit headers between pages** (see next section) and back off if you cross the threshold.
- Use **side-loading** to reduce round-trips: `?include=users,organizations,groups` on supported endpoints returns related records in one response.

## Rate limit handling

Zendesk returns rate-limit headers on **every** response. Capture them so you can throttle proactively rather than waiting for a 429.

Quick way to get both body and headers:

```bash
curl -s --max-time 30 -i -u "$AUTH" "$BASE/tickets/88421" \
  -o /tmp/zd-body.json -D /tmp/zd-headers.txt
grep -i "^x-rate-limit" /tmp/zd-headers.txt
```

Key headers:

- `X-Rate-Limit` — total allowed requests per minute for this endpoint group
- `X-Rate-Limit-Remaining` — requests remaining in the current window
- `Retry-After` — seconds to wait before retrying (only present on 429 responses)

### The 70% rule

After each request, compute `used = (limit − remaining) / limit`.

- **used ≥ 0.70** → pause **15 seconds** before the next call and tell the user you're throttling.
- **used ≥ 0.90** → pause **30 seconds** and warn the user you're close to the cap; recommend narrowing the query.
- On **HTTP 429** → sleep for `Retry-After` seconds (Zendesk-provided), then retry the failed call **exactly once**. If it fails again, stop and report.

### Endpoint-specific notes

- The **`/search` endpoint** has a much lower limit than most (often ~100/min, sometimes lower per account). Be conservative with search-driven loops.
- **Incremental export** endpoints have separate, higher limits — prefer them for bulk work.
- Limits are **per endpoint group, not global** — hitting the cap on `/search` doesn't mean `/tickets` is throttled too.

## Large responses and local file storage

If a response is too large to keep in conversation context (rough thresholds: more than ~500 records, or expected output >50KB), do **not** dump it into chat. Save it to a local file and work against the file.

### When to save to file

- User asks for "all" or "every" of something.
- A search query returns more than one page of results.
- The user wants to cross-reference or analyze many records.
- The response contains long-form text fields (ticket bodies, comments) that would otherwise have to be truncated.

### Where to save

Default to the current working directory with a timestamped filename:

```bash
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
OUTFILE="zendesk-tickets-${TIMESTAMP}.json"
```

If the user has a preferred export folder (e.g. `~/zendesk-exports/`), use that and remember it for the rest of the session.

### Format choice

- **JSON** — default; preserves full fidelity. Best when you'll keep querying with `jq`.
- **CSV** — when the user wants Excel/Numbers or to share with a non-technical stakeholder. Pick a flat column set; for tickets use `id, subject, status, priority, requester_id, assignee_id, created_at, updated_at, tags`. Convert with `jq -r '... | @csv'`.

If unsure which format the user wants, ask before exporting.

### Workflow once saved

1. Tell the user the filename, record count, and total file size.
2. Use `jq` / `grep` / `wc -l` against the file to answer their specific questions — keep raw data out of the conversation.
3. If they want to see specific records, read them from the file and show only those.
4. Don't re-download data already on disk in the same session unless freshness matters.

### Example — large search export to JSON then summarize

```bash
QUERY=$(python3 -c "import urllib.parse; print(urllib.parse.quote('type:ticket status:open created>2026-01-01'))")
OUTFILE="zendesk-search-$(date +%Y%m%d-%H%M%S).json"
curl -s --max-time 30 -u "$AUTH" \
  "$BASE/search/export?query=${QUERY}&filter[type]=ticket&page[size]=100" -o "$OUTFILE"
jq '.results | length' "$OUTFILE"                          # count
jq '[.results[] | {id, subject, status, priority}] | .[0:10]' "$OUTFILE"   # preview first 10
```

## Output formatting

- For a single record, show the key fields in a readable list (not raw JSON dump).
- For lists, show a short table or bulleted summary with IDs, then offer to dig into any specific record.
- Keep raw JSON available — if the user asks "show me the full response," print it.
- Convert Zendesk timestamps (ISO 8601 UTC) to a friendlier format when summarizing.

## Error handling

- **401 Unauthorized** → token or email is wrong/expired. Suggest the user say "update my Zendesk credentials" so the skill re-prompts and overwrites the Keychain items.
- **403 Forbidden** → token is valid but lacks permission for that endpoint/resource. The user's Zendesk role may not grant access.
- **404 Not Found** → resource ID doesn't exist *or* the endpoint URL is wrong. Go to **Endpoint discovery and corrections** above and suggest alternatives before retrying.
- **422 Unprocessable Entity** → query syntax error (most common on `/search`). Re-check the search query string and URL-encoding.
- **429 Too Many Requests** → see **Rate limit handling**. Sleep `Retry-After` seconds, retry once.
- **5xx** → Zendesk-side issue. Retry once after 5 seconds, then stop and report.
- **Empty/null in response** → not always an error. Some endpoints return `200 OK` with empty arrays when no records match.
- **When reporting any error, sanitize the curl output** so the token never appears in the message back to the user.

## Example interactions

All examples assume credentials are already loaded from Keychain at the top of the script:

```bash
ZENDESK_SUBDOMAIN=$(security find-generic-password -s "claude-zendesk-subdomain" -w)
ZENDESK_EMAIL=$(security find-generic-password -s "claude-zendesk-email" -w)
ZENDESK_API_TOKEN=$(security find-generic-password -s "claude-zendesk-api-token" -w)
AUTH="${ZENDESK_EMAIL}/token:${ZENDESK_API_TOKEN}"
BASE="https://${ZENDESK_SUBDOMAIN}.zendesk.com/api/v2"
```

**"Show me ticket 88421"**
```bash
curl -s -u "$AUTH" "$BASE/tickets/88421" \
  | jq '.ticket | {id, subject, status, priority, requester_id, assignee_id, created_at, updated_at}'
```

**"Find open high-priority tickets assigned to me created this month"**
```bash
QUERY=$(python3 -c "import urllib.parse; print(urllib.parse.quote('type:ticket status:open priority:high assignee:me created>2026-05-01'))")
curl -s -u "$AUTH" "$BASE/search?query=${QUERY}" \
  | jq '.results[] | {id, subject, status, priority, created_at}'
```

**"Get all comments on ticket 88421"**
```bash
curl -s -u "$AUTH" "$BASE/tickets/88421/comments" \
  | jq '.comments[] | {id, author_id, public, created_at, body}'
```

**"Who is user 12345?"**
```bash
curl -s -u "$AUTH" "$BASE/users/12345" \
  | jq '.user | {id, name, email, role, organization_id, created_at}'
```

