List all partners for a partner program.
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)
List[operations.ListPartnersResponseBody]
| 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 |
*/* |
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.
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)
operations.CreatePartnerResponseBody
| 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 a partner's links by their partner ID or tenant ID.
from dub import Dub
with Dub(
token="DUB_API_KEY",
) as d_client:
res = d_client.partners.retrieve_links(request={})
# Handle response
print(res)
List[operations.RetrieveLinksResponseBody]
| 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 a link for a partner that is enrolled in your program.
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)
components.LinkSchema
| 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 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.
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)
components.LinkSchema
| 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 analytics for a partner within a program. The response type vary based on the groupBy query parameter.
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)
operations.RetrievePartnerAnalyticsResponseBody
| 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 a partner from your program. This will disable all links and mark all commissions as canceled.
from dub import Dub
with Dub(
token="DUB_API_KEY",
) as d_client:
res = d_client.partners.ban()
# Handle response
print(res)
operations.BanPartnerResponseBody
| 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 |
*/* |
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.
from dub import Dub
with Dub(
token="DUB_API_KEY",
) as d_client:
res = d_client.partners.deactivate()
# Handle response
print(res)
operations.DeactivatePartnerResponseBody
| 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 |
*/* |