(benefits)
- list - List Benefits
- create - Create Benefit
- get - Get Benefit
- update - Update Benefit
- delete - Delete Benefit
- grants - List Benefit Grants
List benefits.
Scopes: benefits:read benefits:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.benefits.list(organization_id="1dbfc517-0bbf-4301-9ba8-555ca42b9737", page=1, limit=10)
while res is not None:
# Handle items
res = res.next()| Parameter | Type | Required | Description |
|---|---|---|---|
organization_id |
OptionalNullable[models.QueryParamOrganizationIDFilter] | ➖ | Filter by organization ID. |
type_filter |
OptionalNullable[models.BenefitTypeFilter] | ➖ | Filter by benefit type. |
id |
OptionalNullable[models.FilterIDs] | ➖ | Filter by benefit IDs. |
exclude_id |
OptionalNullable[models.ExcludeIDs] | ➖ | Exclude benefits with these IDs. |
query |
OptionalNullable[str] | ➖ | Filter by description. |
page |
Optional[int] | ➖ | Page number, defaults to 1. |
limit |
Optional[int] | ➖ | Size of a page, defaults to 10. Maximum is 100. |
sorting |
List[models.BenefitSortProperty] | ➖ | Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order. |
metadata |
Dict[str, models.MetadataQuery] | ➖ | Filter by metadata key-value pairs. It uses the deepObject style, e.g. ?metadata[key]=value. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |
Create a benefit.
Scopes: benefits:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.benefits.create(request={
"type": "license_keys",
"description": "mature emergent at outside arrogantly gadzooks zealous equatorial notwithstanding",
"properties": {},
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.BenefitCreate | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |
Get a benefit by ID.
Scopes: benefits:read benefits:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.benefits.get(id="<value>")
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.ResourceNotFound | 404 | application/json |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |
Update a benefit.
Scopes: benefits:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.benefits.update(id="<value>", request_body={
"type": "custom",
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | N/A |
request_body |
models.BenefitsUpdateBenefitUpdate | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.ResourceNotFound | 404 | application/json |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |
Delete a benefit.
Warning
Every grants associated with the benefit will be revoked. Users will lose access to the benefit.
Scopes: benefits:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
polar.benefits.delete(id="<value>")
# Use the SDK ...| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | N/A |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.NotPermitted | 403 | application/json |
| models.ResourceNotFound | 404 | application/json |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |
List the individual grants for a benefit.
It's especially useful to check if a user has been granted a benefit.
Scopes: benefits:read benefits:write
from polar_sdk import Polar
with Polar(
access_token="<YOUR_BEARER_TOKEN_HERE>",
) as polar:
res = polar.benefits.grants(id="<value>", page=1, limit=10)
while res is not None:
# Handle items
res = res.next()| Parameter | Type | Required | Description |
|---|---|---|---|
id |
str | ✔️ | N/A |
is_granted |
OptionalNullable[bool] | ➖ | Filter by granted status. If true, only granted benefits will be returned. If false, only revoked benefits will be returned. |
customer_id |
OptionalNullable[models.QueryParamCustomerIDFilter] | ➖ | Filter by customer. |
member_id |
OptionalNullable[models.MemberIDFilter] | ➖ | Filter by member. |
page |
Optional[int] | ➖ | Page number, defaults to 1. |
limit |
Optional[int] | ➖ | Size of a page, defaults to 10. Maximum is 100. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.ResourceNotFound | 404 | application/json |
| models.HTTPValidationError | 422 | application/json |
| models.SDKError | 4XX, 5XX | */* |