zcli-ticket
A command-line interface for the Zendesk Ticketing API. Built for both humans and AI agents.
Installation
For Humans
Copy and paste this prompt to your LLM agent (Claude Code, Cursor, Codex, etc.):
Install and configure zcli-ticket by following the instructions here:
https://raw.githubusercontent.com/mack-peng/zcli-ticket/main/docs/guide/installation.md
For LLM Agents
Fetch the installation guide and follow it:
curl -s https://raw.githubusercontent.com/mack-peng/zcli-ticket/main/docs/guide/installation.md
Quick Start
Install
npm install -g zcli-ticket
1. Configure Authentication
Three auth modes. Most users use API tokens:
zcli-ticket config-set subdomain mycompany
zcli-ticket config-set email agent@company.com
zcli-ticket config-set token abc123xyz
zcli-ticket config-set password mypassword
zcli-ticket config-set oauth-client-id <client-id>
zcli-ticket config-set oauth-client-secret <client-secret>
zcli-ticket oauth-login
zcli-ticket config-set oauth-token eyJ...
zcli-ticket config-new staging
zcli-ticket -p staging config-set subdomain stagingco
zcli-ticket -p staging config-set email admin@staging.co
zcli-ticket -p staging config-set token xyz789
zcli-ticket config-use staging
zcli-ticket config-list
Config is stored at ~/.zendeskrc. Override per-command with -s, -e, --token:
zcli-ticket ticket-list --subdomain mycompany --email me@corp.com --token abc
2. Try It
zcli-ticket ticket-list --status open
zcli-ticket ticket-show 12345
zcli-ticket user-me
zcli-ticket ticket-thread 12345
Authentication
| API Token | token | {email}/token:{token} base64 (recommended) |
| Basic Auth | password | {email}:{password} base64 |
| OAuth | oauth-token, or oauth-client-id + oauth-client-secret | Bearer {token}; with client credentials the token is exchanged via client_credentials and refreshed automatically |
Config file (~/.zendeskrc) stores credentials per profile. Use config-show to verify without exposing secrets. If a profile has more than one credential type, pin the mode with config-set mode or --mode.
OAuth auto refresh
OAuth is one mode with two credential flavours. With oauth-client-id /
oauth-client-secret configured, zcli-ticket exchanges them for an access token
(POST /oauth/tokens, grant type client_credentials) and keeps it fresh:
- Before each request, a token missing or expiring within 60s is refreshed automatically.
- On HTTP 401 it refreshes once and retries the request once.
- Refreshed tokens are written back to
~/.zendeskrc (atomic write, file mode 0600) together with oauthTokenExpiresAt and the granted scope.
- Both
oauth-login and automatic refresh request the maximum TTL (expires_in: 172800, 2 days — Zendesk's ceiling); if the server issues a smaller lifetime it is persisted as-is.
- Without client credentials, a static
oauth-token behaves exactly as before.
- If a profile carries several credential types, pin the mode explicitly with
config-set mode api-token|basic|oauth (or --mode); otherwise OAuth wins whenever OAuth credentials exist.
zcli-ticket oauth-login performs the exchange explicitly (--scope, --expires-in 300-172800, default 172800). --verbose logs each refresh to stderr.
- The OAuth client must be confidential (Zendesk Admin Center → APIs → OAuth clients → Client kind); public clients get
unauthorized_client. client_credentials tokens never come with a refresh_token; expiry is handled by re-exchanging the client credentials.
Configuration
zcli-ticket config-set subdomain mycompany
zcli-ticket config-set email agent@company.com
zcli-ticket config-set token abc123xyz
zcli-ticket config-set mode api-token
zcli-ticket config-set oauth-client-id <client-id>
zcli-ticket config-set oauth-client-secret <client-secret>
zcli-ticket config-set oauth-scope "tickets:read users:read"
zcli-ticket oauth-login
zcli-ticket config-show
zcli-ticket config-path
zcli-ticket config-new myprofile
zcli-ticket -p myprofile config-set subdomain co
zcli-ticket config-use myprofile
zcli-ticket config-list
Priority: CLI flags > Config file (~/.zendeskrc)
-s, --subdomain Zendesk subdomain
-e, --email Zendesk agent email
--token API token
--password password for basic auth
--oauth-token static OAuth access token
--oauth-client-id OAuth client id (enables auto refresh)
--oauth-client-secret OAuth client secret (enables auto refresh)
--oauth-scope space-separated OAuth scopes
-p, --profile named profile (or ZENDESK_PROFILE env, for selecting a profile temporarily)
--mode force auth mode: api-token | basic | oauth
Credentials must be configured first (config-set or per-command flags); there are no credential environment variables.
Known config keys are normalized on write (config-set oauth-token ... is stored as oauthToken, and legacy kebab-case keys from older versions are migrated on the next write).
Subdomain auto-resolves: mycorp → mycorp.zendesk.com, full domains like mycorp.zendesk.de or support.mycorp.com work directly.
Agent Skill
Teach AI coding agents how to use zcli-ticket effectively:
zcli-ticket skill-install
zcli-ticket skill-install --target opencode
zcli-ticket skill-install --target claude
zcli-ticket skill-install --target all
zcli-ticket skill-install --path /path/to/project
zcli-ticket skill-uninstall
The skill installs a SKILL.md + references/pitfalls.md into each agent's
skill directory (~/.agents/skills/, ~/.claude/skills/, etc.). Agents use it
to discover commands, configure auth, and avoid common pitfalls.
Output Modes
| (default) | Human-readable tables / formatted JSON | Terminal viewing |
--json | Machine-readable JSON | Scripts, jq pipes, AI agent consumption |
--raw | Raw data without formatting | Direct consumption by other tools |
zcli-ticket ticket-list --status open
zcli-ticket --json ticket-list --status open
zcli-ticket --json ticket-list | jq '.[].id'
zcli-ticket --raw ticket-show 12345
Commands
Tickets
zcli-ticket ticket-list
zcli-ticket ticket-list --status open
zcli-ticket ticket-list --sort-by updated_at --sort-order desc
zcli-ticket ticket-list-recent
zcli-ticket ticket-show 12345
zcli-ticket ticket-show-many 1,2,3
zcli-ticket ticket-thread 12345
zcli-ticket ticket-create "Subject" "Description"
zcli-ticket ticket-create "Subject" "Body" --priority urgent --tags urgent,printer
zcli-ticket ticket-create-many tickets.json
zcli-ticket ticket-update 12345 --status solved
zcli-ticket ticket-update 12345 --assignee-id 789
zcli-ticket ticket-update 12345 --comment "Fixed"
zcli-ticket ticket-update 12345 --private-comment "Note"
zcli-ticket ticket-update-many 1,2,3 --status closed
zcli-ticket ticket-delete 12345
zcli-ticket ticket-delete-many 1,2,3
zcli-ticket ticket-merge 12345 --target-id 67890
zcli-ticket ticket-related 12345
zcli-ticket comment-list 26520363
zcli-ticket comment-create 26520363 "Have you tried restarting?"
zcli-ticket comment-create 26520363 "Internal note" --private
zcli-ticket comment-update --ticket-id 12345 --comment-id 456 "Updated text"
zcli-ticket comment-redact --ticket-id 12345 --comment-id 456 "[REDACTED]"
zcli-ticket comment-delete --ticket-id 12345 --comment-id 456
Users
zcli-ticket user-list
zcli-ticket user-list --role agent
zcli-ticket user-me
zcli-ticket user-show 67890
zcli-ticket user-show me
zcli-ticket user-show-many 1,2,3
zcli-ticket user-create "John Doe" "john@example.com"
zcli-ticket user-create "Agent" "agent@corp.com" --role agent --verified
zcli-ticket user-create-many users.json
zcli-ticket user-update 67890 --name "Jane"
zcli-ticket user-update 67890 --role admin
zcli-ticket user-update-many 1,2,3 --role agent
zcli-ticket user-delete 67890
zcli-ticket user-delete-many 1,2,3
zcli-ticket user-merge --source-id 100 --target-id 200
zcli-ticket user-search --query "jane"
zcli-ticket user-search --email "jane@corp.com"
zcli-ticket user-search --external-id "ext123"
zcli-ticket user-autocomplete "John"
zcli-ticket identity-list --user-id 67890
Organizations
zcli-ticket org-list
zcli-ticket org-show 123
zcli-ticket org-create "Acme Corp" --external-id "acme-001" --tags "enterprise,partner"
zcli-ticket org-update 123 --name "Acme Inc"
zcli-ticket org-delete 123
zcli-ticket org-search --external-id "acme-001"
zcli-ticket org-membership-list --org-id 123
zcli-ticket org-membership-create --user-id 456 --org-id 123
zcli-ticket org-membership-delete 789
Groups
zcli-ticket group-list
zcli-ticket group-show 42
zcli-ticket group-create "Support Team"
zcli-ticket group-update 42 --name "Support Tier 2"
zcli-ticket group-delete 42
zcli-ticket group-membership-list --group-id 42
zcli-ticket group-membership-create --user-id 100 --group-id 42
zcli-ticket group-membership-delete 200
Search
zcli-ticket search "status:open"
zcli-ticket search "type:user jane"
zcli-ticket search "type:organization acme"
zcli-ticket search "status:open priority:urgent" --sort-by created_at --sort-order desc
Views
zcli-ticket view-list
zcli-ticket view-show 123
zcli-ticket view-execute 123
zcli-ticket view-execute 123 --sort-by created_at
zcli-ticket view-count 123
zcli-ticket view-count-many 1,2,3
Attachments
zcli-ticket attachment-show 123456
zcli-ticket attachment-upload ./screenshot.png
zcli-ticket attachment-upload ./report.pdf --filename "Q4-Report.pdf"
zcli-ticket attachment-delete 123456
Ticket Fields & Forms
zcli-ticket ticket-field-list
zcli-ticket ticket-field-show 12345
zcli-ticket ticket-form-list
zcli-ticket ticket-form-show 123
Tags & Macros
zcli-ticket tag-list
zcli-ticket macro-list
zcli-ticket macro-show 123
zcli-ticket macro-apply --ticket-id 12345 --macro-id 67
Suspended Tickets
zcli-ticket suspended-list
zcli-ticket suspended-recover 12345
zcli-ticket suspended-delete 12345
Incremental Exports
zcli-ticket incremental-tickets 1710000000
zcli-ticket incremental-users 1710000000
zcli-ticket incremental-orgs 1710000000
Global Options
--json Output as JSON (default: human-readable)
--raw Output raw result without formatting
--verbose Log token refreshes to stderr
--help [command] Show help for a command or global
--version Show version
-p, --profile Use named config profile (or ZENDESK_PROFILE)
-s, --subdomain Zendesk subdomain (or full domain)
-e, --email Zendesk agent email
--token API token
--password Password for basic auth
--oauth-token Static OAuth access token
--oauth-client-id OAuth client id (enables auto refresh)
--oauth-client-secret OAuth client secret (enables auto refresh)
--oauth-scope Space-separated OAuth scopes
--mode Force auth mode: api-token | basic | oauth
Development
npm install
npm run build
npm test
npx tsc --noEmit
License
MIT