Skip to content

Latest commit

 

History

History
464 lines (341 loc) · 27 KB

File metadata and controls

464 lines (341 loc) · 27 KB

Partners

Overview

Available Operations

list

List all partners for a partner program.

Example Usage

from dub import Dub
from dub.models import operations


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

    res = d_client.partners.list(request={
        "group_id": "grp_123",
        "status": operations.ListPartnersQueryParamStatus.APPROVED,
        "country": "US",
        "email": "panic@thedis.co",
        "tenant_id": "1K0NM7HCN944PEMZ3CQPH43H8",
        "search": "john",
        "page": 1,
        "page_size": 50,
    })

    # Handle response
    print(res)

Parameters

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

Response

List[operations.ListPartnersResponseBody]

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

Creates or updates a partner record (upsert behavior). If a partner with the same email already exists, their program enrollment will be updated with the provided tenantId. If no existing partner is found, a new partner will be created using the supplied information.

Example Usage

from dub import Dub


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

    res = d_client.partners.create(request={
        "email": "Summer50@yahoo.com",
        "link_props": {
            "external_id": "123456",
            "tag_ids": [
                "clux0rgak00011...",
            ],
            "test_variants": [
                {
                    "url": "https://example.com/variant-1",
                    "percentage": 50,
                },
                {
                    "url": "https://example.com/variant-2",
                    "percentage": 50,
                },
            ],
        },
    })

    # Handle response
    print(res)

Parameters

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

Response

operations.CreatePartnerResponseBody

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

retrieve_links

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

Example Usage

from dub import Dub


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

    res = d_client.partners.retrieve_links(request={})

    # Handle response
    print(res)

Parameters

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

Response

List[operations.RetrieveLinksResponseBody]

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_link

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

Example Usage

from dub import Dub


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

    res = d_client.partners.create_link(request={
        "link_props": {
            "external_id": "123456",
            "tag_ids": [
                "clux0rgak00011...",
            ],
            "test_variants": [
                {
                    "url": "https://example.com/variant-1",
                    "percentage": 50,
                },
                {
                    "url": "https://example.com/variant-2",
                    "percentage": 50,
                },
            ],
        },
    })

    # Handle response
    print(res)

Parameters

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

Response

components.LinkSchema

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

upsert_link

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). Otherwise, a new link will be created.

Example Usage

from dub import Dub


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

    res = d_client.partners.upsert_link(request={
        "url": "https://bad-intent.org/",
        "link_props": {
            "external_id": "123456",
            "tag_ids": [
                "clux0rgak00011...",
            ],
            "test_variants": [
                {
                    "url": "https://example.com/variant-1",
                    "percentage": 50,
                },
                {
                    "url": "https://example.com/variant-2",
                    "percentage": 50,
                },
            ],
        },
    })

    # Handle response
    print(res)

Parameters

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

Response

components.LinkSchema

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

analytics

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

Example Usage

from dub import Dub


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

    res = d_client.partners.analytics(request={
        "timezone": "America/New_York",
        "query": "metadata['key']:'value'",
    })

    # Handle response
    print(res)

Parameters

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

Response

operations.RetrievePartnerAnalyticsResponseBody

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

ban

Ban a partner from your program. This will disable all links and mark all commissions as canceled.

Example Usage

from dub import Dub


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

    res = d_client.partners.ban()

    # Handle response
    print(res)

Parameters

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

Response

operations.BanPartnerResponseBody

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

deactivate

This will deactivate the partner from your program and disable all their active links. Their commissions and payouts will remain intact. You can reactivate them later if needed.

Example Usage

from dub import Dub


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

    res = d_client.partners.deactivate()

    # Handle response
    print(res)

Parameters

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

Response

operations.DeactivatePartnerResponseBody

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