> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# API

> API reference for Plain: every `plain.api.*` operation with input and output types.

Every `plain.api.*` operation is listed below with parameter shapes and return types from the plugin Zod schemas.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Companies

### fetch

`companies.fetch`

Fetch a company by ID.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.companies.fetch({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `companyId` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `company` | `object \| null` | Yes | — |

> [accordion] company full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   domainName: string,
>   contractValue?: number | null
> } | null
> ```

***

### update

`companies.update`

Create or update a company by ID or domain.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.companies.update({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `identifier` | `object` | Yes | — |
| `name` | `string` | Yes | — |
| `domainName` | `string` | Yes | — |
| `contractValue` | `number` | No | — |
| `accountOwnerUserId` | `string` | No | — |

> [accordion] identifier full type
>
> ```ts theme={null}
> {
>   companyId?: string,
>   companyDomainName?: string
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `result` | `CREATED \| UPDATED \| NOOP \| null` | No | — |
| `company` | `object \| null` | Yes | — |

> [accordion] company full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   domainName: string,
>   contractValue?: number | null
> } | null
> ```

***

## Customer Groups

### addCustomer

`customerGroups.addCustomer`

Add a customer to one or more customer groups.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.customerGroups.addCustomer({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerId` | `string` | Yes | — |
| `customerGroupIdentifiers` | `object[]` | Yes | — |

> [accordion] customerGroupIdentifiers full type
>
> ```ts theme={null}
> {
>   customerGroupId?: string,
>   customerGroupKey?: string,
>   externalId?: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerGroupMemberships` | `object[]` | Yes | — |

> [accordion] customerGroupMemberships full type
>
> ```ts theme={null}
> {
>   customerId: string,
>   customerGroup: {
>     id: string,
>     name: string,
>     key: string,
>     color: string,
>     externalId?: string | null
>   }
> }[]
> ```

***

### create

`customerGroups.create`

Create a customer group.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.customerGroups.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | — |
| `key` | `string` | Yes | — |
| `color` | `string` | Yes | — |
| `externalId` | `string` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerGroup` | `object` | Yes | — |

> [accordion] customerGroup full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   key: string,
>   color: string,
>   externalId?: string | null
> }
> ```

***

### list

`customerGroups.list`

List customer groups with cursor pagination.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.customerGroups.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `filters` | `object` | No | — |
| `first` | `number` | No | — |
| `after` | `string` | No | — |
| `last` | `number` | No | — |
| `before` | `string` | No | — |

> [accordion] filters full type
>
> ```ts theme={null}
> {
>   externalIds?: string[]
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerGroups` | `object[]` | Yes | — |
| `pageInfo` | `object` | Yes | — |

> [accordion] customerGroups full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   key: string,
>   color: string,
>   externalId?: string | null
> }[]
> ```

> [accordion] pageInfo full type
>
> ```ts theme={null}
> {
>   hasNextPage: boolean,
>   hasPreviousPage: boolean,
>   startCursor: string | null,
>   endCursor: string | null
> }
> ```

***

### removeCustomer

`customerGroups.removeCustomer`

Remove a customer from one or more customer groups.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.customerGroups.removeCustomer({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerId` | `string` | Yes | — |
| `customerGroupIdentifiers` | `object[]` | Yes | — |

> [accordion] customerGroupIdentifiers full type
>
> ```ts theme={null}
> {
>   customerGroupId?: string,
>   customerGroupKey?: string,
>   externalId?: string
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `success` | `true` | Yes | — |

***

## Customers

### delete

`customers.delete`

Delete a customer asynchronously.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.customers.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerId` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `success` | `true` | Yes | — |

***

### getByEmail

`customers.getByEmail`

Fetch a customer by email address.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.customers.getByEmail({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `email` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `customer` | `object \| null` | Yes | — |

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   id: string,
>   externalId?: string | null,
>   fullName: string,
>   shortName?: string | null,
>   email: {
>     email: string,
>     isVerified: boolean
>   }
> } | null
> ```

***

### getById

`customers.getById`

Fetch a customer by Plain customer ID.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.customers.getById({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerId` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `customer` | `object \| null` | Yes | — |

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   id: string,
>   externalId?: string | null,
>   fullName: string,
>   shortName?: string | null,
>   email: {
>     email: string,
>     isVerified: boolean
>   }
> } | null
> ```

***

### list

`customers.list`

List customers with optional filters and cursor pagination (first/after or last/before).

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.customers.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `filters` | `object` | No | — |
| `sortBy` | `object` | No | — |
| `first` | `number` | No | — |
| `after` | `string` | No | — |
| `last` | `number` | No | — |
| `before` | `string` | No | — |

> [accordion] filters full type
>
> ```ts theme={null}
> {
>   isMarkedAsSpam?: boolean,
>   customerGroupIds?: string[],
>   customerGroupKeys?: string[],
>   companyIdentifiers?: {
>     companyId?: string,
>     companyDomainName?: string
>   }[],
>   tenantIdentifiers?: {
>     tenantId?: string,
>     externalId?: string
>   }[],
>   slackChannelId?: string
> }
> ```

> [accordion] sortBy full type
>
> ```ts theme={null}
> {
>   field: FULL_NAME,
>   direction: ASC | DESC
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `customers` | `object[]` | Yes | — |
| `pageInfo` | `object` | Yes | — |
| `totalCount` | `number` | Yes | — |

> [accordion] customers full type
>
> ```ts theme={null}
> {
>   id: string,
>   externalId?: string | null,
>   fullName: string,
>   shortName?: string | null,
>   email: {
>     email: string,
>     isVerified: boolean
>   }
> }[]
> ```

> [accordion] pageInfo full type
>
> ```ts theme={null}
> {
>   hasNextPage: boolean,
>   hasPreviousPage: boolean,
>   startCursor: string | null,
>   endCursor: string | null
> }
> ```

***

### upsert

`customers.upsert`

Create or update a customer by identifier.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.customers.upsert({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `identifier` | `object` | Yes | — |
| `onCreate` | `object` | Yes | — |
| `onUpdate` | `object` | Yes | — |

> [accordion] identifier full type
>
> ```ts theme={null}
> {
>   externalId?: string,
>   emailAddress?: string,
>   customerId?: string
> }
> ```

> [accordion] onCreate full type
>
> ```ts theme={null}
> {
>   externalId?: string,
>   fullName: string,
>   shortName?: string,
>   email: {
>     email: string,
>     isVerified: boolean
>   },
>   customerGroupIdentifiers?: {
>     customerGroupId?: string,
>     customerGroupKey?: string,
>     externalId?: string
>   }[],
>   tenantIdentifiers?: {
>     tenantId?: string,
>     externalId?: string
>   }[]
> }
> ```

> [accordion] onUpdate full type
>
> ```ts theme={null}
> {
>   externalId?: {
>     value?: string | null
>   },
>   fullName?: {
>     value: string
>   },
>   shortName?: {
>     value?: string | null
>   },
>   email?: {
>     email: string,
>     isVerified: boolean
>   }
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `result` | `CREATED \| UPDATED \| NOOP \| null` | No | — |
| `customer` | `object \| null` | Yes | — |

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   id: string,
>   externalId?: string | null,
>   fullName: string,
>   shortName?: string | null,
>   email: {
>     email: string,
>     isVerified: boolean
>   }
> } | null
> ```

***

## Graphql

### run

`graphql.run`

Run an arbitrary GraphQL query or mutation.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.graphql.run({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `query` | `string` | Yes | — |
| `variables` | `Record<string, JsonValue>` | No | — |
| `operationName` | `string` | No | — |

**Output:** `JsonValue`

***

## Threads

### create

`threads.create`

Create a thread for a customer.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.threads.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerIdentifier` | `object` | Yes | — |
| `title` | `string` | No | — |
| `description` | `string` | No | — |
| `priority` | `number` | No | — |
| `labelTypeIds` | `string[]` | No | — |
| `threadFields` | `object[]` | No | — |
| `assignedTo` | `object` | No | — |
| `externalId` | `string` | No | — |
| `tenantIdentifier` | `object` | No | — |
| `channel` | `API \| EMAIL \| SLACK \| MS_TEAMS \| CHAT \| INTERNAL \| DISCORD \| IMPORT` | No | — |

> [accordion] customerIdentifier full type
>
> ```ts theme={null}
> {
>   externalId?: string,
>   emailAddress?: string,
>   customerId?: string
> }
> ```

> [accordion] threadFields full type
>
> ```ts theme={null}
> {
>   key: string,
>   type: STRING | BOOL | ENUM | NUMBER | CURRENCY | DATE,
>   stringValue?: string,
>   booleanValue?: boolean,
>   numberValue?: number,
>   dateValue?: string
> }[]
> ```

> [accordion] assignedTo full type
>
> ```ts theme={null}
> {
>   userId?: string,
>   machineUserId?: string
> }
> ```

> [accordion] tenantIdentifier full type
>
> ```ts theme={null}
> {
>   tenantId?: string,
>   externalId?: string
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `thread` | `object \| null` | Yes | — |

> [accordion] thread full type
>
> ```ts theme={null}
> {
>   id: string,
>   ref: string,
>   title: string,
>   status: string,
>   priority: number
> } | null
> ```

***

### fetchIssues

`threads.fetchIssues`

Fetch external thread links for a customer and flatten as issue records.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.threads.fetchIssues({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerId` | `string` | Yes | — |
| `threadFirst` | `number` | No | — |
| `threadAfter` | `string` | No | — |
| `threadLast` | `number` | No | — |
| `threadBefore` | `string` | No | — |
| `linkFirst` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `issues` | `object[]` | Yes | — |
| `pageInfo` | `object` | Yes | — |
| `totalThreads` | `number` | Yes | — |

> [accordion] issues full type
>
> ```ts theme={null}
> {
>   threadId: string,
>   threadRef: string,
>   threadTitle: string,
>   link: {
>     id: string,
>     sourceId: string,
>     sourceType: string,
>     title: string,
>     description?: string | null,
>     url: string,
>     status: string,
>     linkType: string
>   }
> }[]
> ```

> [accordion] pageInfo full type
>
> ```ts theme={null}
> {
>   hasNextPage: boolean,
>   hasPreviousPage: boolean,
>   startCursor: string | null,
>   endCursor: string | null
> }
> ```

***

### getById

`threads.getById`

Fetch a thread by Plain thread ID.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.threads.getById({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `threadId` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `thread` | `object \| null` | Yes | — |

> [accordion] thread full type
>
> ```ts theme={null}
> {
>   id: string,
>   ref: string,
>   title: string,
>   status: string,
>   priority: number
> } | null
> ```

***

### listDeprecated

`threads.listDeprecated`

Deprecated threads listing operation; use threads.query.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.threads.listDeprecated({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `filters` | `object` | No | — |
| `sortBy` | `object` | No | — |
| `first` | `number` | No | — |
| `after` | `string` | No | — |
| `last` | `number` | No | — |
| `before` | `string` | No | — |

> [accordion] filters full type
>
> ```ts theme={null}
> {
>   threadIds?: string[],
>   refs?: string[],
>   labelTypeIds?: string[],
>   priorities?: number[],
>   customerIds?: string[],
>   isAssigned?: boolean,
>   assignedToUser?: string[],
>   isMarkedAsSpam?: boolean,
>   supportEmailAddresses?: string[],
>   customerGroupIdentifiers?: {
>     customerGroupId?: string,
>     customerGroupKey?: string,
>     externalId?: string
>   }[],
>   tierIdentifiers?: {
>     tierId?: string,
>     externalId?: string
>   }[],
>   companyIdentifiers?: {
>     companyId?: string,
>     companyDomainName?: string
>   }[],
>   tenantIdentifiers?: {
>     tenantId?: string,
>     externalId?: string
>   }[],
>   messageSource?: (CHAT | EMAIL | API | SLACK | MS_TEAMS | DISCORD | INTERNAL)[],
>   participantIds?: string[],
>   broadcastIds?: string[],
>   statuses?: (TODO | SNOOZED | DONE)[]
> }
> ```

> [accordion] sortBy full type
>
> ```ts theme={null}
> {
>   field: STATUS_CHANGED_AT | CREATED_AT | CLOSEST_TO_BREACH_SLA | LAST_INBOUND_MESSAGE_AT | PRIORITY | THREAD_FIELD,
>   direction: ASC | DESC,
>   threadFieldKey?: string
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `threads` | `object[]` | Yes | — |
| `pageInfo` | `object` | Yes | — |
| `totalCount` | `number` | Yes | — |

> [accordion] threads full type
>
> ```ts theme={null}
> {
>   id: string,
>   ref: string,
>   title: string,
>   status: string,
>   priority: number
> }[]
> ```

> [accordion] pageInfo full type
>
> ```ts theme={null}
> {
>   hasNextPage: boolean,
>   hasPreviousPage: boolean,
>   startCursor: string | null,
>   endCursor: string | null
> }
> ```

***

### query

`threads.query`

List threads with filters, sort, and cursor pagination.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.threads.query({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `filters` | `object` | No | — |
| `sortBy` | `object` | No | — |
| `first` | `number` | No | — |
| `after` | `string` | No | — |
| `last` | `number` | No | — |
| `before` | `string` | No | — |

> [accordion] filters full type
>
> ```ts theme={null}
> {
>   threadIds?: string[],
>   refs?: string[],
>   labelTypeIds?: string[],
>   priorities?: number[],
>   customerIds?: string[],
>   isAssigned?: boolean,
>   assignedToUser?: string[],
>   isMarkedAsSpam?: boolean,
>   supportEmailAddresses?: string[],
>   customerGroupIdentifiers?: {
>     customerGroupId?: string,
>     customerGroupKey?: string,
>     externalId?: string
>   }[],
>   tierIdentifiers?: {
>     tierId?: string,
>     externalId?: string
>   }[],
>   companyIdentifiers?: {
>     companyId?: string,
>     companyDomainName?: string
>   }[],
>   tenantIdentifiers?: {
>     tenantId?: string,
>     externalId?: string
>   }[],
>   messageSource?: (CHAT | EMAIL | API | SLACK | MS_TEAMS | DISCORD | INTERNAL)[],
>   participantIds?: string[],
>   broadcastIds?: string[],
>   statuses?: (TODO | SNOOZED | DONE)[]
> }
> ```

> [accordion] sortBy full type
>
> ```ts theme={null}
> {
>   field: STATUS_CHANGED_AT | CREATED_AT | CLOSEST_TO_BREACH_SLA | LAST_INBOUND_MESSAGE_AT | PRIORITY | THREAD_FIELD,
>   direction: ASC | DESC,
>   threadFieldKey?: string
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `threads` | `object[]` | Yes | — |
| `pageInfo` | `object` | Yes | — |
| `totalCount` | `number` | Yes | — |

> [accordion] threads full type
>
> ```ts theme={null}
> {
>   id: string,
>   ref: string,
>   title: string,
>   status: string,
>   priority: number
> }[]
> ```

> [accordion] pageInfo full type
>
> ```ts theme={null}
> {
>   hasNextPage: boolean,
>   hasPreviousPage: boolean,
>   startCursor: string | null,
>   endCursor: string | null
> }
> ```

***

### sendMessage

`threads.sendMessage`

Reply to a thread via Plain routing.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.threads.sendMessage({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `threadId` | `string` | Yes | — |
| `textContent` | `string` | Yes | — |
| `markdownContent` | `string` | No | — |
| `attachmentIds` | `string[]` | No | — |
| `impersonation` | `object` | No | — |

> [accordion] impersonation full type
>
> ```ts theme={null}
> {
>   asCustomer: {
>     customerIdentifier: {
>       externalId?: string,
>       emailAddress?: string,
>       customerId?: string
>     }
>   }
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `success` | `true` | Yes | — |

***

### update

`threads.update`

Update a thread title.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.threads.update({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `threadId` | `string` | Yes | — |
| `title` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `thread` | `object \| null` | Yes | — |

> [accordion] thread full type
>
> ```ts theme={null}
> {
>   id: string,
>   ref: string,
>   title: string,
>   status: string,
>   priority: number
> } | null
> ```

***

## Tiers

### fetch

`tiers.fetch`

Fetch a tier by ID.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.tiers.fetch({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tierId` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `tier` | `object \| null` | Yes | — |

> [accordion] tier full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   externalId?: string | null,
>   color?: string,
>   isDefault?: boolean
> } | null
> ```

***

### list

`tiers.list`

List tiers with cursor pagination.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.tiers.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `first` | `number` | No | — |
| `after` | `string` | No | — |
| `last` | `number` | No | — |
| `before` | `string` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `tiers` | `object[]` | Yes | — |
| `pageInfo` | `object` | Yes | — |

> [accordion] tiers full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   externalId?: string | null,
>   color?: string,
>   isDefault?: boolean
> }[]
> ```

> [accordion] pageInfo full type
>
> ```ts theme={null}
> {
>   hasNextPage: boolean,
>   hasPreviousPage: boolean,
>   startCursor: string | null,
>   endCursor: string | null
> }
> ```

***

## Users

### delete

`users.delete`

Delete a workspace user.

**Risk:** `write`

```ts theme={null}
await corsair.plain.api.users.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `userId` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `success` | `true` | Yes | — |

***

### getById

`users.getById`

Fetch a workspace user by ID.

**Risk:** `read`

```ts theme={null}
await corsair.plain.api.users.getById({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `userId` | `string` | Yes | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `user` | `object \| null` | Yes | — |

> [accordion] user full type
>
> ```ts theme={null}
> {
>   id: string,
>   fullName: string,
>   publicName: string,
>   email: string,
>   isDeleted?: boolean
> } | null
> ```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.