This document provides a complete reference for the ShahiAssist REST API, webhooks, integration patterns, sample code, and recommended developer workflows.
—
Table of Contents
- Authentication & Security
- API Endpoints (Tickets, KB, Stats)
- Pagination, Filtering & Sorting
- Request/Response Examples (curl, JS, PHP)
- Webhooks: Events & Payloads
- Rate Limiting & Best Practices
- Extending Endpoints (custom routes)
- Integration Examples (Zapier, Integromat, custom)
- Changelog & Versioning
- WordPress Application Passwords (recommended for scripts)
- Cookie Authentication (browser sessions)
- OAuth / JWT
- All endpoints check capabilities where appropriate
- Sensitive routes require
manageoptionsoreditpostsdepending on context - Use HTTPS to protect credentials and webhooks
- Pagination parameters:
?page=1&per_page=20 - Filters support:
status,category,priority,assignedto,customeremail,product - Sorting:
?orderby=created_at&order=desc ticket.createdticket.status_changedticket.replyarticle.published- Webhooks are delivered via POST with JSON body
- On non-2xx responses, the plugin retries 3 times with exponential backoff
- Debug logs record request/response (if enabled)
- Plugin does not impose strict rate limits, but your host or WP could. Use sensible polling intervals (e.g., >30s) for integrations.
- Use webhooks where possible instead of polling
- Cache heavy queries server-side and use
per_pagelimits to avoid large payloads - Use webhooks to push events into Zapier
- Example: Create a Zap that triggers on
ticket.createdwebhook and sends Slack channel message - API version string is
shahi-assist/v1. For breaking changes, we will increment the namespace (e.g.,v2) and document migration steps in the changelog.
—
1. Authentication & Security
Supported authentication mechanisms:
– Create under Users → Profile → Application Passwords
– Use basic auth header Authorization: Basic base64(user:app_pass)
– Use when calling from logged-in frontends or admin pages
– Not built-in; you can install JWT/OAuth plugins and use them with REST endpoints
Security notes:
2. API Endpoints
Base namespace: /wp-json/shahi-assist/v1
Tickets
`
GET /tickets – list tickets (supports filters)
GET /tickets/{id} – single ticket
POST /tickets – create ticket
PUT /tickets/{id} – update ticket
DELETE /tickets/{id} – delete ticket
GET /tickets/{id}/replies – list replies
POST /tickets/{id}/replies – add reply
`
KB Articles
`
GET /kb-articles – list KB articles
GET /kb-articles/{id} – single article
POST /kb-articles – create article
PUT /kb-articles/{id} – update article
`
Stats
`
GET /stats – site-wide stats (counts / trending)
`
3. Pagination, Filtering & Sorting
Example: /wp-json/shahi-assist/v1/tickets?status=saopen&assignedto=45&page=1&per_page=25
4. Request/Response Examples
Create ticket (curl):
`bash
curl -X POST “https://example.com/wp-json/shahi-assist/v1/tickets” \
-u “admin:apppasswordhere” \
-H “Content-Type: application/json” \
-d ‘{“subject”:”Installation issue”,”description”:”I see error X”,”email”:”user@example.com”,”category”:2}’
`
Create ticket (JavaScript, fetch):
`javascript
fetch(‘/wp-json/shahi-assist/v1/tickets’, {
method: ‘POST’,
headers: { ‘Content-Type’: ‘application/json’ },
body: JSON.stringify({ subject: ‘Hello’, description: ‘Help’ })
}).then(r => r.json()).then(console.log).catch(console.error);
`
Add reply (PHP, using wpremotepost):
`php
$response = wpremotepost(rest_url(‘shahi-assist/v1/tickets/123/replies’), [
‘body’ => json_encode([ ‘message’ => ‘Thanks, we are looking into this’ ]),
‘headers’ => [ ‘Authorization’ => ‘Basic ‘ . base64encode(“user:apppass”) , ‘Content-Type’ => ‘application/json’ ]
]);
`
5. Webhooks: Events & Payloads
Supported events:
Example payload (ticket.created):
`json
{
“event”: “ticket.created”,
“timestamp”: “2025-11-27T12:34:56+00:00”,
“data”: {
“ticket_id”: 123,
“ticket”: {
“id”: 123,
“ticket_id”: “SA-AB12CD34”,
“subject”: “User issue”,
“status”: “sa_open”,
“customer_email”: “user@example.com”
}
}
}
`
Delivery & retry policy:
6. Rate Limiting & Best Practices
7. Extending Endpoints (Custom Routes)
You can extend the API by registering custom routes in a site plugin or theme:
`php
addaction(‘restapi_init’, function() {
registerrestroute(‘shahi-assist/v1’, ‘/reports/summary’, [
‘methods’ => ‘GET’,
‘callback’ => ‘shahiassistreports_summary’,
‘permissioncallback’ => function() { return currentusercan(‘viewstatistics’); }
]);
});
function shahiassistreports_summary($request) {
return restensureresponse([ ‘tickets_total’ => 123, ‘open’ => 12]);
}
`
8. Integration Examples
Zapier / Make (Integromat):
Custom Integration (Node.js):
`javascript
const axios = require(‘axios’);
axios.post(‘https://example.com/wp-json/shahi-assist/v1/tickets’, { subject: ‘test’ }, { auth: { username: ‘user’, password: ‘app_pass’ } });
`
9. Changelog & Versioning
—
If you want, I can generate a Postman collection and a small SDK (PHP or JS) for common operations. Which SDK should I generate first?
Share this article
Still need help?
Our support team is ready to assist you with personalized guidance for your workspace.