# Commissions ## Overview ### Available Operations * [list](#list) - List all commissions * [create](#create) - Create commission * [update](#update) - Update a commission * [updateMany](#updatemany) - Bulk update commissions ## list Retrieve a paginated list of commissions for your partner program. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.commissions.list(); for await (const page of result) { console.log(page); } } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { commissionsList } from "dub/funcs/commissionsList.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await commissionsList(dub); if (res.ok) { const { value: result } = res; for await (const page of result) { console.log(page); } } else { console.log("commissionsList failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.ListCommissionsRequest](../../models/operations/listcommissionsrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.ListCommissionsResponse](../../models/operations/listcommissionsresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequest | 400 | application/json | | errors.Unauthorized | 401 | application/json | | errors.Forbidden | 403 | application/json | | errors.NotFound | 404 | application/json | | errors.Conflict | 409 | application/json | | errors.InviteExpired | 410 | application/json | | errors.UnprocessableEntity | 422 | application/json | | errors.RateLimitExceeded | 429 | application/json | | errors.InternalServerError | 500 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## create Create one or more commissions (custom, lead or sale) for a partner. Commission creation is processed asynchronously. Use the List Commissions endpoint or webhooks to be notified when the commission is created. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.commissions.create(); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { commissionsCreate } from "dub/funcs/commissionsCreate.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await commissionsCreate(dub); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("commissionsCreate failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.CreateCommissionRequestBody](../../models/operations/createcommissionrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.CreateCommissionResponseBody](../../models/operations/createcommissionresponsebody.md)\>** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequest | 400 | application/json | | errors.Unauthorized | 401 | application/json | | errors.Forbidden | 403 | application/json | | errors.NotFound | 404 | application/json | | errors.Conflict | 409 | application/json | | errors.InviteExpired | 410 | application/json | | errors.UnprocessableEntity | 422 | application/json | | errors.RateLimitExceeded | 429 | application/json | | errors.InternalServerError | 500 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## update Update an existing commission amount. This is useful for handling refunds (partial or full) or fraudulent sales. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.commissions.update({ id: "cm_1JVR7XRCSR0EDBAF39FZ4PMYE", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { commissionsUpdate } from "dub/funcs/commissionsUpdate.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await commissionsUpdate(dub, { id: "cm_1JVR7XRCSR0EDBAF39FZ4PMYE", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("commissionsUpdate failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.UpdateCommissionRequest](../../models/operations/updatecommissionrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.UpdateCommissionResponseBody](../../models/operations/updatecommissionresponsebody.md)\>** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequest | 400 | application/json | | errors.Unauthorized | 401 | application/json | | errors.Forbidden | 403 | application/json | | errors.NotFound | 404 | application/json | | errors.Conflict | 409 | application/json | | errors.InviteExpired | 410 | application/json | | errors.UnprocessableEntity | 422 | application/json | | errors.RateLimitExceeded | 429 | application/json | | errors.InternalServerError | 500 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | ## updateMany Bulk update up to 100 commissions with the same status. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.commissions.updateMany(); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { commissionsUpdateMany } from "dub/funcs/commissionsUpdateMany.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await commissionsUpdateMany(dub); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("commissionsUpdateMany failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.BulkUpdateCommissionsRequestBody](../../models/operations/bulkupdatecommissionsrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.BulkUpdateCommissionsResponseBody[]](../../models/.md)\>** ### Errors | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequest | 400 | application/json | | errors.Unauthorized | 401 | application/json | | errors.Forbidden | 403 | application/json | | errors.NotFound | 404 | application/json | | errors.Conflict | 409 | application/json | | errors.InviteExpired | 410 | application/json | | errors.UnprocessableEntity | 422 | application/json | | errors.RateLimitExceeded | 429 | application/json | | errors.InternalServerError | 500 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* |