Skip to main content

Tickets

The center of the platform. cstar.tickets covers the full CRUD plus a sub-resource for ticket messages. Standard list-shape with filters; bare-object returns on get/create/update.

List

list.js
const { data, pagination, hasMore } = await cstar.tickets.list({
  status: 'open',
  priority: 'high',
  customerId: 'cus_...',
  assignedTo: 'mem_...',
  search: 'login',
  expand: ['customer'],   // Inline summary; otherwise just customerId
  page: 1,
  pageSize: 20
});

Filter params are all optional. Combine them freely. expand: ['customer'] inlines a TicketCustomerSummary on each row instead of just customerId.

Get

get.js
const ticket = await cstar.tickets.get('tkt_abc123');
// Single-ticket GET always inlines messages
console.log(ticket.messages?.length);

Create

create.js
const ticket = await cstar.tickets.create({
  title: 'Cannot reset password',
  priority: 'high',           // 'low' | 'normal' | 'high' | 'urgent' (default 'normal')
  customerId: 'cus_...',      // OR customerName: 'Jane Doe'
  tags: ['auth', 'login'],
  notes: 'Internal note — visible to agents only.',
  metadata: { source: 'web-form' }
}, {
  idempotencyKey: `form_${formId}`
});

Update

update.js
await cstar.tickets.update('tkt_abc123', {
  status: 'resolved',
  assignedTo: 'mem_...',
  tags: ['auth', 'login', 'resolved']
});

Delete

delete is the canonical name; del still works for legacy callers.

delete.js
await cstar.tickets.delete('tkt_abc123');
// → { deleted: true, id: 'tkt_abc123' }

Messages sub-resource

messages.js
// List
const { data: messages } = await cstar.tickets.messages.list('tkt_abc123');

// Add
const message = await cstar.tickets.messages.create('tkt_abc123', {
  content: "Hi! We've reset your password.",
  sender: 'agent'
}, {
  idempotencyKey: `reply_${replyId}`
});

Ticket type

Next up