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

# Dub API reference

> API reference for the Dub plugin in Corsair: every `dub.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).

## Analytics

### retrieve

`analytics.retrieve`

Read aggregated click, lead and sale analytics, grouped by count, timeseries, country, device, link and more

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.analytics.retrieve({ groupBy: 'countries', interval: '7d' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | No | — |
| `key` | `string` | No | — |
| `linkId` | `string` | No | — |
| `externalId` | `string` | No | — |
| `tenantId` | `string` | No | — |
| `tagId` | `string` | No | — |
| `folderId` | `string` | No | — |
| `partnerTagId` | `string` | No | — |
| `groupId` | `string` | No | — |
| `partnerId` | `string` | No | — |
| `customerId` | `string` | No | — |
| `interval` | `24h \| 7d \| 30d \| 90d \| 1y \| mtd \| qtd \| ytd \| all` | No | Defaults to 24h. Ignored when start or end is set. |
| `start` | `string` | No | Start date, taking precedence over interval. Accepts natural language such as "4 hours ago". |
| `end` | `string` | No | — |
| `timezone` | `string` | No | — |
| `country` | `string` | No | — |
| `city` | `string` | No | — |
| `region` | `string` | No | — |
| `continent` | `string` | No | — |
| `device` | `string` | No | — |
| `browser` | `string` | No | — |
| `os` | `string` | No | — |
| `trigger` | `string` | No | — |
| `eventName` | `string` | No | — |
| `referer` | `string` | No | — |
| `refererUrl` | `string` | No | — |
| `url` | `string` | No | — |
| `utm_source` | `string` | No | — |
| `utm_medium` | `string` | No | — |
| `utm_campaign` | `string` | No | — |
| `utm_term` | `string` | No | — |
| `utm_content` | `string` | No | — |
| `root` | `boolean` | No | — |
| `saleType` | `new \| recurring` | No | — |
| `query` | `string` | No | — |
| `event` | `clicks \| leads \| sales \| composite` | No | — |
| `groupBy` | `count \| timeseries \| continents \| regions \| countries \| cities \| devices \| browsers \| os \| trigger \| triggers \| event_names \| referers \| referer_urls \| top_folders \| top_link_tags \| top_domains \| top_links \| top_urls \| top_base_urls \| top_partners \| top_groups \| top_partner_tags \| utm_sources \| utm_mediums \| utm_campaigns \| utm_terms \| utm_contents` | No | — |

**Output:** `object \| object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   clicks?: number | null,
>   leads?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null
> } | {
>   start?: string | null,
>   continent?: string | null,
>   country?: string | null,
>   region?: string | null,
>   city?: string | null,
>   device?: string | null,
>   browser?: string | null,
>   os?: string | null,
>   trigger?: string | null,
>   eventName?: string | null,
>   referer?: string | null,
>   refererUrl?: string | null,
>   url?: string | null,
>   link?: string | null,
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   shortLink?: string | null,
>   createdAt?: string | null,
>   clicks?: number | null,
>   leads?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null
> }[]
> ```

***

## Bounties

### approveSubmission

`bounties.approveSubmission`

Approve a bounty submission: approve a bounty submission. Optionally specify a custom reward amount. (awards the bounty reward)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.bounties.approveSubmission({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `bountyId` | `string` | Yes | The ID of the bounty |
| `submissionId` | `string` | Yes | The ID of the bounty submission |
| `rewardAmount` | `number \| null` | No | The reward amount for the performance-based bounty. Applicable if the bounty reward amount is not set. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | — |
| `bountyId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `urls` | `string[] \| null` | No | — |
| `files` | `object[] \| null` | No | — |
| `status` | `string \| null` | No | — |
| `performanceCount` | `number \| null` | No | — |
| `socialMetricCount` | `number \| null` | No | — |
| `socialMetricsLastSyncedAt` | `string \| null` | No | — |
| `approvedSocialMetricThreshold` | `number \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `completedAt` | `string \| null` | No | — |
| `reviewedAt` | `string \| null` | No | — |
| `rejectionReason` | `string \| null` | No | — |
| `rejectionNote` | `string \| null` | No | — |
| `periodNumber` | `number \| null` | No | — |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   fileName?: string | null,
>   size?: number | null
> }[] | null
> ```

***

### listSubmissions

`bounties.listSubmissions`

List bounty submissions: list all submissions for a specific bounty in your partner program.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.bounties.listSubmissions({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `bountyId` | `string` | Yes | The unique ID of the bounty on Dub. Can be found in the URL of the bounty page, prefixed with `bnty_`. |
| `status` | `draft \| submitted \| approved \| rejected \| partiallyApproved` | No | The status of the submissions to list. |
| `groupId` | `string` | No | The ID of the group to list submissions for. |
| `partnerId` | `string` | No | The ID of the partner to list submissions for. |
| `sortBy` | `completedAt \| performanceCount \| socialMetricCount` | No | The field to sort the submissions by. |
| `sortOrder` | `asc \| desc` | No | The order to sort the submissions by. |
| `page` | `number` | No | The page number for pagination. The first page is `1`. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   bountyId?: string | null,
>   partnerId?: string | null,
>   description?: string | null,
>   urls?: string[] | null,
>   files?: {
>     url?: string | null,
>     fileName?: string | null,
>     size?: number | null
>   }[] | null,
>   status?: string | null,
>   performanceCount?: number | null,
>   socialMetricCount?: number | null,
>   socialMetricsLastSyncedAt?: string | null,
>   approvedSocialMetricThreshold?: number | null,
>   createdAt?: string | null,
>   completedAt?: string | null,
>   reviewedAt?: string | null,
>   rejectionReason?: string | null,
>   rejectionNote?: string | null,
>   periodNumber?: number | null
> }[]
> ```

***

### rejectSubmission

`bounties.rejectSubmission`

Reject a bounty submission: reject a bounty submission with a specified reason and optional note. (notifies the partner)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.bounties.rejectSubmission({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `bountyId` | `string` | Yes | The ID of the bounty |
| `submissionId` | `string` | Yes | The ID of the bounty submission |
| `rejectionReason` | `invalidProof \| duplicateSubmission \| outOfTimeWindow \| didNotMeetCriteria \| other` | No | The reason for rejecting the submission. |
| `rejectionNote` | `string` | No | The note for rejecting the submission. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | — |
| `bountyId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `urls` | `string[] \| null` | No | — |
| `files` | `object[] \| null` | No | — |
| `status` | `string \| null` | No | — |
| `performanceCount` | `number \| null` | No | — |
| `socialMetricCount` | `number \| null` | No | — |
| `socialMetricsLastSyncedAt` | `string \| null` | No | — |
| `approvedSocialMetricThreshold` | `number \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `completedAt` | `string \| null` | No | — |
| `reviewedAt` | `string \| null` | No | — |
| `rejectionReason` | `string \| null` | No | — |
| `rejectionNote` | `string \| null` | No | — |
| `periodNumber` | `number \| null` | No | — |

> [accordion] files full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   fileName?: string | null,
>   size?: number | null
> }[] | null
> ```

***

## Commissions

### bulkUpdate

`commissions.bulkUpdate`

Bulk update commissions: bulk update up to 100 commissions with the same status. (changes what partners are paid)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.commissions.bulkUpdate({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `commissionIds` | `string[]` | Yes | — |
| `status` | `pending \| refunded \| duplicate \| canceled \| fraud \| hold` | Yes | The status to apply to every commission in the batch. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   status?: string | null
> }[]
> ```

***

### create

`commissions.create`

Create commission: create one or more commissions (custom, lead or sale) for a partner. Custom commissions accept a negative `amount` to create a clawback. Commission creation… (creates a commission owed to a partner)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.commissions.create({});
```

**Input:** `object`

> [accordion] Input full type
>
> ```ts theme={null}
> {
>   type: custom,
>   partnerId: string,
>   amount: number,
>   date?: string | null,
>   description?: string | null
> } | {
>   type: lead,
>   partnerId: string,
>   customerId?: string | null,
>   customer?: {
>     email?: string | null,
>     name?: string | null,
>     avatar?: string | null,
>     externalId: string,
>     stripeCustomerId?: string | null,
>     country: string
>   } | null,
>   linkId?: string | null,
>   date?: string | null,
>   lead?: {
>     eventName?: string | null,
>     metadata?: Record<string, any> | null
>   } | null,
>   leadEventDate?: string | null,
>   leadEventName?: string | null
> } | {
>   type: sale,
>   partnerId: string,
>   customerId?: string | null,
>   customer?: {
>     email?: string | null,
>     name?: string | null,
>     avatar?: string | null,
>     externalId: string,
>     stripeCustomerId?: string | null,
>     country: string
>   } | null,
>   linkId?: string | null,
>   discountCode?: string | null,
>   stripeInvoicesToImport?: all | string[] | null,
>   date?: string | null,
>   sale?: {
>     amount?: number | null,
>     currency?: string,
>     eventName?: string,
>     paymentProcessor?: stripe | shopify | polar | paddle | apple | revenuecat | lemonsqueezy | dub | custom,
>     invoiceId?: string | null,
>     metadata?: Record<string, any> | null
>   } | null,
>   importStripeInvoices?: boolean | null,
>   saleEventDate?: string | null,
>   saleAmount?: number | null,
>   invoiceId?: string | null,
>   productId?: string | null
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `success` | `boolean \| null` | No | — |
| `message` | `string \| null` | No | — |

***

### list

`commissions.list`

List all commissions: retrieve a paginated list of commissions for your partner program.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.commissions.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `string` | No | One type (click, lead, sale, referral, custom), several comma-separated ("sale,lead"), or an exclusion ("-click"). |
| `customerId` | `string` | No | Filter the list of commissions by the associated customer. |
| `payoutId` | `string` | No | Filter the list of commissions by the associated payout. |
| `bountySubmissionId` | `string` | No | Filter the list of commissions by the associated bounty submission. |
| `partnerId` | `string` | No | Filter the list of commissions by the associated partner. When specified, takes precedence over `tenantId`. Supports advanced filtering: single value, multiple values (comma-separated), or exclusion… |
| `tenantId` | `string` | No | Filter the list of commissions by the associated partner's `tenantId` (their unique ID within your database). |
| `groupId` | `string` | No | Filter the list of commissions by the associated partner group. Supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with `-`). Examples: - "group\_abc"… |
| `partnerTagId` | `string` | No | Filter the list of commissions by the associated partner tag. Supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with `-`). Examples: - "ptag\_abc" -… |
| `invoiceId` | `string` | No | Filter the list of commissions by the associated invoice. Since invoiceId is unique on a per-program basis, this will only return one commission per invoice. |
| `status` | `pending \| processed \| paid \| refunded \| duplicate \| fraud \| canceled \| hold` | No | Filter the list of commissions by their corresponding status. |
| `sortBy` | `createdAt \| amount` | No | The field to sort the list of commissions by. |
| `sortOrder` | `asc \| desc` | No | The sort order for the list of commissions. |
| `interval` | `24h \| 7d \| 30d \| 90d \| 1y \| mtd \| qtd \| ytd \| all` | No | The interval to retrieve commissions for. |
| `start` | `string` | No | The start date of the date range to filter the commissions by. |
| `end` | `string` | No | The end date of the date range to filter the commissions by. |
| `timezone` | `string` | No | — |
| `query` | `string` | No | Filter by lead or sale event metadata. Top-level keys only. Compares string values only — numeric and boolean metadata values are not matched. Examples: - "metadata\['key']='value'" -… |
| `endingBefore` | `string` | No | If specified, the query only searches for results before this cursor. Mutually exclusive with `startingAfter`. |
| `startingAfter` | `string` | No | If specified, the query only searches for results after this cursor. Mutually exclusive with `endingBefore`. |
| `page` | `number` | No | DEPRECATED. Use `startingAfter` instead. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   type?: string | null,
>   amount?: number | null,
>   earnings?: number | null,
>   currency?: string | null,
>   status?: string | null,
>   invoiceId?: string | null,
>   description?: string | null,
>   quantity?: number | null,
>   userId?: string | null,
>   metadata?: Record<string, any> | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   paidAt?: string | null,
>   partner?: {
>     id?: string | null,
>     name?: string | null,
>     email?: string | null,
>     image?: string | null,
>     payoutsEnabledAt?: string | null,
>     networkStatus?: string | null,
>     country?: string | null,
>     groupId?: string | null
>   } | null,
>   customer?: {
>     id?: string | null,
>     name?: string | null,
>     email?: string | null,
>     avatar?: string | null,
>     externalId?: string | null,
>     stripeCustomerId?: string | null,
>     country?: string | null,
>     sales?: number | null,
>     saleAmount?: number | null,
>     createdAt?: string | null,
>     firstSaleAt?: string | null,
>     subscriptionCanceledAt?: string | null
>   } | null
> }[]
> ```

***

### update

`commissions.update`

Update a commission: update an existing commission amount. This is useful for handling refunds (partial or full) or fraudulent sales. (changes what a partner is paid)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.commissions.update({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The commission's unique ID on Dub. |
| `earnings` | `number` | No | The new earnings amount for the commission. Paid commissions cannot be updated. If provided, will override the earnings calculated based on the sale amount and currency. |
| `saleAmount` | `number` | No | The new absolute amount for the sale. Paid commissions cannot be updated. |
| `modifySaleAmount` | `number` | No | Modify the current sale amount: use positive values to increase the amount, negative values to decrease it. Takes precedence over `saleAmount`. Paid commissions cannot be updated. |
| `currency` | `string` | No | The currency of the sale amount to update. Accepts ISO 4217 currency codes. |
| `status` | `pending \| refunded \| duplicate \| canceled \| fraud \| hold` | No | Useful for marking a commission as pending, refunded, duplicate, canceled, fraudulent, or on hold. Takes precedence over `saleAmount` and `modifySaleAmount`. When a commission is marked as pending,… |
| `amount` | `number` | No | Deprecated. Use `saleAmount` instead. |
| `modifyAmount` | `number` | No | Deprecated. Use `modifySaleAmount` instead. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | — |
| `type` | `string \| null` | No | — |
| `amount` | `number \| null` | No | — |
| `earnings` | `number \| null` | No | — |
| `currency` | `string \| null` | No | — |
| `status` | `string \| null` | No | — |
| `invoiceId` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `quantity` | `number \| null` | No | — |
| `userId` | `string \| null` | No | — |
| `metadata` | `Record<string, any> \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `paidAt` | `string \| null` | No | — |
| `partner` | `object \| null` | No | — |
| `customer` | `object \| null` | No | — |

> [accordion] partner full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   email?: string | null,
>   image?: string | null,
>   payoutsEnabledAt?: string | null,
>   networkStatus?: string | null,
>   country?: string | null,
>   groupId?: string | null
> } | null
> ```

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   email?: string | null,
>   avatar?: string | null,
>   externalId?: string | null,
>   stripeCustomerId?: string | null,
>   country?: string | null,
>   sales?: number | null,
>   saleAmount?: number | null,
>   createdAt?: string | null,
>   firstSaleAt?: string | null,
>   subscriptionCanceledAt?: string | null
> } | null
> ```

***

## Customers

### delete

`customers.delete`

Permanently delete a customer; past events keep their recorded data

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

```ts theme={null}
await corsair.dub.api.customers.delete({ id: 'cus_1KAP4CXQ2W' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The ID of the customer to delete. |

**Output**

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

***

### get

`customers.get`

Retrieve one customer by their Dub id, or their externalId prefixed with ext\_

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.customers.get({ id: 'cus_1KAP4CXQ2W' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The customer's ID on Dub, or their externalId prefixed with ext\_. |
| `includeExpandedFields` | `boolean` | No | Also return the customer's link, partner and discount. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `externalId` | `string \| null` | No | — |
| `name` | `string \| null` | No | — |
| `email` | `string \| null` | No | — |
| `avatar` | `string \| null` | No | — |
| `stripeCustomerId` | `string \| null` | No | — |
| `country` | `string \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `firstSaleAt` | `string \| null` | No | — |
| `subscriptionCanceledAt` | `string \| null` | No | — |
| `link` | `object \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partner` | `object \| null` | No | — |
| `discount` | `object \| null` | No | — |

> [accordion] link full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   shortLink?: string | null,
>   url?: string | null,
>   programId?: string | null
> } | null
> ```

> [accordion] partner full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   email?: string | null,
>   image?: string | null
> } | null
> ```

> [accordion] discount full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   amount?: number | null,
>   type?: string | null,
>   maxDuration?: number | null,
>   couponId?: string | null,
>   couponTestId?: string | null,
>   description?: string | null,
>   partnersCount?: number | null
> } | null
> ```

***

### list

`customers.list`

List customers with filters and cursor paging; the next cursor is the last customer id

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.customers.list({ search: 'jordan', pageSize: 50 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `email` | `string` | No | — |
| `externalId` | `string` | No | — |
| `search` | `string` | No | — |
| `country` | `string` | No | — |
| `linkId` | `string` | No | — |
| `programId` | `string` | No | — |
| `partnerId` | `string` | No | — |
| `includeExpandedFields` | `boolean` | No | — |
| `sortBy` | `createdAt \| saleAmount \| firstSaleAt \| subscriptionCanceledAt` | No | — |
| `sortOrder` | `asc \| desc` | No | — |
| `startingAfter` | `string` | No | — |
| `endingBefore` | `string` | No | — |
| `pageSize` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `items` | `object[]` | Yes | — |
| `nextCursor` | `string \| null` | Yes | The startingAfter cursor for the next page while this one is full; null once a page comes back short. |

> [accordion] items full type
>
> ```ts theme={null}
> {
>   id: string,
>   externalId?: string | null,
>   name?: string | null,
>   email?: string | null,
>   avatar?: string | null,
>   stripeCustomerId?: string | null,
>   country?: string | null,
>   sales?: number | null,
>   saleAmount?: number | null,
>   createdAt?: string | null,
>   firstSaleAt?: string | null,
>   subscriptionCanceledAt?: string | null,
>   link?: {
>     id?: string | null,
>     domain?: string | null,
>     key?: string | null,
>     shortLink?: string | null,
>     url?: string | null,
>     programId?: string | null
>   } | null,
>   programId?: string | null,
>   partner?: {
>     id?: string | null,
>     name?: string | null,
>     email?: string | null,
>     image?: string | null
>   } | null,
>   discount?: {
>     id?: string | null,
>     amount?: number | null,
>     type?: string | null,
>     maxDuration?: number | null,
>     couponId?: string | null,
>     couponTestId?: string | null,
>     description?: string | null,
>     partnersCount?: number | null
>   } | null
> }[]
> ```

***

### update

`customers.update`

Update a customer email, name, avatar or country

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.customers.update({ id: 'cus_1KAP4CXQ2W', name: 'Jordan Lee' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `includeExpandedFields` | `boolean` | No | Also return the customer's link, partner and discount. |
| `email` | `string \| null` | No | — |
| `name` | `string \| null` | No | — |
| `avatar` | `string \| null` | No | — |
| `externalId` | `string` | No | — |
| `stripeCustomerId` | `string \| null` | No | — |
| `country` | `string \| null` | No | — |
| `subscriptionCanceledAt` | `string \| null` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `externalId` | `string \| null` | No | — |
| `name` | `string \| null` | No | — |
| `email` | `string \| null` | No | — |
| `avatar` | `string \| null` | No | — |
| `stripeCustomerId` | `string \| null` | No | — |
| `country` | `string \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `firstSaleAt` | `string \| null` | No | — |
| `subscriptionCanceledAt` | `string \| null` | No | — |
| `link` | `object \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partner` | `object \| null` | No | — |
| `discount` | `object \| null` | No | — |

> [accordion] link full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   shortLink?: string | null,
>   url?: string | null,
>   programId?: string | null
> } | null
> ```

> [accordion] partner full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   email?: string | null,
>   image?: string | null
> } | null
> ```

> [accordion] discount full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   amount?: number | null,
>   type?: string | null,
>   maxDuration?: number | null,
>   couponId?: string | null,
>   couponTestId?: string | null,
>   description?: string | null,
>   partnersCount?: number | null
> } | null
> ```

***

## Discount Codes

### create

`discountCodes.create`

Create a discount code: create a discount code for a partner. The partner's group must already have a discount assigned to it, and the discount code must be associated with a link… (creates a live discount code)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.discountCodes.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `code` | `string` | No | The discount code to create. If omitted, a unique code will be generated automatically from the partner's name. Stripe and Shopify codes can only contain letters, numbers, dashes, and underscores.… |
| `partnerId` | `string` | Yes | The ID of the partner to create a discount code for. |
| `linkId` | `string` | Yes | The ID of the partner's referral link to associate this discount code with. Each link can only have one discount code. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | — |
| `code` | `string \| null` | No | — |
| `discountId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `linkId` | `string \| null` | No | — |
| `disabledAt` | `string \| null` | No | — |

***

### delete

`discountCodes.delete`

Delete a discount code: delete a discount code for a partner by its unique ID or alphanumeric code. This will also disable the code in your connected discount provider (Stripe,… (deletes the code; customers can no longer use it)

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

```ts theme={null}
await corsair.dub.api.discountCodes.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `idOrCode` | `string` | Yes | The unique ID (e.g. `dcode_...`) or alphanumeric code (e.g. `ABC123`) of the discount code to delete. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | — |

***

### list

`discountCodes.list`

List discount codes: retrieve a paginated list of discount codes in a program or filtered by partner, discount, or code.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.discountCodes.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string` | No | The ID of the partner to retrieve discount codes for. If omitted, returns discount codes for the whole program. |
| `discountId` | `string` | No | Filter discount codes by discount ID. |
| `code` | `string` | No | Filter discount codes by the alphanumeric code (e.g. `PARTNER10OFF`). |
| `page` | `number` | No | The page number for pagination. The first page is `1`. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   code?: string | null,
>   discountId?: string | null,
>   partnerId?: string | null,
>   linkId?: string | null,
>   disabledAt?: string | null
> }[]
> ```

***

## Domains

### checkStatus

`domains.checkStatus`

Check the availability of one or more domains: check if a domain name is available for purchase. You can check multiple domains at once.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.domains.checkStatus({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domains` | `string \| string[]` | Yes | The domains to search. We only support .link domains for now. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   domain?: string | null,
>   available?: boolean | null,
>   premium?: boolean | null,
>   prices?: {
>     registration?: number | null,
>     renewal?: number | null
>   } | null,
>   price?: string | null
> }[]
> ```

***

### create

`domains.create`

Add a domain to the workspace; it still needs DNS verification in the dashboard

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.domains.create({ slug: 'acme.link' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `slug` | `string` | Yes | — |
| `expiredUrl` | `string \| null` | No | — |
| `notFoundUrl` | `string \| null` | No | — |
| `archived` | `boolean` | No | — |
| `placeholder` | `string \| null` | No | — |
| `logo` | `string \| string \| null` | No | — |
| `assetLinks` | `string \| null` | No | — |
| `appleAppSiteAssociation` | `string \| null` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `slug` | `string \| null` | No | — |
| `verified` | `boolean \| null` | No | — |
| `primary` | `boolean \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `placeholder` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `notFoundUrl` | `string \| null` | No | — |
| `logo` | `string \| null` | No | — |
| `assetLinks` | `string \| null` | No | — |
| `appleAppSiteAssociation` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `registeredDomain` | `object \| null` | No | — |

> [accordion] registeredDomain full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   autoRenewalDisabledAt?: string | null,
>   createdAt?: string | null,
>   expiresAt?: string | null,
>   renewalFee?: number | null
> } | null
> ```

***

### delete

`domains.delete`

Permanently delete a domain; its links stop resolving and analytics are not restored on recreate

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

```ts theme={null}
await corsair.dub.api.domains.delete({ slug: 'acme.link' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `slug` | `string` | Yes | The domain name to delete. |

**Output**

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

***

### list

`domains.list`

List the workspace domains with search and page paging

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.domains.list({ archived: false });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `archived` | `boolean` | No | — |
| `search` | `string` | No | — |
| `page` | `number` | No | — |
| `pageSize` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `items` | `object[]` | Yes | — |
| `page` | `number` | Yes | — |
| `pageSize` | `number` | Yes | — |
| `nextPage` | `number \| null` | Yes | The next page while this one came back full; null once it came back short. A full last page leads to one empty page. |

> [accordion] items full type
>
> ```ts theme={null}
> {
>   id: string,
>   slug?: string | null,
>   verified?: boolean | null,
>   primary?: boolean | null,
>   archived?: boolean | null,
>   placeholder?: string | null,
>   expiredUrl?: string | null,
>   notFoundUrl?: string | null,
>   logo?: string | null,
>   assetLinks?: string | null,
>   appleAppSiteAssociation?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   registeredDomain?: {
>     id?: string | null,
>     autoRenewalDisabledAt?: string | null,
>     createdAt?: string | null,
>     expiresAt?: string | null,
>     renewalFee?: number | null
>   } | null
> }[]
> ```

***

### register

`domains.register`

Register a domain: register a domain for the authenticated workspace. Only available for Enterprise Plans. (claims a .link domain for the workspace)

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

```ts theme={null}
await corsair.dub.api.domains.register({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | Yes | The domain to claim. We only support .link domains for now. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string \| null` | No | — |
| `status` | `string \| null` | No | — |
| `expiration` | `number \| null` | No | — |

***

### update

`domains.update`

Update a domain or rename it with newSlug; redirects and branding are editable here

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.domains.update({ slug: 'acme.link', newSlug: 'acme.io' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `slug` | `string` | Yes | The current domain name to update. |
| `newSlug` | `string` | No | A new domain name, to rename the domain. |
| `expiredUrl` | `string \| null` | No | — |
| `notFoundUrl` | `string \| null` | No | — |
| `archived` | `boolean` | No | — |
| `placeholder` | `string \| null` | No | — |
| `logo` | `string \| string \| null` | No | — |
| `assetLinks` | `string \| null` | No | — |
| `appleAppSiteAssociation` | `string \| null` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `slug` | `string \| null` | No | — |
| `verified` | `boolean \| null` | No | — |
| `primary` | `boolean \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `placeholder` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `notFoundUrl` | `string \| null` | No | — |
| `logo` | `string \| null` | No | — |
| `assetLinks` | `string \| null` | No | — |
| `appleAppSiteAssociation` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `registeredDomain` | `object \| null` | No | — |

> [accordion] registeredDomain full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   autoRenewalDisabledAt?: string | null,
>   createdAt?: string | null,
>   expiresAt?: string | null,
>   renewalFee?: number | null
> } | null
> ```

***

## Embed Tokens

### createReferrals

`embedTokens.createReferrals`

Create a referrals embed token: create a referrals embed token for the given partner/tenant. The endpoint first attempts to locate an existing enrollment using the provided tenantId. If no…

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.embedTokens.createReferrals({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string` | No | — |
| `tenantId` | `string` | No | — |
| `partner` | `object` | No | — |

> [accordion] partner full type
>
> ```ts theme={null}
> {
>   name?: string | null,
>   email: string,
>   username?: string | null,
>   image?: string | null,
>   tenantId?: string,
>   groupId?: string,
>   tagIds?: string[],
>   tagNames?: string[],
>   country?: string | null,
>   description?: string | null,
>   linkProps?: {
>     externalId?: string | null,
>     tenantId?: string | null,
>     prefix?: string,
>     archived?: boolean,
>     tagIds?: string | string[],
>     tagNames?: string | string[],
>     comments?: string | null,
>     expiresAt?: string | null,
>     expiredUrl?: string | null,
>     password?: string | null,
>     proxy?: boolean,
>     title?: string | null,
>     description?: string | null,
>     image?: string | null,
>     video?: string | null,
>     rewrite?: boolean,
>     ios?: string | null,
>     android?: string | null,
>     doIndex?: boolean,
>     testVariants?: {
>       url: string,
>       percentage: number
>     }[] | null,
>     testStartedAt?: string | null,
>     testCompletedAt?: string | null
>   }
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `publicToken` | `string \| null` | No | — |
| `expires` | `string \| null` | No | — |

***

## Events

### list

`events.list`

List raw click, lead and sale events with filters, newest first

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.events.list({ event: 'clicks', limit: 100 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | No | — |
| `key` | `string` | No | — |
| `linkId` | `string` | No | — |
| `externalId` | `string` | No | — |
| `tenantId` | `string` | No | — |
| `tagId` | `string` | No | — |
| `folderId` | `string` | No | — |
| `partnerTagId` | `string` | No | — |
| `groupId` | `string` | No | — |
| `partnerId` | `string` | No | — |
| `customerId` | `string` | No | — |
| `interval` | `24h \| 7d \| 30d \| 90d \| 1y \| mtd \| qtd \| ytd \| all` | No | Defaults to 24h. Ignored when start or end is set. |
| `start` | `string` | No | Start date, taking precedence over interval. Accepts natural language such as "4 hours ago". |
| `end` | `string` | No | — |
| `timezone` | `string` | No | — |
| `country` | `string` | No | — |
| `city` | `string` | No | — |
| `region` | `string` | No | — |
| `continent` | `string` | No | — |
| `device` | `string` | No | — |
| `browser` | `string` | No | — |
| `os` | `string` | No | — |
| `trigger` | `string` | No | — |
| `eventName` | `string` | No | — |
| `referer` | `string` | No | — |
| `refererUrl` | `string` | No | — |
| `url` | `string` | No | — |
| `utm_source` | `string` | No | — |
| `utm_medium` | `string` | No | — |
| `utm_campaign` | `string` | No | — |
| `utm_term` | `string` | No | — |
| `utm_content` | `string` | No | — |
| `root` | `boolean` | No | — |
| `saleType` | `new \| recurring` | No | — |
| `query` | `string` | No | — |
| `event` | `clicks \| leads \| sales` | No | — |
| `page` | `number` | No | — |
| `limit` | `number` | No | Defaults to 100. |
| `sortBy` | `timestamp` | No | — |
| `sortOrder` | `asc \| desc` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `items` | `object[]` | Yes | — |
| `page` | `number` | Yes | — |
| `limit` | `number` | Yes | — |
| `nextPage` | `number \| null` | Yes | The next page while this one came back full; null once it came back short. A full last page leads to one empty page. |

> [accordion] items full type
>
> ```ts theme={null}
> (
>   {
>     event: click,
>     timestamp?: string | null,
>     click?: {
>       id: string,
>       timestamp?: string | null,
>       url?: string | null,
>       country?: string | null,
>       city?: string | null,
>       region?: string | null,
>       continent?: string | null,
>       device?: string | null,
>       browser?: string | null,
>       os?: string | null,
>       ua?: string | null,
>       trigger?: string | null,
>       referer?: string | null,
>       refererUrl?: string | null,
>       qr?: boolean | null,
>       ip?: string | null
>     } | null,
>     link?: {
>       id: string,
>       domain?: string | null,
>       key?: string | null,
>       url?: string | null,
>       trackConversion?: boolean | null,
>       externalId?: string | null,
>       tenantId?: string | null,
>       programId?: string | null,
>       partnerId?: string | null,
>       archived?: boolean | null,
>       expiresAt?: string | null,
>       expiredUrl?: string | null,
>       disabledAt?: string | null,
>       password?: string | null,
>       proxy?: boolean | null,
>       title?: string | null,
>       description?: string | null,
>       image?: string | null,
>       video?: string | null,
>       rewrite?: boolean | null,
>       doIndex?: boolean | null,
>       ios?: string | null,
>       android?: string | null,
>       geo?: Record<string, any> | null,
>       publicStats?: boolean | null,
>       tags?: {
>         id: string,
>         name?: string | null,
>         color?: string | null
>       }[] | null,
>       folderId?: string | null,
>       comments?: string | null,
>       shortLink?: string | null,
>       qrCode?: string | null,
>       utm_source?: string | null,
>       utm_medium?: string | null,
>       utm_campaign?: string | null,
>       utm_term?: string | null,
>       utm_content?: string | null,
>       testVariants?: {
>         url?: string | null,
>         percentage?: number | null
>       }[] | null,
>       testStartedAt?: string | null,
>       testCompletedAt?: string | null,
>       userId?: string | null,
>       workspaceId?: string | null,
>       clicks?: number | null,
>       leads?: number | null,
>       conversions?: number | null,
>       sales?: number | null,
>       saleAmount?: number | null,
>       lastClicked?: string | null,
>       createdAt?: string | null,
>       updatedAt?: string | null,
>       projectId?: string | null
>     } | null,
>     click_id?: string | null,
>     link_id?: string | null,
>     domain?: string | null,
>     key?: string | null,
>     url?: string | null,
>     continent?: string | null,
>     country?: string | null,
>     city?: string | null,
>     device?: string | null,
>     browser?: string | null,
>     os?: string | null,
>     qr?: boolean | null,
>     ip?: string | null
>   } | {
>     event: lead,
>     timestamp?: string | null,
>     eventId?: string | null,
>     eventName?: string | null,
>     metadata?: Record<string, any> | null,
>     customer?: {
>       id?: string | null,
>       name?: string | null,
>       email?: string | null,
>       avatar?: string | null,
>       externalId?: string | null,
>       createdAt?: string | null
>     } | null,
>     click?: {
>       id: string,
>       timestamp?: string | null,
>       url?: string | null,
>       country?: string | null,
>       city?: string | null,
>       region?: string | null,
>       continent?: string | null,
>       device?: string | null,
>       browser?: string | null,
>       os?: string | null,
>       ua?: string | null,
>       trigger?: string | null,
>       referer?: string | null,
>       refererUrl?: string | null,
>       qr?: boolean | null,
>       ip?: string | null
>     } | null,
>     link?: {
>       id: string,
>       domain?: string | null,
>       key?: string | null,
>       url?: string | null,
>       trackConversion?: boolean | null,
>       externalId?: string | null,
>       tenantId?: string | null,
>       programId?: string | null,
>       partnerId?: string | null,
>       archived?: boolean | null,
>       expiresAt?: string | null,
>       expiredUrl?: string | null,
>       disabledAt?: string | null,
>       password?: string | null,
>       proxy?: boolean | null,
>       title?: string | null,
>       description?: string | null,
>       image?: string | null,
>       video?: string | null,
>       rewrite?: boolean | null,
>       doIndex?: boolean | null,
>       ios?: string | null,
>       android?: string | null,
>       geo?: Record<string, any> | null,
>       publicStats?: boolean | null,
>       tags?: {
>         id: string,
>         name?: string | null,
>         color?: string | null
>       }[] | null,
>       folderId?: string | null,
>       comments?: string | null,
>       shortLink?: string | null,
>       qrCode?: string | null,
>       utm_source?: string | null,
>       utm_medium?: string | null,
>       utm_campaign?: string | null,
>       utm_term?: string | null,
>       utm_content?: string | null,
>       testVariants?: {
>         url?: string | null,
>         percentage?: number | null
>       }[] | null,
>       testStartedAt?: string | null,
>       testCompletedAt?: string | null,
>       userId?: string | null,
>       workspaceId?: string | null,
>       clicks?: number | null,
>       leads?: number | null,
>       conversions?: number | null,
>       sales?: number | null,
>       saleAmount?: number | null,
>       lastClicked?: string | null,
>       createdAt?: string | null,
>       updatedAt?: string | null,
>       projectId?: string | null
>     } | null,
>     click_id?: string | null,
>     link_id?: string | null,
>     domain?: string | null,
>     key?: string | null,
>     url?: string | null,
>     continent?: string | null,
>     country?: string | null,
>     city?: string | null,
>     device?: string | null,
>     browser?: string | null,
>     os?: string | null,
>     qr?: boolean | null,
>     ip?: string | null
>   } | {
>     event: sale,
>     timestamp?: string | null,
>     eventId?: string | null,
>     eventName?: string | null,
>     sale?: {
>       amount?: number | null,
>       currency?: string | null,
>       paymentProcessor?: string | null,
>       invoiceId?: string | null,
>       metadata?: Record<string, any> | null
>     } | null,
>     saleAmount?: number | null,
>     invoice_id?: string | null,
>     payment_processor?: string | null,
>     metadata?: Record<string, any> | null,
>     customer?: {
>       id?: string | null,
>       name?: string | null,
>       email?: string | null,
>       avatar?: string | null,
>       externalId?: string | null,
>       createdAt?: string | null
>     } | null,
>     click?: {
>       id: string,
>       timestamp?: string | null,
>       url?: string | null,
>       country?: string | null,
>       city?: string | null,
>       region?: string | null,
>       continent?: string | null,
>       device?: string | null,
>       browser?: string | null,
>       os?: string | null,
>       ua?: string | null,
>       trigger?: string | null,
>       referer?: string | null,
>       refererUrl?: string | null,
>       qr?: boolean | null,
>       ip?: string | null
>     } | null,
>     link?: {
>       id: string,
>       domain?: string | null,
>       key?: string | null,
>       url?: string | null,
>       trackConversion?: boolean | null,
>       externalId?: string | null,
>       tenantId?: string | null,
>       programId?: string | null,
>       partnerId?: string | null,
>       archived?: boolean | null,
>       expiresAt?: string | null,
>       expiredUrl?: string | null,
>       disabledAt?: string | null,
>       password?: string | null,
>       proxy?: boolean | null,
>       title?: string | null,
>       description?: string | null,
>       image?: string | null,
>       video?: string | null,
>       rewrite?: boolean | null,
>       doIndex?: boolean | null,
>       ios?: string | null,
>       android?: string | null,
>       geo?: Record<string, any> | null,
>       publicStats?: boolean | null,
>       tags?: {
>         id: string,
>         name?: string | null,
>         color?: string | null
>       }[] | null,
>       folderId?: string | null,
>       comments?: string | null,
>       shortLink?: string | null,
>       qrCode?: string | null,
>       utm_source?: string | null,
>       utm_medium?: string | null,
>       utm_campaign?: string | null,
>       utm_term?: string | null,
>       utm_content?: string | null,
>       testVariants?: {
>         url?: string | null,
>         percentage?: number | null
>       }[] | null,
>       testStartedAt?: string | null,
>       testCompletedAt?: string | null,
>       userId?: string | null,
>       workspaceId?: string | null,
>       clicks?: number | null,
>       leads?: number | null,
>       conversions?: number | null,
>       sales?: number | null,
>       saleAmount?: number | null,
>       lastClicked?: string | null,
>       createdAt?: string | null,
>       updatedAt?: string | null,
>       projectId?: string | null
>     } | null,
>     click_id?: string | null,
>     link_id?: string | null,
>     domain?: string | null,
>     key?: string | null,
>     url?: string | null,
>     continent?: string | null,
>     country?: string | null,
>     city?: string | null,
>     device?: string | null,
>     browser?: string | null,
>     os?: string | null,
>     qr?: boolean | null,
>     ip?: string | null
>   }
> )[]
> ```

***

## Folders

### create

`folders.create`

Create a folder to group links, with an access level

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.folders.create({ name: 'Campaigns' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | — |
| `description` | `string \| null` | No | — |
| `accessLevel` | `write \| read \| null` | No | Defaults to write. read and null need Business plans. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `type` | `string \| null` | No | — |
| `accessLevel` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

***

### delete

`folders.delete`

Permanently delete a folder; its links keep existing

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

```ts theme={null}
await corsair.dub.api.folders.delete({ id: 'fold_1KAP4CZF3T' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The ID of the folder to delete. |

**Output**

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

***

### list

`folders.list`

List folders with search and page paging

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.folders.list({ search: 'camp' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `search` | `string` | No | — |
| `page` | `number` | No | — |
| `pageSize` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `items` | `object[]` | Yes | — |
| `page` | `number` | Yes | — |
| `pageSize` | `number` | Yes | — |
| `nextPage` | `number \| null` | Yes | The next page while this one came back full; null once it came back short. A full last page leads to one empty page. |

> [accordion] items full type
>
> ```ts theme={null}
> {
>   id: string,
>   name?: string | null,
>   description?: string | null,
>   type?: string | null,
>   accessLevel?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }[]
> ```

***

### update

`folders.update`

Rename a folder, change its description or access level

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.folders.update({ id: 'fold_1KAP4CZF3T', name: 'Q4' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The ID of the folder to update. |
| `name` | `string` | No | — |
| `description` | `string \| null` | No | — |
| `accessLevel` | `write \| read \| null` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `type` | `string \| null` | No | — |
| `accessLevel` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

***

## Links

### bulkCreate

`links.bulkCreate`

Create up to 100 links in one call; the answer carries one row per link, including per-link errors

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.links.bulkCreate({ links: [{ url: 'https://dub.co', key: 'try' }, { url: 'https://dub.co/help', key: 'help' }] });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `links` | `object[]` | Yes | 1-100 links to create, each with the links.create fields. |

> [accordion] links full type
>
> ```ts theme={null}
> {
>   url: string,
>   domain?: string,
>   key?: string,
>   keyLength?: number,
>   externalId?: string | null,
>   tenantId?: string | null,
>   programId?: string | null,
>   partnerId?: string | null,
>   prefix?: string,
>   trackConversion?: boolean,
>   archived?: boolean,
>   tagIds?: string | string[],
>   tagNames?: string | string[],
>   folderId?: string | null,
>   comments?: string | null,
>   expiresAt?: string | null,
>   expiredUrl?: string | null,
>   password?: string | null,
>   proxy?: boolean,
>   title?: string | null,
>   description?: string | null,
>   image?: string | null,
>   video?: string | null,
>   rewrite?: boolean,
>   ios?: string | null,
>   android?: string | null,
>   geo?: Record<string, string> | null,
>   doIndex?: boolean,
>   utm_source?: string | null,
>   utm_medium?: string | null,
>   utm_campaign?: string | null,
>   utm_term?: string | null,
>   utm_content?: string | null,
>   ref?: string | null,
>   testVariants?: {
>     url: string,
>     percentage: number
>   }[] | null,
>   testStartedAt?: string | null,
>   testCompletedAt?: string | null
> }[]
> ```

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> (
>   {
>     id: string,
>     domain?: string | null,
>     key?: string | null,
>     url?: string | null,
>     trackConversion?: boolean | null,
>     externalId?: string | null,
>     tenantId?: string | null,
>     programId?: string | null,
>     partnerId?: string | null,
>     archived?: boolean | null,
>     expiresAt?: string | null,
>     expiredUrl?: string | null,
>     disabledAt?: string | null,
>     password?: string | null,
>     proxy?: boolean | null,
>     title?: string | null,
>     description?: string | null,
>     image?: string | null,
>     video?: string | null,
>     rewrite?: boolean | null,
>     doIndex?: boolean | null,
>     ios?: string | null,
>     android?: string | null,
>     geo?: Record<string, any> | null,
>     publicStats?: boolean | null,
>     tags?: {
>       id: string,
>       name?: string | null,
>       color?: string | null
>     }[] | null,
>     folderId?: string | null,
>     comments?: string | null,
>     shortLink?: string | null,
>     qrCode?: string | null,
>     utm_source?: string | null,
>     utm_medium?: string | null,
>     utm_campaign?: string | null,
>     utm_term?: string | null,
>     utm_content?: string | null,
>     testVariants?: {
>       url?: string | null,
>       percentage?: number | null
>     }[] | null,
>     testStartedAt?: string | null,
>     testCompletedAt?: string | null,
>     userId?: string | null,
>     workspaceId?: string | null,
>     clicks?: number | null,
>     leads?: number | null,
>     conversions?: number | null,
>     sales?: number | null,
>     saleAmount?: number | null,
>     lastClicked?: string | null,
>     createdAt?: string | null,
>     updatedAt?: string | null,
>     projectId?: string | null
>   } | {
>     link: any,
>     error?: string | null,
>     code?: string | null
>   }
> )[]
> ```

***

### bulkDelete

`links.bulkDelete`

Permanently delete up to 100 links in one call; their analytics are not recoverable

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

```ts theme={null}
await corsair.dub.api.links.bulkDelete({ linkIds: ['link_1KAP4CQ4Y1'] });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `linkIds` | `string[]` | Yes | Up to 100 link IDs. Non-existing IDs are ignored. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `deletedCount` | `number` | Yes | — |

***

### bulkUpdate

`links.bulkUpdate`

Apply one set of field changes to up to 100 links named by id or externalId

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.links.bulkUpdate({ linkIds: ['link_1KAP4CQ4Y1'], data: { archived: true } });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `linkIds` | `string[]` | No | The IDs of the links to update. |
| `externalIds` | `string[]` | No | The external IDs of the links to update. |
| `data` | `object` | Yes | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   url?: string,
>   domain?: string,
>   key?: string,
>   externalId?: string | null,
>   tenantId?: string | null,
>   programId?: string | null,
>   partnerId?: string | null,
>   trackConversion?: boolean,
>   archived?: boolean,
>   tagIds?: string | string[],
>   tagNames?: string | string[],
>   folderId?: string | null,
>   comments?: string | null,
>   expiresAt?: string | null,
>   expiredUrl?: string | null,
>   password?: string | null,
>   proxy?: boolean,
>   title?: string | null,
>   description?: string | null,
>   image?: string | null,
>   video?: string | null,
>   rewrite?: boolean,
>   ios?: string | null,
>   android?: string | null,
>   geo?: Record<string, string> | null,
>   doIndex?: boolean,
>   utm_source?: string | null,
>   utm_medium?: string | null,
>   utm_campaign?: string | null,
>   utm_term?: string | null,
>   utm_content?: string | null,
>   ref?: string | null,
>   testVariants?: {
>     url: string,
>     percentage: number
>   }[] | null,
>   testStartedAt?: string | null,
>   testCompletedAt?: string | null
> }
> ```

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id: string,
>   domain?: string | null,
>   key?: string | null,
>   url?: string | null,
>   trackConversion?: boolean | null,
>   externalId?: string | null,
>   tenantId?: string | null,
>   programId?: string | null,
>   partnerId?: string | null,
>   archived?: boolean | null,
>   expiresAt?: string | null,
>   expiredUrl?: string | null,
>   disabledAt?: string | null,
>   password?: string | null,
>   proxy?: boolean | null,
>   title?: string | null,
>   description?: string | null,
>   image?: string | null,
>   video?: string | null,
>   rewrite?: boolean | null,
>   doIndex?: boolean | null,
>   ios?: string | null,
>   android?: string | null,
>   geo?: Record<string, any> | null,
>   publicStats?: boolean | null,
>   tags?: {
>     id: string,
>     name?: string | null,
>     color?: string | null
>   }[] | null,
>   folderId?: string | null,
>   comments?: string | null,
>   shortLink?: string | null,
>   qrCode?: string | null,
>   utm_source?: string | null,
>   utm_medium?: string | null,
>   utm_campaign?: string | null,
>   utm_term?: string | null,
>   utm_content?: string | null,
>   testVariants?: {
>     url?: string | null,
>     percentage?: number | null
>   }[] | null,
>   testStartedAt?: string | null,
>   testCompletedAt?: string | null,
>   userId?: string | null,
>   workspaceId?: string | null,
>   clicks?: number | null,
>   leads?: number | null,
>   conversions?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null,
>   lastClicked?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   projectId?: string | null
> }[]
> ```

***

### count

`links.count`

Count links matching the filters, optionally grouped by domain, tag, folder or user

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.links.count({ groupBy: 'domain' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | No | — |
| `tagIds` | `string[]` | No | — |
| `tagNames` | `string[]` | No | — |
| `folderId` | `string` | No | — |
| `search` | `string` | No | — |
| `userId` | `string` | No | — |
| `tenantId` | `string` | No | — |
| `showArchived` | `boolean` | No | — |
| `groupBy` | `domain \| tagId \| folderId \| userId` | No | — |

**Output:** `number \| object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> number | {
>   _count?: number | {
>   } | null
> }[]
> ```

***

### create

`links.create`

Create a short link; a duplicate domain and slug answers 409 conflict

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.links.create({ url: 'https://dub.co', domain: 'dub.sh', key: 'try' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | The destination URL of the short link. |
| `domain` | `string` | No | — |
| `key` | `string` | No | — |
| `keyLength` | `number` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `prefix` | `string` | No | — |
| `trackConversion` | `boolean` | No | — |
| `archived` | `boolean` | No | — |
| `tagIds` | `string \| string[]` | No | — |
| `tagNames` | `string \| string[]` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, string> \| null` | No | — |
| `doIndex` | `boolean` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `ref` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url: string,
>   percentage: number
> }[] | null
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `domain` | `string \| null` | No | — |
| `key` | `string \| null` | No | — |
| `url` | `string \| null` | No | — |
| `trackConversion` | `boolean \| null` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `disabledAt` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean \| null` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean \| null` | No | — |
| `doIndex` | `boolean \| null` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, any> \| null` | No | — |
| `publicStats` | `boolean \| null` | No | — |
| `tags` | `object[] \| null` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `shortLink` | `string \| null` | No | — |
| `qrCode` | `string \| null` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |
| `userId` | `string \| null` | No | — |
| `workspaceId` | `string \| null` | No | — |
| `clicks` | `number \| null` | No | — |
| `leads` | `number \| null` | No | — |
| `conversions` | `number \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `lastClicked` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `projectId` | `string \| null` | No | — |

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

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   percentage?: number | null
> }[] | null
> ```

***

### delete

`links.delete`

Permanently delete a short link; recreating it does not restore its analytics

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

```ts theme={null}
await corsair.dub.api.links.delete({ linkId: 'link_1KAP4CQ4Y1' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `linkId` | `string` | Yes | The ID of the link to delete. |

**Output**

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

***

### get

`links.get`

Retrieve one link by id, externalId, or a domain and slug pair

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.links.get({ linkId: 'link_1KAP4CQ4Y1' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `linkId` | `string` | No | — |
| `externalId` | `string` | No | — |
| `domain` | `string` | No | — |
| `key` | `string` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `domain` | `string \| null` | No | — |
| `key` | `string \| null` | No | — |
| `url` | `string \| null` | No | — |
| `trackConversion` | `boolean \| null` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `disabledAt` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean \| null` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean \| null` | No | — |
| `doIndex` | `boolean \| null` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, any> \| null` | No | — |
| `publicStats` | `boolean \| null` | No | — |
| `tags` | `object[] \| null` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `shortLink` | `string \| null` | No | — |
| `qrCode` | `string \| null` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |
| `userId` | `string \| null` | No | — |
| `workspaceId` | `string \| null` | No | — |
| `clicks` | `number \| null` | No | — |
| `leads` | `number \| null` | No | — |
| `conversions` | `number \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `lastClicked` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `projectId` | `string \| null` | No | — |

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

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   percentage?: number | null
> }[] | null
> ```

***

### list

`links.list`

List short links with filters and cursor paging; the next cursor is the last link id

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.links.list({ search: 'try', pageSize: 50 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `domain` | `string` | No | — |
| `tagIds` | `string[]` | No | — |
| `tagNames` | `string[]` | No | — |
| `folderId` | `string` | No | — |
| `search` | `string` | No | — |
| `userId` | `string` | No | — |
| `tenantId` | `string` | No | — |
| `showArchived` | `boolean` | No | — |
| `startingAfter` | `string` | No | — |
| `endingBefore` | `string` | No | — |
| `pageSize` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `items` | `object[]` | Yes | — |
| `nextCursor` | `string \| null` | Yes | The startingAfter cursor for the next page while this one is full; null once a page comes back short. |

> [accordion] items full type
>
> ```ts theme={null}
> {
>   id: string,
>   domain?: string | null,
>   key?: string | null,
>   url?: string | null,
>   trackConversion?: boolean | null,
>   externalId?: string | null,
>   tenantId?: string | null,
>   programId?: string | null,
>   partnerId?: string | null,
>   archived?: boolean | null,
>   expiresAt?: string | null,
>   expiredUrl?: string | null,
>   disabledAt?: string | null,
>   password?: string | null,
>   proxy?: boolean | null,
>   title?: string | null,
>   description?: string | null,
>   image?: string | null,
>   video?: string | null,
>   rewrite?: boolean | null,
>   doIndex?: boolean | null,
>   ios?: string | null,
>   android?: string | null,
>   geo?: Record<string, any> | null,
>   publicStats?: boolean | null,
>   tags?: {
>     id: string,
>     name?: string | null,
>     color?: string | null
>   }[] | null,
>   folderId?: string | null,
>   comments?: string | null,
>   shortLink?: string | null,
>   qrCode?: string | null,
>   utm_source?: string | null,
>   utm_medium?: string | null,
>   utm_campaign?: string | null,
>   utm_term?: string | null,
>   utm_content?: string | null,
>   testVariants?: {
>     url?: string | null,
>     percentage?: number | null
>   }[] | null,
>   testStartedAt?: string | null,
>   testCompletedAt?: string | null,
>   userId?: string | null,
>   workspaceId?: string | null,
>   clicks?: number | null,
>   leads?: number | null,
>   conversions?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null,
>   lastClicked?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   projectId?: string | null
> }[]
> ```

***

### update

`links.update`

Update a short link by id (or externalId prefixed with ext\_)

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.links.update({ linkId: 'link_1KAP4CQ4Y1', archived: true });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `linkId` | `string` | Yes | The ID of the link to update, or its externalId prefixed with ext\_. |
| `url` | `string` | No | — |
| `domain` | `string` | No | — |
| `key` | `string` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `trackConversion` | `boolean` | No | — |
| `archived` | `boolean` | No | — |
| `tagIds` | `string \| string[]` | No | — |
| `tagNames` | `string \| string[]` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, string> \| null` | No | — |
| `doIndex` | `boolean` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `ref` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url: string,
>   percentage: number
> }[] | null
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `domain` | `string \| null` | No | — |
| `key` | `string \| null` | No | — |
| `url` | `string \| null` | No | — |
| `trackConversion` | `boolean \| null` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `disabledAt` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean \| null` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean \| null` | No | — |
| `doIndex` | `boolean \| null` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, any> \| null` | No | — |
| `publicStats` | `boolean \| null` | No | — |
| `tags` | `object[] \| null` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `shortLink` | `string \| null` | No | — |
| `qrCode` | `string \| null` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |
| `userId` | `string \| null` | No | — |
| `workspaceId` | `string \| null` | No | — |
| `clicks` | `number \| null` | No | — |
| `leads` | `number \| null` | No | — |
| `conversions` | `number \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `lastClicked` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `projectId` | `string \| null` | No | — |

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

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   percentage?: number | null
> }[] | null
> ```

***

### upsert

`links.upsert`

Create a link, or return and update the existing link with the same destination url; a different key renames that link's slug, so use links.update to change one specific link

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.links.upsert({ url: 'https://dub.co', domain: 'dub.sh', key: 'try' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | The destination URL of the short link. |
| `domain` | `string` | No | — |
| `key` | `string` | No | — |
| `keyLength` | `number` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `prefix` | `string` | No | — |
| `trackConversion` | `boolean` | No | — |
| `archived` | `boolean` | No | — |
| `tagIds` | `string \| string[]` | No | — |
| `tagNames` | `string \| string[]` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, string> \| null` | No | — |
| `doIndex` | `boolean` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `ref` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url: string,
>   percentage: number
> }[] | null
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `domain` | `string \| null` | No | — |
| `key` | `string \| null` | No | — |
| `url` | `string \| null` | No | — |
| `trackConversion` | `boolean \| null` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `disabledAt` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean \| null` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean \| null` | No | — |
| `doIndex` | `boolean \| null` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, any> \| null` | No | — |
| `publicStats` | `boolean \| null` | No | — |
| `tags` | `object[] \| null` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `shortLink` | `string \| null` | No | — |
| `qrCode` | `string \| null` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |
| `userId` | `string \| null` | No | — |
| `workspaceId` | `string \| null` | No | — |
| `clicks` | `number \| null` | No | — |
| `leads` | `number \| null` | No | — |
| `conversions` | `number \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `lastClicked` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `projectId` | `string \| null` | No | — |

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

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   percentage?: number | null
> }[] | null
> ```

***

## Messages

### create

`messages.create`

Send a message to a partner: send a direct message from your partner program to a partner. Until the partner replies, you can only send one message to a partner who isn't enrolled in your… (sends a message to the partner)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.messages.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to message. Takes precedence over `tenantId` if both are provided. |
| `tenantId` | `string \| null` | No | The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. |
| `text` | `string` | Yes | The text of the message. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | — |
| `text` | `string \| null` | No | — |
| `readInApp` | `string \| null` | No | — |
| `readInEmail` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `attachments` | `object[] \| null` | No | — |
| `sourceType` | `string \| null` | No | — |
| `partner` | `object \| null` | No | — |

> [accordion] attachments full type
>
> ```ts theme={null}
> {
>   name?: string | null,
>   size?: number | null,
>   type?: string | null,
>   url?: string | null
> }[] | null
> ```

> [accordion] partner full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   email?: string | null,
>   image?: string | null
> } | null
> ```

***

### list

`messages.list`

List all messages: retrieve a paginated list of direct messages between your partner program and its partners, newest first.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.messages.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string` | No | Only return messages with this partner. |
| `tenantId` | `string` | No | Only return messages with the partner that has this ID in your system. |
| `sourceType` | `partner \| program` | No | Only return messages sent by the partner (`partner`) or by your program (`program`). |
| `unread` | `boolean` | No | Only return messages that are unread (`true`) or read (`false`) by the recipient. Without `sourceType`, this returns messages from partners. |
| `endingBefore` | `string` | No | If specified, the query only searches for results before this cursor. Mutually exclusive with `startingAfter`. |
| `startingAfter` | `string` | No | If specified, the query only searches for results after this cursor. Mutually exclusive with `endingBefore`. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   text?: string | null,
>   readInApp?: string | null,
>   readInEmail?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   attachments?: {
>     name?: string | null,
>     size?: number | null,
>     type?: string | null,
>     url?: string | null
>   }[] | null,
>   sourceType?: string | null,
>   partner?: {
>     id?: string | null,
>     name?: string | null,
>     email?: string | null,
>     image?: string | null
>   } | null
> }[]
> ```

***

## Partners

### analytics

`partners.analytics`

Retrieve analytics for a partner: retrieve analytics for a partner within a program. The response type vary based on the `groupBy` query parameter.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.partners.analytics({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to create a link for. Will take precedence over `tenantId` if provided. |
| `tenantId` | `string \| null` | No | The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. |
| `interval` | `24h \| 7d \| 30d \| 90d \| 1y \| mtd \| qtd \| ytd \| all` | No | The interval to retrieve analytics for. If undefined, defaults to 24h. |
| `start` | `string` | No | The start date and time when to retrieve analytics from. If set, takes precedence over `interval`. |
| `end` | `string` | No | The end date and time when to retrieve analytics from. If not provided, defaults to the current date. If set along with `start`, takes precedence over `interval`. |
| `timezone` | `string` | No | The IANA time zone code for aligning timeseries granularity (e.g. America/New\_York). Defaults to UTC. |
| `query` | `string` | No | Search the events by a custom metadata value. Only available for lead and sale events. Examples: `metadata['key']:'value'` |
| `groupBy` | `top_links \| timeseries \| count` | No | The parameter to group the analytics data points by. Defaults to `count` if undefined. |

**Output:** `object \| object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   clicks?: number | null,
>   leads?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null,
>   earnings?: number | null
> } | {
>   start?: string | null,
>   clicks?: number | null,
>   leads?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null,
>   earnings?: number | null
> }[] | {
>   link?: string | null,
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   shortLink?: string | null,
>   url?: string | null,
>   title?: string | null,
>   comments?: string | null,
>   folderId?: string | null,
>   partnerId?: string | null,
>   createdAt?: string | null,
>   clicks?: number | null,
>   leads?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null,
>   earnings?: number | null
> }[]
> ```

***

### attributeReferringPartner

`partners.attributeReferringPartner`

Attribute a referring partner: attribute a partner to the partner who referred them. Both partners must be approved in your program, and a partner can only be attributed once. When… (can create commissions for past events)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.partners.attributeReferringPartner({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to attribute to a referring partner. Takes precedence over `tenantId` if both are provided. |
| `tenantId` | `string \| null` | No | The ID in your system of the partner to attribute to a referring partner. Either `partnerId` or `tenantId` is required. |
| `referredByPartnerId` | `string \| null` | No | The ID of the referring partner. Takes precedence over `referredByTenantId` if both are provided. |
| `referredByTenantId` | `string \| null` | No | The ID in your system of the referring partner. Either `referredByPartnerId` or `referredByTenantId` is required. |
| `createCommissionsForPastEvents` | `boolean` | No | Whether to create referral commissions for the partner's eligible past events. Skipped when the referring partner has no referral reward. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | — |
| `referredByPartnerId` | `string \| null` | No | — |

***

### ban

`partners.ban`

Ban a partner: ban a partner from your program. This will disable all links and mark all commissions as canceled. (bans the partner from the program)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.partners.ban({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to create a link for. Will take precedence over `tenantId` if provided. |
| `tenantId` | `string \| null` | No | The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. |
| `reason` | `tos_violation \| inappropriate_content \| fake_traffic \| fraud \| spam \| brand_abuse` | Yes | The reason for banning the partner. |
| `flagForFraud` | `boolean` | No | Whether to flag the partner for fraud review by the Dub team. |
| `flagForFraudReason` | `string` | No | The reason for flagging the partner for fraud. Required when flagForFraud is true. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | — |

***

### create

`partners.create`

Create or update a partner: creates a partner and enrolls them in the program. If that email is already enrolled, the enrollment is returned unchanged, except a different `tenantId`…

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.partners.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string \| null` | No | The partner's full name. If undefined, the partner's email will be used in lieu of their name (e.g. `john@acme.com`) |
| `email` | `string` | Yes | The partner's email address. Partners will be able to claim their profile by signing up at `partners.dub.co` with this email. |
| `username` | `string \| null` | No | The partner's unique username in your system (max 100 characters). This will be used to create a short link for the partner using your program's default domain. If not provided, Dub will try to… |
| `image` | `string \| null` | No | The partner's avatar image. If not provided, a default avatar will be used. |
| `tenantId` | `string` | No | The partner's unique ID in your system. Useful for retrieving the partner's links and stats later on. If not provided, the partner will be created as a standalone partner. |
| `groupId` | `string` | No | The group ID to add the partner to. If not provided, the partner will be added to the default group. |
| `tagIds` | `string[]` | No | The IDs of the partner tags to assign when creating the partner. Existing tags are kept. Takes priority over `tagNames` only when it contains at least one ID. |
| `tagNames` | `string[]` | No | The names of the partner tags to assign when creating the partner. Existing tags are kept. Ignored only when `tagIds` contains at least one ID. |
| `country` | `string \| null` | No | The partner's country of residence. Must be passed as a 2-letter ISO 3166-1 country code. See [https://d.to/geo](https://d.to/geo) for more information. |
| `description` | `string \| null` | No | A brief description of the partner and their background. Max 5,000 characters. |
| `linkProps` | `object` | No | Additional properties that you can pass to the partner's short link. Will be used to override the default link properties for this partner. |

> [accordion] linkProps full type
>
> ```ts theme={null}
> {
>   externalId?: string | null,
>   tenantId?: string | null,
>   prefix?: string,
>   archived?: boolean,
>   tagIds?: string | string[],
>   tagNames?: string | string[],
>   comments?: string | null,
>   expiresAt?: string | null,
>   expiredUrl?: string | null,
>   password?: string | null,
>   proxy?: boolean,
>   title?: string | null,
>   description?: string | null,
>   image?: string | null,
>   video?: string | null,
>   rewrite?: boolean,
>   ios?: string | null,
>   android?: string | null,
>   doIndex?: boolean,
>   testVariants?: {
>     url: string,
>     percentage: number
>   }[] | null,
>   testStartedAt?: string | null,
>   testCompletedAt?: string | null
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| null` | No | — |
| `name` | `string \| null` | No | — |
| `username` | `string \| null` | No | — |
| `email` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `country` | `string \| null` | No | — |
| `companyName` | `string \| null` | No | — |
| `networkStatus` | `string \| null` | No | — |
| `defaultPayoutMethod` | `string \| null` | No | — |
| `paypalEmail` | `string \| null` | No | — |
| `stripeConnectId` | `string \| null` | No | — |
| `payoutsEnabledAt` | `string \| null` | No | — |
| `identityVerifiedAt` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `groupId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `status` | `string \| null` | No | — |
| `links` | `object[] \| null` | No | — |
| `totalCommissions` | `number \| null` | No | — |
| `clickRewardId` | `string \| null` | No | — |
| `leadRewardId` | `string \| null` | No | — |
| `saleRewardId` | `string \| null` | No | — |
| `referralRewardId` | `string \| null` | No | — |
| `customRewardId` | `string \| null` | No | — |
| `discountId` | `string \| null` | No | — |
| `applicationId` | `string \| null` | No | — |
| `bannedAt` | `string \| null` | No | — |
| `bannedReason` | `string \| null` | No | — |
| `application` | `object \| null` | No | — |
| `tags` | `object[] \| null` | No | — |
| `totalClicks` | `number \| null` | No | — |
| `totalLeads` | `number \| null` | No | — |
| `totalConversions` | `number \| null` | No | — |
| `totalSales` | `number \| null` | No | — |
| `totalSaleAmount` | `number \| null` | No | — |
| `netRevenue` | `number \| null` | No | — |
| `earningsPerClick` | `number \| null` | No | — |
| `averageLifetimeValue` | `number \| null` | No | — |
| `clickToLeadRate` | `number \| null` | No | — |
| `clickToConversionRate` | `number \| null` | No | — |
| `leadToConversionRate` | `number \| null` | No | — |
| `returnOnAdSpend` | `number \| null` | No | — |
| `website` | `string \| null` | No | — |
| `youtube` | `string \| null` | No | — |
| `twitter` | `string \| null` | No | — |
| `linkedin` | `string \| null` | No | — |
| `instagram` | `string \| null` | No | — |
| `tiktok` | `string \| null` | No | — |
| `trustedAt` | `string \| null` | No | — |

> [accordion] links full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   shortLink?: string | null,
>   url?: string | null,
>   clicks?: number | null,
>   leads?: number | null,
>   conversions?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null
> }[] | null
> ```

> [accordion] application full type
>
> ```ts theme={null}
> {
>   rejectionReason?: string | null,
>   rejectionNote?: string | null,
>   reviewedAt?: string | null
> } | null
> ```

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

***

### createLink

`partners.createLink`

Create a link for a partner: create a link for a partner that is enrolled in your program.

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.partners.createLink({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to create a link for. Will take precedence over `tenantId` if provided. |
| `tenantId` | `string \| null` | No | The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. |
| `url` | `string \| null` | No | The URL to shorten (if not provided, the program's default URL will be used). |
| `key` | `string` | No | The short link slug. If not provided, a random 7-character slug will be generated. |
| `comments` | `string \| null` | No | The comments for the short link. |
| `linkProps` | `object` | No | Additional properties that you can pass to the partner's short link. Will be used to override the default link properties for this partner. |

> [accordion] linkProps full type
>
> ```ts theme={null}
> {
>   externalId?: string | null,
>   tenantId?: string | null,
>   prefix?: string,
>   archived?: boolean,
>   tagIds?: string | string[],
>   tagNames?: string | string[],
>   comments?: string | null,
>   expiresAt?: string | null,
>   expiredUrl?: string | null,
>   password?: string | null,
>   proxy?: boolean,
>   title?: string | null,
>   description?: string | null,
>   image?: string | null,
>   video?: string | null,
>   rewrite?: boolean,
>   ios?: string | null,
>   android?: string | null,
>   doIndex?: boolean,
>   testVariants?: {
>     url: string,
>     percentage: number
>   }[] | null,
>   testStartedAt?: string | null,
>   testCompletedAt?: string | null
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `domain` | `string \| null` | No | — |
| `key` | `string \| null` | No | — |
| `url` | `string \| null` | No | — |
| `trackConversion` | `boolean \| null` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `disabledAt` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean \| null` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean \| null` | No | — |
| `doIndex` | `boolean \| null` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, any> \| null` | No | — |
| `publicStats` | `boolean \| null` | No | — |
| `tags` | `object[] \| null` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `shortLink` | `string \| null` | No | — |
| `qrCode` | `string \| null` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |
| `userId` | `string \| null` | No | — |
| `workspaceId` | `string \| null` | No | — |
| `clicks` | `number \| null` | No | — |
| `leads` | `number \| null` | No | — |
| `conversions` | `number \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `lastClicked` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `projectId` | `string \| null` | No | — |

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

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   percentage?: number | null
> }[] | null
> ```

***

### deactivate

`partners.deactivate`

Deactivate a partner: this will deactivate the partner from your program and disable all their active links. Their commissions and payouts will remain intact. You can reactivate… (removes the partner and disables their links)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.partners.deactivate({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to create a link for. Will take precedence over `tenantId` if provided. |
| `tenantId` | `string \| null` | No | The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | — |

***

### list

`partners.list`

List all partners: list all partners for a partner program.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.partners.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `groupId` | `string` | No | A filter on the list based on the partner's `groupId` field. |
| `status` | `pending \| approved \| rejected \| invited \| declined \| deactivated \| banned \| archived` | No | A filter on the list based on the partner's `status` field. |
| `country` | `string` | No | A filter on the list based on the partner's `country` field. |
| `sortBy` | `createdAt \| totalClicks \| totalLeads \| totalConversions \| totalSaleAmount \| totalCommissions \| netRevenue \| earningsPerClick \| averageLifetimeValue \| clickToLeadRate \| clickToConversionRate \| leadToConversionRate \| returnOnAdSpend` | No | The field to sort the partners by. The default is `totalSaleAmount`. |
| `sortOrder` | `asc \| desc` | No | The sort order. The default is `desc`. |
| `email` | `string` | No | Filter the partner list based on the partner's `email`. The value must be a string. Takes precedence over `search`. |
| `tenantId` | `string` | No | Filter the partner list based on the partner's `tenantId`. The value must be a string. Combines with the other filters. |
| `search` | `string` | No | A search query to filter partners by ID, name, email, company name, description, social platforms, or referral links. Partial matches are supported. |
| `page` | `number` | No | The page number for pagination. The first page is `1`. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   username?: string | null,
>   email?: string | null,
>   image?: string | null,
>   description?: string | null,
>   country?: string | null,
>   companyName?: string | null,
>   networkStatus?: string | null,
>   defaultPayoutMethod?: string | null,
>   paypalEmail?: string | null,
>   stripeConnectId?: string | null,
>   payoutsEnabledAt?: string | null,
>   identityVerifiedAt?: string | null,
>   programId?: string | null,
>   groupId?: string | null,
>   partnerId?: string | null,
>   tenantId?: string | null,
>   createdAt?: string | null,
>   status?: string | null,
>   links?: {
>     id?: string | null,
>     domain?: string | null,
>     key?: string | null,
>     shortLink?: string | null,
>     url?: string | null,
>     clicks?: number | null,
>     leads?: number | null,
>     conversions?: number | null,
>     sales?: number | null,
>     saleAmount?: number | null
>   }[] | null,
>   totalCommissions?: number | null,
>   clickRewardId?: string | null,
>   leadRewardId?: string | null,
>   saleRewardId?: string | null,
>   referralRewardId?: string | null,
>   customRewardId?: string | null,
>   discountId?: string | null,
>   applicationId?: string | null,
>   bannedAt?: string | null,
>   bannedReason?: string | null,
>   application?: {
>     rejectionReason?: string | null,
>     rejectionNote?: string | null,
>     reviewedAt?: string | null
>   } | null,
>   tags?: {
>     id?: string | null,
>     name?: string | null
>   }[] | null,
>   totalClicks?: number | null,
>   totalLeads?: number | null,
>   totalConversions?: number | null,
>   totalSales?: number | null,
>   totalSaleAmount?: number | null,
>   netRevenue?: number | null,
>   earningsPerClick?: number | null,
>   averageLifetimeValue?: number | null,
>   clickToLeadRate?: number | null,
>   clickToConversionRate?: number | null,
>   leadToConversionRate?: number | null,
>   returnOnAdSpend?: number | null,
>   website?: string | null,
>   youtube?: string | null,
>   twitter?: string | null,
>   linkedin?: string | null,
>   instagram?: string | null,
>   tiktok?: string | null,
>   trustedAt?: string | null
> }[]
> ```

***

### listLinks

`partners.listLinks`

Retrieve a partner's links: retrieve a partner's links by their partner ID or tenant ID.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.partners.listLinks({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to create a link for. Will take precedence over `tenantId` if provided. |
| `tenantId` | `string \| null` | No | The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   shortLink?: string | null,
>   url?: string | null,
>   clicks?: number | null,
>   leads?: number | null,
>   conversions?: number | null,
>   sales?: number | null,
>   saleAmount?: number | null
> }[]
> ```

***

### listNetwork

`partners.listNetwork`

List all partners in the network: list the partners in the Dub partner network for your program. The partner network must be enabled for the program.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.partners.listNetwork({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `discover \| invited \| recruited \| ignored` | No | Filter the list of partners by their status for your program. `discover` returns the partners that are not in your program and that you have not ignored, ranked by relevance. |
| `country` | `string` | No | Filter the list of partners by country (ISO 3166-1 alpha-2). |
| `starred` | `boolean \| null` | No | Filter the list of partners by whether you starred them. Only applies to the `discover` status. |
| `sortBy` | `relevance \| subscribers` | No | The field to sort the `discover` list by. `subscribers` needs `platform`. The other statuses are sorted by the most recent action. |
| `platform` | `website \| youtube \| twitter \| linkedin \| instagram \| tiktok` | No | Only return partners with a verified profile on this platform. |
| `partnerIds` | `string \| string[]` | No | Only return the partners with these IDs (comma-separated, up to 100). |
| `page` | `number` | No | The page number for pagination. The first page is `1`. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   companyName?: string | null,
>   country?: string | null,
>   profileType?: string | null,
>   image?: string | null,
>   description?: string | null,
>   createdAt?: string | null,
>   networkStatus?: string | null,
>   monthlyTraffic?: string | null,
>   preferredEarningStructures?: string[] | null,
>   salesChannels?: string[] | null,
>   identityVerificationStatus?: string | null,
>   identityVerifiedAt?: string | null,
>   starredAt?: string | null,
>   invitedAt?: string | null,
>   ignoredAt?: string | null,
>   recruitedAt?: string | null,
>   categories?: string[] | null,
>   platforms?: {
>     type?: string | null,
>     identifier?: string | null,
>     verifiedAt?: string | null,
>     subscribers?: number | null,
>     posts?: number | null,
>     views?: number | null
>   }[] | null
> }[]
> ```

***

### updateGroup

`partners.updateGroup`

Update the group of partners: move up to 100 partners enrolled in your program into a group. They get the group's rewards and discount. Partners already in the group are skipped, unless…

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.partners.updateGroup({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerIds` | `string[]` | No | The IDs of the partners to update, up to 100. Provide either `partnerIds` or `tenantIds`, not both. |
| `tenantIds` | `string[]` | No | The tenant IDs of the partners to update, up to 100. Provide either `partnerIds` or `tenantIds`, not both. |
| `groupId` | `string` | Yes | The ID of the group to move the partners to. |
| `disableGroupMove` | `boolean` | No | Whether to stop the group's move rules from moving these partners to another group. `true` turns this on and requires an Advanced plan or above. `false` turns it off on any plan, and leaving it out… |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `count` | `number \| null` | No | — |

***

### updateTags

`partners.updateTags`

Update the tags of partners: add and remove partner tags on up to 100 partners enrolled in your program. Tags that a partner already has are not added again, and tags a partner does not…

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.partners.updateTags({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerIds` | `string[]` | No | The IDs of the partners to update, up to 100. Provide either `partnerIds` or `tenantIds`, not both. |
| `tenantIds` | `string[]` | No | The tenant IDs of the partners to update, up to 100. Provide either `partnerIds` or `tenantIds`, not both. |
| `addTagIds` | `string[]` | No | The IDs of the partner tags to add to the partners, up to 10. |
| `removeTagIds` | `string[]` | No | The IDs of the partner tags to remove from the partners, up to 10. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `added` | `number \| null` | No | — |
| `removed` | `number \| null` | No | — |

***

### upsertLink

`partners.upsertLink`

Upsert a link for a partner: upsert a link for a partner that is enrolled in your program. If a link with the same URL already exists, return it (or update it if there are any changes).…

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.partners.upsertLink({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | The ID of the partner to create a link for. Will take precedence over `tenantId` if provided. |
| `tenantId` | `string \| null` | No | The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. |
| `url` | `string` | Yes | The URL to upsert for. |
| `key` | `string` | No | The short link slug. If not provided, a random 7-character slug will be generated. |
| `comments` | `string \| null` | No | The comments for the short link. |
| `linkProps` | `object` | No | Additional properties that you can pass to the partner's short link. Will be used to override the default link properties for this partner. |

> [accordion] linkProps full type
>
> ```ts theme={null}
> {
>   externalId?: string | null,
>   tenantId?: string | null,
>   prefix?: string,
>   archived?: boolean,
>   tagIds?: string | string[],
>   tagNames?: string | string[],
>   comments?: string | null,
>   expiresAt?: string | null,
>   expiredUrl?: string | null,
>   password?: string | null,
>   proxy?: boolean,
>   title?: string | null,
>   description?: string | null,
>   image?: string | null,
>   video?: string | null,
>   rewrite?: boolean,
>   ios?: string | null,
>   android?: string | null,
>   doIndex?: boolean,
>   testVariants?: {
>     url: string,
>     percentage: number
>   }[] | null,
>   testStartedAt?: string | null,
>   testCompletedAt?: string | null
> }
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `domain` | `string \| null` | No | — |
| `key` | `string \| null` | No | — |
| `url` | `string \| null` | No | — |
| `trackConversion` | `boolean \| null` | No | — |
| `externalId` | `string \| null` | No | — |
| `tenantId` | `string \| null` | No | — |
| `programId` | `string \| null` | No | — |
| `partnerId` | `string \| null` | No | — |
| `archived` | `boolean \| null` | No | — |
| `expiresAt` | `string \| null` | No | — |
| `expiredUrl` | `string \| null` | No | — |
| `disabledAt` | `string \| null` | No | — |
| `password` | `string \| null` | No | — |
| `proxy` | `boolean \| null` | No | — |
| `title` | `string \| null` | No | — |
| `description` | `string \| null` | No | — |
| `image` | `string \| null` | No | — |
| `video` | `string \| null` | No | — |
| `rewrite` | `boolean \| null` | No | — |
| `doIndex` | `boolean \| null` | No | — |
| `ios` | `string \| null` | No | — |
| `android` | `string \| null` | No | — |
| `geo` | `Record<string, any> \| null` | No | — |
| `publicStats` | `boolean \| null` | No | — |
| `tags` | `object[] \| null` | No | — |
| `folderId` | `string \| null` | No | — |
| `comments` | `string \| null` | No | — |
| `shortLink` | `string \| null` | No | — |
| `qrCode` | `string \| null` | No | — |
| `utm_source` | `string \| null` | No | — |
| `utm_medium` | `string \| null` | No | — |
| `utm_campaign` | `string \| null` | No | — |
| `utm_term` | `string \| null` | No | — |
| `utm_content` | `string \| null` | No | — |
| `testVariants` | `object[] \| null` | No | — |
| `testStartedAt` | `string \| null` | No | — |
| `testCompletedAt` | `string \| null` | No | — |
| `userId` | `string \| null` | No | — |
| `workspaceId` | `string \| null` | No | — |
| `clicks` | `number \| null` | No | — |
| `leads` | `number \| null` | No | — |
| `conversions` | `number \| null` | No | — |
| `sales` | `number \| null` | No | — |
| `saleAmount` | `number \| null` | No | — |
| `lastClicked` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `projectId` | `string \| null` | No | — |

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

> [accordion] testVariants full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   percentage?: number | null
> }[] | null
> ```

***

## Payouts

### list

`payouts.list`

List all payouts: retrieve a paginated list of payouts for your partner program.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.payouts.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `status` | `pending \| processing \| processed \| sent \| completed \| failed \| canceled` | No | Filter the list of payouts by their corresponding status. |
| `partnerId` | `string` | No | Filter the list of payouts by the associated partner. When specified, takes precedence over `tenantId`. |
| `tenantId` | `string` | No | Filter the list of payouts by the associated partner's `tenantId` (their unique ID within your database). |
| `invoiceId` | `string` | No | Filter the list of payouts by invoice ID (the unique ID of the invoice you receive for each batch payout you process on Dub). Pending payouts will not have an invoice ID. |
| `groupId` | `string` | No | Filter the list of payouts by the associated partner group. Supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with `-`). Examples: `group_abc`,… |
| `partnerTagId` | `string` | No | Filter the list of payouts by the associated partner tag. Supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with `-`). Examples: `ptag_abc`,… |
| `sortBy` | `amount \| initiatedAt \| paidAt` | No | The field to sort the list of payouts by. |
| `sortOrder` | `asc \| desc` | No | The sort order for the list of payouts. |
| `page` | `number` | No | The page number for pagination. The first page is `1`. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   invoiceId?: string | null,
>   amount?: number | null,
>   currency?: string | null,
>   status?: string | null,
>   description?: string | null,
>   periodStart?: string | null,
>   periodEnd?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   initiatedAt?: string | null,
>   paidAt?: string | null,
>   failureReason?: string | null,
>   mode?: string | null,
>   method?: string | null,
>   traceId?: string | null,
>   partner?: {
>     id?: string | null,
>     name?: string | null,
>     email?: string | null,
>     image?: string | null,
>     defaultPayoutMethod?: string | null,
>     payoutsEnabledAt?: string | null,
>     country?: string | null,
>     networkStatus?: string | null,
>     groupId?: string | null,
>     tenantId?: string | null
>   } | null,
>   user?: {
>     id?: string | null,
>     name?: string | null,
>     email?: string | null,
>     image?: string | null
>   } | null
> }[]
> ```

***

## Program Applications

### approve

`programApplications.approve`

Approve a partner application: approve a pending partner application to your program. The partner will be enrolled in the specified group and notified of the approval. (enrolls the partner and emails them)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.programApplications.approve({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string` | Yes | The ID of the partner to approve. |
| `applicationId` | `string` | No | The ID of the application to approve. If not provided, the partner's most recent pending or rejected application is used. For a partner who is already approved in the program, only a pending… |
| `groupId` | `string \| null` | No | The ID of the group to assign the partner to. If not provided, the partner will be assigned to the group they applied to, or the program's default group if no application group is set. |
| `tagIds` | `string[]` | No | The IDs of the partner tags to assign as part of approval. Existing tags are kept. Takes priority over `tagNames` only when it contains at least one ID. |
| `tagNames` | `string[]` | No | The names of the partner tags to assign as part of approval. Existing tags are kept. Ignored only when `tagIds` contains at least one ID. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | — |

***

### list

`programApplications.list`

List all program applications: retrieve a paginated list of applications for your partner program. Filter by `status` to list pending, approved, or rejected applications.

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.programApplications.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `country` | `string` | No | A filter on the list based on the partner's `country` field. |
| `groupId` | `string` | No | A filter on the list based on the partner's `groupId` field. |
| `sortOrder` | `asc \| desc` | No | The sort order. The default is `desc`. |
| `search` | `string` | No | Filter applications by name, email, or company name. Partial matches are supported. An exact partner ID is also matched. |
| `status` | `pending \| approved \| rejected` | No | Filter applications by status. One of `pending`, `approved`, or `rejected`. Defaults to `pending`. |
| `page` | `number` | No | The page number for pagination. The first page is `1`. |
| `pageSize` | `number` | No | The number of items per page. |

**Output:** `object[]`

> [accordion] Output full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   createdAt?: string | null,
>   partner?: {
>     id?: string | null,
>     name?: string | null,
>     companyName?: string | null,
>     email?: string | null,
>     image?: string | null,
>     description?: string | null,
>     country?: string | null,
>     groupId?: string | null,
>     status?: string | null,
>     website?: string | null,
>     youtube?: string | null,
>     twitter?: string | null,
>     linkedin?: string | null,
>     instagram?: string | null,
>     tiktok?: string | null,
>     networkStatus?: string | null,
>     defaultPayoutMethod?: string | null,
>     payoutsEnabledAt?: string | null,
>     platforms?: {
>       type?: string | null,
>       identifier?: string | null,
>       verifiedAt?: string | null,
>       subscribers?: number | null,
>       posts?: number | null,
>       views?: number | null
>     }[] | null
>   } | null,
>   applicationFormData?: {
>     label?: string | null,
>     value?: string | null
>   }[] | null
> }[]
> ```

***

### reject

`programApplications.reject`

Reject a partner application: reject a pending partner application to your program. The partner will be notified via email that their application was not approved. (emails the partner)

**Risk:** `destructive`

```ts theme={null}
await corsair.dub.api.programApplications.reject({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string` | Yes | The ID of the partner to reject. |
| `rejectionReason` | `needsMoreDetail \| doesNotMeetRequirements \| notTheRightFit \| other` | No | The reason for rejecting the partner application. This will be shared with the partner via email. |
| `rejectionNote` | `string` | No | Additional details about the rejection. This will be shared with the partner via email. |
| `reapplicationTimeframe` | `instant \| standard \| never` | No | The mode for reapplying for the program. `instant`: The partner can reapply immediately. `standard`: The partner can reapply after 30 days. `never`: The partner can never reapply for the program.… |
| `flagForFraud` | `boolean` | No | Whether to flag the partner for fraud review by the Dub team. Cannot be combined with `reapplicationTimeframe: instant`. |
| `flagForFraudReason` | `string` | No | The reason for flagging the partner for fraud. Required when flagForFraud is true. |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `partnerId` | `string \| null` | No | — |

***

## Qr

### get

`qr.get`

Generate an SVG QR code for a URL; the document comes back as the svg string

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.qr.get({ url: 'https://dub.sh/try', size: 512 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string` | Yes | The URL to encode into the QR code. |
| `size` | `number` | No | — |
| `level` | `L \| M \| Q \| H` | No | — |
| `fgColor` | `string` | No | — |
| `bgColor` | `string` | No | — |
| `margin` | `number` | No | — |
| `format` | `svg` | No | SVG only. PNG is left out because it answers binary, which the plugin does not decode. |

**Output**

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

***

## Tags

### create

`tags.create`

Create a tag with an optional color

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.tags.create({ name: 'Announcement', color: 'red' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `name` | `string` | Yes | — |
| `color` | `red \| yellow \| green \| blue \| purple \| brown \| gray \| pink` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string \| null` | No | — |
| `color` | `string \| null` | No | — |

***

### delete

`tags.delete`

Permanently delete a tag and remove it from every link

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

```ts theme={null}
await corsair.dub.api.tags.delete({ id: 'tag_1KAP4C9G2F' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The ID of the tag to delete. |

**Output**

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

***

### list

`tags.list`

List tags with search, sorting and page paging

**Risk:** `read`

```ts theme={null}
await corsair.dub.api.tags.list({ search: 'ann', pageSize: 50 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `sortBy` | `name \| createdAt` | No | — |
| `sortOrder` | `asc \| desc` | No | — |
| `search` | `string` | No | — |
| `ids` | `string[]` | No | — |
| `page` | `number` | No | — |
| `pageSize` | `number` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `items` | `object[]` | Yes | — |
| `page` | `number` | Yes | — |
| `pageSize` | `number` | Yes | — |
| `nextPage` | `number \| null` | Yes | The next page while this one came back full; null once it came back short. A full last page leads to one empty page. |

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

***

### update

`tags.update`

Rename a tag or change its color

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.tags.update({ id: 'tag_1KAP4C9G2F', name: 'Launch' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | The ID of the tag to update. |
| `name` | `string` | No | — |
| `color` | `red \| yellow \| green \| blue \| purple \| brown \| gray \| pink` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | — |
| `name` | `string \| null` | No | — |
| `color` | `string \| null` | No | — |

***

## Track

### lead

`track.lead`

Record a lead conversion attributed to a click; there is no delete, so a tracked lead cannot be undone

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

```ts theme={null}
await corsair.dub.api.track.lead({ clickId: 'click_1KAP4CD1E2', eventName: 'Sign up', customerExternalId: 'ext_123456' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `clickId` | `string` | Yes | The click ID from the dub\_id cookie. An empty string asks Dub to reuse the last click of the customer. |
| `eventName` | `string` | Yes | — |
| `customerExternalId` | `string` | Yes | — |
| `customerName` | `string \| null` | No | — |
| `customerEmail` | `string \| null` | No | — |
| `customerAvatar` | `string \| null` | No | — |
| `mode` | `async \| wait \| deferred` | No | — |
| `eventQuantity` | `number \| null` | No | — |
| `metadata` | `Record<string, any> \| null` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `click` | `object \| null` | No | — |
| `link` | `object \| null` | No | — |
| `customer` | `object \| null` | No | — |

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

> [accordion] link full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   shortLink?: string | null,
>   url?: string | null,
>   partnerId?: string | null,
>   programId?: string | null,
>   tenantId?: string | null,
>   externalId?: string | null
> } | null
> ```

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   email?: string | null,
>   avatar?: string | null,
>   externalId?: string | null,
>   createdAt?: string | null
> } | null
> ```

***

### open

`track.open`

Track a deep link open event: this endpoint is used to track when a user opens your app via a Dub-powered deep link (for both iOS and Android).

**Risk:** `write`

```ts theme={null}
await corsair.dub.api.track.open({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `deepLink` | `string` | No | The deep link that brought the user to the app. If left blank, Dub will fallback to probabilistic tracking by using the `dubDomain` parameter to check if there is an associated click event for the… |
| `dubDomain` | `string` | No | Your deep link custom domain on Dub (e.g. `acme.link`). This is used in probabilistic tracking to check if there is an associated click event for the user's IP address. Learn more: [https://d.to/ddl](https://d.to/ddl) |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `clickId` | `string \| null` | No | — |
| `link` | `object \| null` | No | — |

> [accordion] link full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   domain?: string | null,
>   key?: string | null,
>   url?: string | null
> } | null
> ```

***

### sale

`track.sale`

Record a sale conversion in cents attributed to a customer; invoiceId deduplicates, but a tracked sale cannot be undone

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

```ts theme={null}
await corsair.dub.api.track.sale({ customerExternalId: 'ext_123456', amount: 4900, eventName: 'Invoice paid' });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `customerExternalId` | `string` | Yes | — |
| `amount` | `number` | Yes | The sale amount in cents, or the full integer for zero-decimal currencies. |
| `currency` | `string` | No | — |
| `eventName` | `string` | No | — |
| `paymentProcessor` | `stripe \| shopify \| polar \| paddle \| apple \| revenuecat \| lemonsqueezy \| dub \| custom` | No | — |
| `invoiceId` | `string \| null` | No | Acts as an idempotency key: only one sale is recorded per invoice ID. |
| `metadata` | `Record<string, any> \| null` | No | — |
| `leadEventName` | `string \| null` | No | — |
| `clickId` | `string \| null` | No | — |
| `customerName` | `string \| null` | No | — |
| `customerEmail` | `string \| null` | No | — |
| `customerAvatar` | `string \| null` | No | — |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `eventName` | `string \| null` | No | — |
| `customer` | `object \| null` | No | — |
| `sale` | `object \| null` | No | — |

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   name?: string | null,
>   email?: string | null,
>   avatar?: string | null,
>   externalId?: string | null,
>   createdAt?: string | null
> } | null
> ```

> [accordion] sale full type
>
> ```ts theme={null}
> {
>   amount?: number | null,
>   currency?: string | null,
>   paymentProcessor?: string | null,
>   invoiceId?: string | null,
>   metadata?: Record<string, any> | null
> } | null
> ```

***


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