A thread event will only be created in the thread ID provided. If you want an event to appear in
all threads for a customer please use a customer
event.
To create a thread event you need a thread ID.You can get this by creating a thread in Plain, from data in webhooks or other API calls you made. If you want to test this, press ⌘ + K on any thread and then “Copy thread ID” to get an ID you can experiment with.In this example we’ll be creating the following event:
For this you’ll need an API key with the following permissions:
threadEvent:create
threadEvent:read
thread:read
customer:read
Copy
Ask AI
import { PlainClient, uiComponent } from '@team-plain/typescript-sdk';const client = new PlainClient({ apiKey: 'plainApiKey_xxx' });const res = await client.createThreadEvent({ title: 'API key generated', threadId: 'th_01HB924RWAW8H3Q8KZDFWYBJHZ', components: [ uiComponent.text({ text: 'New API key was added with the fingerprint **3b7896975ee9fd15eeb7** with 4 associated roles.', }), uiComponent.spacer({ size: 'M', }), uiComponent.linkButton({ label: 'View in admin', url: 'https://admin.your-app.com', }), ], // Optional - if provided, this will ensure that this event can only // be created once and fail on the second time. This external id acts // as an idempotency key while also letting you correlate an event to // something your systems. externalId: 'ex-id-1',});if (res.error) { console.error(res.error);} else { console.log(res.data);}