May 24, 2023

Typescript SDK

Image showing Typescript SDK in Plain

For all of its versatility and power, GraphQL can be tricky to set up. Especially if you just want to open an issue in Plain or submit a contact form.

To make it easier to use our API, today we are releasing our first SDK for Typescript and its open source:

https://github.com/team-plain/typescript-sdk

It doesn't allow you to do everything our GraphQL API does but it does handle the majority of use cases (and makes those a breeze).

This first version lets you:

  • Create custom timeline entries to submit contact forms

  • Log events that happen in your systems through timeline entries

  • Create, update and get customers

  • Create issues

  • Add and remove customers from customer groups

For example—this is how you create a customer in Plain:

import { PlainClient } from '../client';

const client = new PlainClient({ apiKey: 'plainApiKey_123' });

const res = await client.upsertCustomer({
  identifier: {
    email: 'jerry@acme.com',
  },
  onCreate: {
    fullName: 'Jerry Field',
    email: {
      email: 'jerry@acme.com',
      isVerified: true,
    },
  },
  onUpdate: {},
});

if (res.error) {
  console.error(res.error);
} else {
  console.log(`Created customer with ${res.data.id}`);
}

To show off the SDK we've built a very fancy example contact form, which you can see here.If you’re looking for some inspiration, check out the code. It's all open source!We'll be extending the functionality of the SDK very soon and creating SDKs for other languages. If you don't work with Typescript—let us know and we can help!

Designed, built and written by

Matt Vagni

Co-founder & CTO

Matt Vagni

Co-founder & CTO

We’re building Plain to be the fastest, most powerful support tool out there. We’d love for you to try what we’ve built and tell us what you think.

© 2024 Not Just Tickets Limited

Plain and the Plain logo are trademarks and tradenames of Not Just Tickets Limited and may not be used or reproduced without consent.

© 2024 Not Just Tickets Limited

Plain and the Plain logo are trademarks and tradenames of Not Just Tickets Limited and may not be used or reproduced without consent.