Before you start
- A Dispatch Tickets account (get early access)
- Node.js 18+ installed
- Your API key (from the dashboard)
1
Install the SDK
Add the Dispatch Tickets SDK to your project:
npm install @dispatchtickets/sdkOr use yarn: yarn add @dispatchtickets/sdk
2
Initialize the client
Create a client instance with your API key:
lib/dispatch.ts
import { DispatchTickets } from '@dispatchtickets/sdk';
const dispatch = new DispatchTickets({
apiKey: process.env.DISPATCH_API_KEY!, // sk_live_...
});
export default dispatch;Keep your API key secret. Never expose it in client-side code. Use environment variables and make API calls from your backend.
3
Get your brand ID
Every ticket belongs to a brand (workspace). Find your brand ID in the dashboard, or list your brands via the API:
const { data: brands } = await dispatch.brands.list();
console.log(brands);
// [{ id: 'br_abc123', name: 'My Brand', ... }]Your brand ID looks like br_abc123
4
Create a ticket
Now create your first ticket:
Create ticket
const ticket = await dispatch.tickets.create('br_abc123', {
title: 'Need help with my order',
body: 'Order #12345 has not arrived yet.',
customerEmail: '[email protected]',
customerName: 'Jane Doe', // optional
});
console.log(ticket);
// {
// id: 'tkt_xyz789',
// ticketNumber: 'TKT-1001',
// title: 'Need help with my order',
// status: 'open',
// ...
// }That's it. The ticket is now visible in your dashboard and the customer will receive a confirmation email (if configured).
5
Reply to the ticket
Add a comment to respond:
Add comment
await dispatch.tickets.addComment('br_abc123', 'tkt_xyz789', {
body: 'Hi Jane, I found your order. It shipped yesterday and should arrive tomorrow.',
authorType: 'STAFF',
authorName: 'Support Team',
});What's next?
Stuck? Contact support or open an issue.