> ## 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.

# Memberstack API reference

> API reference for the Memberstack plugin in Corsair: every `memberstack.api.*` operation with its input and output types, taken from the plugin's 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).

## Members

### addPlan

`members.addPlan`

Add a free plan to a member

**Risk:** `write`

```ts theme={null}
await corsair.memberstack.api.members.addPlan({ id: 'mem_example', planId: 'pln_example' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `planId` | `string` | Yes | — |

**Output:** `void`

***

### create

`members.create`

Create a member with optional free plans and custom data

**Risk:** `write`

```ts theme={null}
await corsair.memberstack.api.members.create({ email: 'member@example.com' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `email` | `string` | Yes | — |
| `customFields` | `Record<string, any>` | No | — |
| `metaData` | `Record<string, any>` | No | — |
| `json` | `Record<string, any>` | No | — |
| `loginRedirect` | `string` | No | — |
| `password` | `string` | No | — |
| `plans` | `object[]` | No | — |

> [accordion] plans full type
>
> ```ts theme={null}
> {
>   planId: string
> }[]
> ```

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   auth?: {
>     email?: string
>   },
>   createdAt?: string,
>   lastLogin?: string | null,
>   verified?: boolean,
>   customFields?: Record<string, any> | null,
>   metaData?: Record<string, any> | null,
>   json?: Record<string, any> | null,
>   loginRedirect?: string | null,
>   stripeCustomerId?: string | null,
>   profileImage?: string | null,
>   permissions?: string[],
>   planConnections?: {
>     id?: string,
>     active?: boolean,
>     status?: string,
>     planId?: string,
>     planName?: string,
>     type?: string,
>     payment?: Record<string, any> | null
>   }[],
>   teams?: {
>     id: string,
>     role: string,
>     createdAt: string,
>     inviteToken: string,
>     currentTeamMemberCount: number,
>     maxTeamMembers: number | null,
>     plan: {
>       id: string,
>       name: string,
>       teamAccountInviteSignupLink: string,
>       teamAccountUpgradeLink: string
>     } | null
>   }[]
> }
> ```

***

### delete

`members.delete`

Permanently delete a member and optionally cancel subscriptions

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.memberstack.api.members.delete({ id: 'mem_example' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `deleteStripeCustomer` | `boolean` | No | — |
| `cancelStripeSubscriptions` | `boolean` | No | — |

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string
> }
> ```

***

### get

`members.get`

Get a member by ID or email; returns null when absent

**Risk:** `read`

```ts theme={null}
await corsair.memberstack.api.members.get({ id_or_email: 'mem_example' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id_or_email` | `string` | Yes | — |
| `include` | `string` | No | — |

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   auth?: {
>     email?: string
>   },
>   createdAt?: string,
>   lastLogin?: string | null,
>   verified?: boolean,
>   customFields?: Record<string, any> | null,
>   metaData?: Record<string, any> | null,
>   json?: Record<string, any> | null,
>   loginRedirect?: string | null,
>   stripeCustomerId?: string | null,
>   profileImage?: string | null,
>   permissions?: string[],
>   planConnections?: {
>     id?: string,
>     active?: boolean,
>     status?: string,
>     planId?: string,
>     planName?: string,
>     type?: string,
>     payment?: Record<string, any> | null
>   }[],
>   teams?: {
>     id: string,
>     role: string,
>     createdAt: string,
>     inviteToken: string,
>     currentTeamMemberCount: number,
>     maxTeamMembers: number | null,
>     plan: {
>       id: string,
>       name: string,
>       teamAccountInviteSignupLink: string,
>       teamAccountUpgradeLink: string
>     } | null
>   }[]
> } | null
> ```

***

### list

`members.list`

List members with cursor pagination

**Risk:** `read`

```ts theme={null}
await corsair.memberstack.api.members.list({ limit: 25, after: 123 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `after` | `number` | No | — |
| `order` | `ASC \| DESC` | No | — |
| `first` | `number` | No | — |
| `limit` | `number` | No | — |
| `includeJSON` | `true` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object[]` | Yes | — |
| `totalCount` | `number` | Yes | — |
| `endCursor` | `number \| null` | Yes | — |
| `hasNextPage` | `boolean` | Yes | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   auth?: {
>     email?: string
>   },
>   createdAt?: string,
>   lastLogin?: string | null,
>   verified?: boolean,
>   customFields?: Record<string, any> | null,
>   metaData?: Record<string, any> | null,
>   json?: Record<string, any> | null,
>   loginRedirect?: string | null,
>   stripeCustomerId?: string | null,
>   profileImage?: string | null,
>   permissions?: string[],
>   planConnections?: {
>     id?: string,
>     active?: boolean,
>     status?: string,
>     planId?: string,
>     planName?: string,
>     type?: string,
>     payment?: Record<string, any> | null
>   }[],
>   teams?: {
>     id: string,
>     role: string,
>     createdAt: string,
>     inviteToken: string,
>     currentTeamMemberCount: number,
>     maxTeamMembers: number | null,
>     plan: {
>       id: string,
>       name: string,
>       teamAccountInviteSignupLink: string,
>       teamAccountUpgradeLink: string
>     } | null
>   }[]
> }[]
> ```

***

### removePlan

`members.removePlan`

Remove a free plan and revoke its access

**Risk:** `write`

```ts theme={null}
await corsair.memberstack.api.members.removePlan({ id: 'mem_example', planId: 'pln_example' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `planId` | `string` | Yes | — |

**Output:** `void`

***

### update

`members.update`

Update a member; JSON is replaced, not merged

**Risk:** `write`

```ts theme={null}
await corsair.memberstack.api.members.update({ id: 'mem_example', customFields: { city: 'Paris' } });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `email` | `string` | No | — |
| `customFields` | `Record<string, any>` | No | — |
| `metaData` | `Record<string, any>` | No | — |
| `json` | `Record<string, any>` | No | — |
| `loginRedirect` | `string` | No | — |
| `verified` | `boolean` | No | — |
| `profileImage` | `string` | No | — |

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   auth?: {
>     email?: string
>   },
>   createdAt?: string,
>   lastLogin?: string | null,
>   verified?: boolean,
>   customFields?: Record<string, any> | null,
>   metaData?: Record<string, any> | null,
>   json?: Record<string, any> | null,
>   loginRedirect?: string | null,
>   stripeCustomerId?: string | null,
>   profileImage?: string | null,
>   permissions?: string[],
>   planConnections?: {
>     id?: string,
>     active?: boolean,
>     status?: string,
>     planId?: string,
>     planName?: string,
>     type?: string,
>     payment?: Record<string, any> | null
>   }[],
>   teams?: {
>     id: string,
>     role: string,
>     createdAt: string,
>     inviteToken: string,
>     currentTeamMemberCount: number,
>     maxTeamMembers: number | null,
>     plan: {
>       id: string,
>       name: string,
>       teamAccountInviteSignupLink: string,
>       teamAccountUpgradeLink: string
>     } | null
>   }[]
> }
> ```

***

### verifyToken

`members.verifyToken`

Verify a member JWT and return its decoded payload

**Risk:** `read`

```ts theme={null}
await corsair.memberstack.api.members.verifyToken({ token: 'member-jwt' });
```

**Input**

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

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   type: string,
>   iat: number,
>   exp: number,
>   aud: string,
>   iss: string
> }
> ```

***

## Records

### create

`records.create`

Create a data table record

**Risk:** `write`

```ts theme={null}
await corsair.memberstack.api.records.create({ tableKey: 'products', data: { name: 'Widget' } });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tableKey` | `string` | Yes | — |
| `data` | `Record<string, any>` | Yes | — |
| `memberId` | `string` | No | — |

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   tableKey?: string,
>   data: Record<string, any>,
>   createdAt: string,
>   updatedAt: string,
>   internalOrder: number,
>   createdByMemberId?: string | null
> }
> ```

***

### delete

`records.delete`

Permanently delete a data table record

**Risk:** `destructive` · **Irreversible**

```ts theme={null}
await corsair.memberstack.api.records.delete({ tableKey: 'products', recordId: 'record_example' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tableKey` | `string` | Yes | — |
| `recordId` | `string` | Yes | — |

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   tableKey?: string,
>   data: Record<string, any>,
>   createdAt: string,
>   updatedAt: string,
>   internalOrder: number,
>   createdByMemberId?: string | null
> }
> ```

***

### query

`records.query`

Query data records with filters and pagination

**Risk:** `read`

```ts theme={null}
await corsair.memberstack.api.records.query({ tableKey: 'products', query: { findMany: { take: 20, after: 123, orderBy: { internalOrder: 'asc' } } } });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tableKey` | `string` | Yes | — |
| `query` | `object` | Yes | — |

> [accordion] query full type
>
> ```ts theme={null}
> {
>   findMany: {
>     where?: Record<string, any>,
>     include?: Record<string, any>,
>     select?: Record<string, any>,
>     orderBy?: Record<string, any> | Record<string, any>[],
>     take?: number,
>     skip?: number,
>     after?: string | number,
>     _count?: boolean
>   },
>   findUnique?: never
> } | {
>   findUnique: {
>     where: {
>       id: string
>     },
>     include?: Record<string, any>,
>     select?: Record<string, any>
>   },
>   findMany?: never
> }
> ```

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   records: {
>     id: string,
>     tableKey?: string,
>     data: Record<string, any>,
>     createdAt: string,
>     updatedAt: string,
>     internalOrder: number,
>     createdByMemberId?: string | null
>   }[],
>   pagination: {
>     hasMore: boolean,
>     limit: number,
>     endCursor: number | string | null
>   }
> } | {
>   record: {
>     id: string,
>     tableKey?: string,
>     data: Record<string, any>,
>     createdAt: string,
>     updatedAt: string,
>     internalOrder: number,
>     createdByMemberId?: string | null
>   }
> } | {
>   _count: number
> }
> ```

***

### update

`records.update`

Update fields on a data table record

**Risk:** `write`

```ts theme={null}
await corsair.memberstack.api.records.update({ tableKey: 'products', recordId: 'record_example', data: { name: 'Updated' } });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `tableKey` | `string` | Yes | — |
| `recordId` | `string` | Yes | — |
| `data` | `Record<string, any>` | Yes | — |

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   tableKey?: string,
>   data: Record<string, any>,
>   createdAt: string,
>   updatedAt: string,
>   internalOrder: number,
>   createdByMemberId?: string | null
> }
> ```

***

## Tables

### get

`tables.get`

Get a data table by key or ID

**Risk:** `read`

```ts theme={null}
await corsair.memberstack.api.tables.get({ tableKey: 'products' });
```

**Input**

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

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: string,
>   key: string,
>   name: string,
>   createRule: string,
>   readRule: string,
>   updateRule: string,
>   deleteRule: string,
>   createdAt: string,
>   updatedAt: string,
>   fields: {
>     id: string,
>     key: string,
>     name: string,
>     type: string,
>     required: boolean,
>     defaultValue: any,
>     tableOrder: number,
>     referencedTableId: string | null,
>     referencedTable?: {
>       id: string,
>       key: string,
>       name: string
>     } | null
>   }[]
> }
> ```

***

### list

`tables.list`

List data tables and their fields

**Risk:** `read`

```ts theme={null}
await corsair.memberstack.api.tables.list({});
```

**Input:** *empty object*

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   tables: {
>     id: string,
>     key: string,
>     name: string,
>     createRule: string,
>     readRule: string,
>     updateRule: string,
>     deleteRule: string,
>     createdAt: string,
>     updatedAt: string,
>     fields: {
>       id: string,
>       key: string,
>       name: string,
>       type: string,
>       required: boolean,
>       defaultValue: any,
>       tableOrder: number,
>       referencedTableId: string | null,
>       referencedTable?: {
>         id: string,
>         key: string,
>         name: string
>       } | null
>     }[]
>   }[]
> }
> ```

***


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