zdk — Zendesk CLI for AI Agents and Support Operations (Rust)
A fast, single-binary CLI that gives AI agents, scripts and support engineers structured, rate-limit-aware access to the Zendesk Support API — OAuth-first, because Zendesk stops issuing API tokens on 27 October 2026 and switches the remaining ones off on 30 April 2027.
Every command emits plain JSON when piped, uses deterministic exit codes, keeps stdout clean, and never stores a credential in plaintext. Not a chatbot. A tool that agents wield.
Status: v0.1.0 is the first release: OAuth login, credential stores, the rate governor, cursor pagination, the api escape hatch and curated tickets / comments / users / orgs / search commands. Everything under Roadmap does not exist yet.
Why This Exists
Support teams and the agents that help them need to read, triage, update and export tickets from scripts, pipelines and LLM tool calls. The existing options either assume a browser, depend on the API tokens Zendesk is retiring, ignore the per-endpoint rate limits that make bulk work fail halfway, or return output no program can parse.
zdk is a headless, machine-readable interface to Zendesk that any agent can call as a subprocess: OAuth with PKCE by default, client credentials for CI, a rate governor that learns the account's real quota from response headers, cursor pagination that resumes, and an api escape hatch backed by an operation registry generated from Zendesk's own OpenAPI specs (887 operations: Support 645, Help Center 182, Talk 60).
Agent Integration Contract
stdout is data. When stdout is not a TTY (or with -o json), a command prints the plain JSON payload — an array for lists, an object for single resources — with no envelope, so jq works directly:
zdk tickets list --status open --limit 50 | jq '.[].id'
zdk tickets get 1234 | jq '.status'
zdk tickets list -o ndjson | while IFS= read -r t; do …; done # one object per line, streamed
zdk tickets list -o raw # untouched Zendesk response body
zdk tickets list --fields id,subject,status --jq '.[] | .id' # projection and an embedded jq filter
Formats: table (default on a terminal), json (default when piped), ndjson, csv, tsv, yaml, raw. Selection order: -o → ZENDESK_OUTPUT → [default].output in the config file → TTY detection.
stderr is everything else: progress, warnings, prompts, rate-limit notices, logs. In machine output modes an error is a single JSON line on stderr, and the process exits with a stable code. This is exactly what zdk tickets get 1234 -o json prints before logging in:
{"error":{"code":"AUTH_NOT_LOGGED_IN","message":"not authenticated for profile 'default'","help":"Run `zdk auth login` (browser), `zdk auth login --no-browser` (SSH), or `zdk auth login --client-credentials` (CI).","exit_code":3,"request_id":null}}
help and request_id are null when there is nothing to say; request_id is Zendesk's correlation id whenever the failure came from an HTTP response. In table mode (a TTY) the same error is a readable miette report. The code strings are stable (crates/zdk-core/src/error.rs):
code |
Exit |
When |
USAGE |
2 |
Bad flag or value; a destructive command without --yes on a non-TTY (nothing was sent) |
AUTH_NOT_LOGGED_IN, AUTH_EXPIRED, AUTH_REVOKED, AUTH_CLIENT_SECRET_REQUIRED, AUTH_INVALID_SCOPE, AUTH_TOKEN_ENDPOINT, AUTH_CODE_EXPIRED, AUTH_FLOW_ABORTED |
3 |
No usable credential; refresh failed; the OAuth client rejected a scope; the login flow failed |
SCOPE_MISSING |
4 |
The token's granted scopes are known and lack the one the command needs (checked locally, before any HTTP) |
FORBIDDEN |
4 |
Zendesk answered 403 (or grants are unknown, e.g. a static or API token) |
NOT_FOUND |
5 |
404, or an email that matches no user |
VALIDATION |
6 |
Zendesk rejected the request (400 / 409 / 422); field details are in message |
RATE_LIMITED |
7 |
A budget is exhausted and --rate-limit-strategy fail is set |
PARTIAL_FAILURE |
8 |
Reserved for bulk commands (none ship yet) |
SERVER_ERROR |
9 |
5xx after every retry |
CONFIG, CREDENTIAL_STORE |
10 |
Unparsable config, bad ZENDESK_* value, keyring / encrypted-file failure, refresh-token rotation that could not be saved |
NETWORK |
11 |
Transport or TLS failure |
PAGINATION_LIMIT |
12 |
An offset walk would cross Zendesk's 100-page / 10,000-record wall; help names the alternatives |
JOB_TIMEOUT |
13 |
Reserved for job orchestration (none ships yet) |
INTERRUPTED |
130 |
Ctrl-C (nothing is printed; a --checkpoint file, if given, holds the last completed page) |
IO, ERROR |
1 |
Anything else (including a failed zdk doctor run) |
DRY_RUN exists as a code but maps to exit 0: --dry-run prints the request instead of sending it.
Exit codes (the contract agents branch on), from zdk --help-json:
| Code |
Name |
Meaning |
| 0 |
OK |
success (also --dry-run) |
| 1 |
ERROR |
unexpected error |
| 2 |
USAGE |
usage / argument error |
| 3 |
AUTH |
authentication failed or missing |
| 4 |
FORBIDDEN |
forbidden or missing scope |
| 5 |
NOT_FOUND |
resource not found |
| 6 |
VALIDATION |
Zendesk rejected the request (400/409/422) |
| 7 |
RATE_LIMITED |
rate limit exhausted (or --rate-limit-strategy fail) |
| 8 |
PARTIAL_FAILURE |
bulk operation completed with failures |
| 9 |
SERVER_ERROR |
Zendesk 5xx after retries |
| 10 |
CONFIG |
configuration or credential-store error |
| 11 |
NETWORK |
network / TLS error |
| 12 |
PAGINATION_LIMIT |
offset pagination cap reached |
| 13 |
JOB_TIMEOUT |
job did not finish in time |
| 130 |
INTERRUPTED |
interrupted (ctrl-c) |
zdk --help-json prints the whole command tree — every command's path, summary, usage and flags, plus global_flags and exit_codes once at the root — as JSON for tool-definition generation. A closed stdout pipe (| head) is normal termination (exit 0).
Install
# Homebrew (macOS/Linux)
brew install osodevops/tap/zendesk-cli
# Scoop (Windows)
scoop bucket add osodevops https://github.com/osodevops/scoop-bucket
scoop install zdk
# Pre-built binaries — https://github.com/osodevops/zendesk-cli/releases
# Every archive is attested with GitHub build provenance and listed in checksums-sha256.txt:
gh attestation verify zdk-v0.1.0-aarch64-apple-darwin.tar.gz --owner osodevops
sha256sum -c --ignore-missing checksums-sha256.txt
# From source (Rust 1.88+)
cargo install --git https://github.com/osodevops/zendesk-cli zendesk-cli
Release archives (zdk-<tag>-<target>.tar.gz, .zip on Windows) contain bin/zdk, share/man/man1/*.1, share/completions/* and share/doc/zendesk-cli/. Targets: macOS (Apple Silicon, Intel), Linux (x86_64 and aarch64 static musl, x86_64 glibc), Windows (x64, ARM64).
Documentation
Quickstart
You need an OAuth client from Admin Center → Apps and integrations → APIs → OAuth clients (a Public client with redirect URL http://127.0.0.1/callback for interactive use; docs/oauth-migration.md walks through it).
# 1. Write a config file for your instance (prompts for anything missing; --non-interactive in scripts)
zdk config init --subdomain acme --client-id zdk_local
# 2. Sign in (opens a browser; PKCE, no client secret needed for a Public client)
zdk auth login
# 3. Confirm who you are
zdk auth whoami
# 4. Read something
zdk tickets list --limit 3 # table on a TTY
zdk tickets list --limit 3 | jq . # JSON when piped
config init writes a profile named default whose scopes are tickets:read, tickets:write, users:read, organizations:read; auth login requests the profile's scopes (falling back to the agent preset when a profile has none).
Authentication
OAuth is the default and the documented path. API-token auth exists only as a migration ramp and warns on every use.
# 1. Authorization code + PKCE (interactive default). A single-use loopback listener on
# http://127.0.0.1:<ephemeral port>/callback; `state` is verified; the code is exchanged at once.
zdk auth login --client-id zdk_local --scopes tickets:read,tickets:write,users:read
zdk auth login --preset agent # a named scope bundle (repeatable; combines with --scopes)
zdk auth login --port 9876 # fixed loopback port for clients registered with one
zdk auth login --no-browser # print the URL; paste the code or the full redirect URL back
# (redirect http://127.0.0.1:8484/callback unless --port / auth.callback_port)
zdk auth login --redirect-uri https://localhost # paste-from-address-bar flow with a registered redirect
zdk auth login --expires-in 3600 # requested access-token lifetime (300–172800 s)
# 2. Client credentials (CI / automation). Confidential clients only; no refresh token — zdk re-mints on expiry.
ZENDESK_CLIENT_SECRET=… zdk auth login --client-credentials --client-id zdk_ci --scopes tickets:read,users:read
zdk auth login --client-credentials --client-secret "$SECRET" --store-secret # keep the secret in the credential store
# 3. API token (legacy, deprecated).
zdk auth login --api-token --email me@acme.com --token "$ZENDESK_API_TOKEN" # defaults: ZENDESK_EMAIL, ZENDESK_API_TOKEN
--subdomain and --profile are global flags (zdk --profile ci auth login …). Authorization codes are valid for 120 seconds; a late exchange is AUTH_CODE_EXPIRED. Requesting a scope outside the client's Allowed scopes is AUTH_INVALID_SCOPE and the help text names the Admin Center screen to fix it. An empty scope list is refused (Zendesk would grant full read+write).
Every API-token call prints one line on stderr, once per process, with the live countdown (today it reads: warning: API token auth is deprecated. New tokens cannot be created after 27 Oct 2026 (46 days); all tokens stop working on 30 Apr 2027 (231 days). Run zdk auth login to switch to OAuth.). After 27 October 2026 the wording becomes Zendesk no longer issues new API tokens; all tokens stop working on 30 Apr 2027 (N days), and after 30 April 2027 all API tokens stopped working on 30 Apr 2027 (N days ago). --quiet or auth.suppress_deprecation = true silences it.
After login:
zdk auth status # grant, scopes, expiry countdown, store backend (exit 3 when not logged in)
zdk auth whoami # GET /api/v2/users/me
zdk auth test # one cheap call per product API the credential can reach
zdk auth refresh --force # refresh (authorization code) or re-mint (client credentials) now
zdk auth token --format bearer # raw | bearer | json — the only command that prints a secret
zdk auth logout --no-revoke # remove the local credential; without the flag the token is revoked server-side first
Scopes
zdk ships Zendesk's 52-scope catalogue and four presets:
| Preset |
Scopes |
agent |
read, tickets:read, tickets:write, users:read, organizations:read, hc:read |
admin |
agent plus triggers:write, automations:write, macros:write, webhooks:write |