# Customers ## Overview ### Available Operations * [list](#list) - List all customers * [get](#get) - Retrieve a customer * [delete](#delete) - Delete a customer * [update](#update) - Update a customer ## list Retrieve a paginated list of customers for the authenticated workspace. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.customers.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 { customersList } from "dub/funcs/customersList.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 customersList(dub); if (res.ok) { const { value: result } = res; for await (const page of result) { console.log(page); } } else { console.log("customersList failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.GetCustomersRequest](../../models/operations/getcustomersrequest.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.GetCustomersResponse](../../models/operations/getcustomersresponse.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 | \*/\* | ## get Retrieve a customer by ID for the authenticated workspace. To retrieve a customer by external ID, prefix the ID with `ext_`. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.customers.get({ id: "", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { customersGet } from "dub/funcs/customersGet.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 customersGet(dub, { id: "", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("customersGet failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.GetCustomerRequest](../../models/operations/getcustomerrequest.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.GetCustomerResponseBody](../../models/operations/getcustomerresponsebody.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 | \*/\* | ## delete Delete a customer from a workspace. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.customers.delete(""); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { customersDelete } from "dub/funcs/customersDelete.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 customersDelete(dub, ""); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("customersDelete failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `id` | *string* | :heavy_check_mark: | The unique ID of the customer. You may use either the customer's `id` on Dub (obtained via `/customers` endpoint) or their `externalId` (unique ID within your system, prefixed with `ext_`, e.g. `ext_123`). | | `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.DeleteCustomerResponseBody](../../models/operations/deletecustomerresponsebody.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 a customer for the authenticated workspace. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.customers.update({ id: "", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { customersUpdate } from "dub/funcs/customersUpdate.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 customersUpdate(dub, { id: "", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("customersUpdate failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.UpdateCustomerRequest](../../models/operations/updatecustomerrequest.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.UpdateCustomerResponseBody](../../models/operations/updatecustomerresponsebody.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 | \*/\* |