Skip to content

Latest commit

 

History

History
213 lines (149 loc) · 13.8 KB

File metadata and controls

213 lines (149 loc) · 13.8 KB

Customers

Overview

Available Operations

  • list - List all customers
  • get - Retrieve a customer
  • delete - Delete a customer
  • update - Update a customer

list

Retrieve a paginated list of customers for the authenticated workspace.

Example Usage

from dub import Dub


with Dub(
    token="DUB_API_KEY",
) as d_client:

    res = d_client.customers.list(request={
        "ending_before": "cus_1KAP4CDPBSVMMBMH9XX3YZZ0Z",
        "starting_after": "cus_1KAP4CDPBSVMMBMH9XX3YZZ0Z",
        "page": 1,
        "page_size": 50,
    })

    while res is not None:
        # Handle items

        res = res.next()

Parameters

Parameter Type Required Description
request operations.GetCustomersRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetCustomersResponse

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

from dub import Dub


with Dub(
    token="DUB_API_KEY",
) as d_client:

    res = d_client.customers.get(request={
        "id": "<id>",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request operations.GetCustomerRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.GetCustomerResponseBody

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

from dub import Dub


with Dub(
    token="DUB_API_KEY",
) as d_client:

    res = d_client.customers.delete(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ 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).
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.DeleteCustomerResponseBody

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

from dub import Dub


with Dub(
    token="DUB_API_KEY",
) as d_client:

    res = d_client.customers.update(request={
        "id": "<id>",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request operations.UpdateCustomerRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

operations.UpdateCustomerResponseBody

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 */*