Skip to main content

Customers

Customers are the people behind the tickets. cstar.customers is straight CRUD with filters by status, sentiment, and tag — plus arbitrary customFields for anything your app needs.

List

list.js
const { data, pagination } = await cstar.customers.list({
  status: 'active',
  sentiment: 'negative',
  tag: 'enterprise',
  search: 'jane@',
  page: 1,
  pageSize: 50
});

Get

get.js
const customer = await cstar.customers.get('cus_abc123');
console.log(customer.ticketCount); // Total tickets ever opened

Create

create.js
const customer = await cstar.customers.create({
  name: 'Jane Doe',
  email: 'jane@example.com',
  sentiment: 'positive',
  tags: ['enterprise', 'design-partner'],
  notes: 'Reached out via the Stripe integration.',
  customFields: {
    plan: 'enterprise',
    crmId: 'salesforce_001234'
  },
  metadata: { source: 'stripe' }
}, {
  idempotencyKey: `signup_${stripeCustomerId}`
});

Update

update.js
await cstar.customers.update('cus_abc123', {
  sentiment: 'neutral',
  tags: ['enterprise', 'churn-risk']
});

// Clear a metadata key by setting it to null
await cstar.customers.update('cus_abc123', {
  metadata: { trial_ends_at: null }
});

Delete

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

Customer type

Next up