(benefits )
List benefits.
from polar_sdk import Polar
with Polar (
access_token = "<YOUR_BEARER_TOKEN_HERE>" ,
) as polar :
res = polar .benefits .list ()
while res is not None :
# Handle items
res = res .next ()
models.BenefitsListResponse
Error Type
Status Code
Content Type
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*
Create a benefit.
from polar_sdk import Polar
with Polar (
access_token = "<YOUR_BEARER_TOKEN_HERE>" ,
) as polar :
res = polar .benefits .create (request = {
"description" : "delightfully fumigate convection though zowie up bulky electronics" ,
"properties" : {
"guild_token" : "<value>" ,
"role_id" : "<id>" ,
},
"type" : "discord" ,
})
# Handle response
print (res )
models.Benefit
Error Type
Status Code
Content Type
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*
Get a benefit by ID.
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.
models.Benefit
Error Type
Status Code
Content Type
models.ResourceNotFound
404
application/json
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*
Update a benefit.
from polar_sdk import Polar
with Polar (
access_token = "<YOUR_BEARER_TOKEN_HERE>" ,
) as polar :
res = polar .benefits .update (id = "<value>" , request_body = {
"type" : "license_keys" ,
})
# Handle response
print (res )
models.Benefit
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
*/*
Delete a benefit.
Warning
Every grants associated with the benefit will be revoked.
Users will lose access to the benefit.
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.
from polar_sdk import Polar
with Polar (
access_token = "<YOUR_BEARER_TOKEN_HERE>" ,
) as polar :
res = polar .benefits .grants (id = "<value>" )
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.
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.
models.BenefitsGrantsResponse
Error Type
Status Code
Content Type
models.ResourceNotFound
404
application/json
models.HTTPValidationError
422
application/json
models.SDKError
4XX, 5XX
*/*