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

# Payhip API reference

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

## Coupons

### create

`coupons.create`

Create a discount coupon for one product, all products or a collection

**Risk:** `write`

```ts theme={null}
await corsair.payhip.api.coupons.create({ code: "example123", coupon_type: "multi", percent_off: 20, usage_limit: 100 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `code` | `string` | Yes | Code the customer enters at checkout |
| `coupon_type` | `single \| multi \| collection` | Yes | What the coupon applies to |
| `percent_off` | `number` | No | Percentage discount; required unless amount\_off is passed |
| `amount_off` | `number` | No | Fixed discount in cents; required unless percent\_off is passed |
| `product_key` | `string` | No | Product key; required when coupon\_type is single |
| `collection_id` | `string` | No | Collection id; required when coupon\_type is collection |
| `start_date` | `string` | No | When the coupon becomes valid |
| `end_date` | `string` | No | When the coupon expires |
| `minimum_purchase_amount` | `number` | No | Minimum cart total in cents before redemption |
| `usage_limit` | `number` | No | Maximum redemptions |
| `notes` | `string` | No | Administrative note, not visible to customers |

Exactly one of percent\_off (0-100) or amount\_off (cents) is required; coupon\_type single needs product\_key, collection needs collection\_id. Subscriptions priced with a recurring amount cannot be discounted through the API yet.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | A Payhip coupon |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: number,
>   code?: string | null,
>   coupon_type?: single | multi | collection | string | null,
>   percent_off?: number | null,
>   amount_off?: number | null,
>   start_date?: string | null,
>   end_date?: string | null,
>   product_key?: string | null,
>   collection_id?: string | null,
>   minimum_purchase_amount?: number | null,
>   usage_limit?: number | null,
>   notes?: string | null
> }
> ```

***

### get

`coupons.get`

Read one coupon by id

**Risk:** `read`

```ts theme={null}
await corsair.payhip.api.coupons.get({ couponId: 1495522137 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `couponId` | `number` | Yes | Coupon id |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | A Payhip coupon |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   id: number,
>   code?: string | null,
>   coupon_type?: single | multi | collection | string | null,
>   percent_off?: number | null,
>   amount_off?: number | null,
>   start_date?: string | null,
>   end_date?: string | null,
>   product_key?: string | null,
>   collection_id?: string | null,
>   minimum_purchase_amount?: number | null,
>   usage_limit?: number | null,
>   notes?: string | null
> }
> ```

***

### list

`coupons.list`

List the coupons of the account, paged by limit and offset

**Risk:** `read`

```ts theme={null}
await corsair.payhip.api.coupons.list({ limit: 10, offset: 0 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `limit` | `number` | No | Results per page |
| `offset` | `number` | No | Offset of the first result |

Paged with limit and offset.

**Output**

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

> [accordion] data full type
>
> ```ts theme={null}
> {
>   coupons: {
>     id: number,
>     code?: string | null,
>     coupon_type?: single | multi | collection | string | null,
>     percent_off?: number | null,
>     amount_off?: number | null,
>     start_date?: string | null,
>     end_date?: string | null,
>     product_key?: string | null,
>     collection_id?: string | null,
>     minimum_purchase_amount?: number | null,
>     usage_limit?: number | null,
>     notes?: string | null
>   }[]
> }
> ```

***

## License

### decreaseUsage

`license.decreaseUsage`

Decrease the usage count of a license key (a deactivation)

**Risk:** `write`

```ts theme={null}
await corsair.payhip.api.license.decreaseUsage({ license_key: "WTKP4-66NL5-HMKQW-GFSCZ" });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `license_key` | `string` | Yes | The license key to change |

Decrements the uses counter (a deactivation). The docs' endpoint list names /license/decrease while the example reuses /license/usage; see the overview note.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | A Payhip license key |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   license_key: string,
>   enabled: boolean,
>   product_link?: string | null,
>   product_name?: string | null,
>   variant_name?: string | null,
>   variant_id?: string | null,
>   buyer_email?: string | null,
>   uses?: number | null,
>   date?: string | null
> }
> ```

***

### disable

`license.disable`

Disable a license key so it stops validating

**Risk:** `write`

```ts theme={null}
await corsair.payhip.api.license.disable({ license_key: "WTKP4-66NL5-HMKQW-GFSCZ" });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `license_key` | `string` | Yes | The license key to change |

Payhip disables a license key automatically when a purchase is refunded.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | A Payhip license key |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   license_key: string,
>   enabled: boolean,
>   product_link?: string | null,
>   product_name?: string | null,
>   variant_name?: string | null,
>   variant_id?: string | null,
>   buyer_email?: string | null,
>   uses?: number | null,
>   date?: string | null
> }
> ```

***

### enable

`license.enable`

Enable a license key that was disabled

**Risk:** `write`

```ts theme={null}
await corsair.payhip.api.license.enable({ license_key: "WTKP4-66NL5-HMKQW-GFSCZ" });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `license_key` | `string` | Yes | The license key to change |

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | A Payhip license key |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   license_key: string,
>   enabled: boolean,
>   product_link?: string | null,
>   product_name?: string | null,
>   variant_name?: string | null,
>   variant_id?: string | null,
>   buyer_email?: string | null,
>   uses?: number | null,
>   date?: string | null
> }
> ```

***

### increaseUsage

`license.increaseUsage`

Increase the usage count of a license key (an activation)

**Risk:** `write`

```ts theme={null}
await corsair.payhip.api.license.increaseUsage({ license_key: "WTKP4-66NL5-HMKQW-GFSCZ" });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `license_key` | `string` | Yes | The license key to change |

Increments the uses counter (an activation).

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | A Payhip license key |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   license_key: string,
>   enabled: boolean,
>   product_link?: string | null,
>   product_name?: string | null,
>   variant_name?: string | null,
>   variant_id?: string | null,
>   buyer_email?: string | null,
>   uses?: number | null,
>   date?: string | null
> }
> ```

***

### verify

`license.verify`

Verify a license key against a product secret; read-only check

**Risk:** `read`

```ts theme={null}
await corsair.payhip.api.license.verify({ license_key: "WTKP4-66NL5-HMKQW-GFSCZ" });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `license_key` | `string` | Yes | The license key to verify |

Answers the license key with enabled, uses, buyer\_email and product fields.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `data` | `object` | Yes | A Payhip license key |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   license_key: string,
>   enabled: boolean,
>   product_link?: string | null,
>   product_name?: string | null,
>   variant_name?: string | null,
>   variant_id?: string | null,
>   buyer_email?: string | null,
>   uses?: number | null,
>   date?: string | null
> }
> ```

***


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