(jwt_templates)
- list - List all templates
- create - Create a JWT template
- get - Retrieve a template
- update - Update a JWT template
- delete - Delete a Template
List all templates
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.jwt_templates.list(paginated=False)
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
paginated |
Optional[bool] | ➖ | Whether to paginate the results. If true, the results will be paginated. If false, the results will not be paginated. |
|
limit |
Optional[int] | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
20 |
offset |
Optional[int] | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit . |
10 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.SDKError | 4XX, 5XX | */* |
Create a new JWT template
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.jwt_templates.create(request={
"name": "Example Template",
"claims": {},
"lifetime": 3600,
"allowed_clock_skew": 5,
"custom_signing_key": False,
"signing_algorithm": "RS256",
"signing_key": "PRIVATE_KEY_PLACEHOLDER",
})
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
request |
models.CreateJWTTemplateRequestBody | ✔️ | 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.ClerkErrors | 400, 402, 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Retrieve the details of a given JWT template
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.jwt_templates.get(template_id="template_123")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
template_id |
str | ✔️ | JWT Template ID | template_123 |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 404 | application/json |
models.SDKError | 4XX, 5XX | */* |
Updates an existing JWT template
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.jwt_templates.update(template_id="<id>", name="<value>", claims={}, lifetime=8574.78, allowed_clock_skew=5971.29, custom_signing_key=True, signing_algorithm="<value>", signing_key="<value>")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
template_id |
str | ✔️ | The ID of the JWT template to update |
name |
str | ✔️ | JWT template name |
claims |
models.UpdateJWTTemplateClaims | ✔️ | JWT template claims in JSON format |
lifetime |
OptionalNullable[float] | ➖ | JWT token lifetime |
allowed_clock_skew |
OptionalNullable[float] | ➖ | JWT token allowed clock skew |
custom_signing_key |
Optional[bool] | ➖ | Whether a custom signing key/algorithm is also provided for this template |
signing_algorithm |
OptionalNullable[str] | ➖ | The custom signing algorithm to use when minting JWTs. Required if custom_signing_key is true . |
signing_key |
OptionalNullable[str] | ➖ | The custom signing private key to use when minting JWTs. Required if custom_signing_key is true . |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 400, 402, 422 | application/json |
models.SDKError | 4XX, 5XX | */* |
Delete a Template
from clerk_backend_api import Clerk
with Clerk(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as clerk:
res = clerk.jwt_templates.delete(template_id="<id>")
assert res is not None
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
template_id |
str | ✔️ | JWT Template ID |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
Error Type | Status Code | Content Type |
---|---|---|
models.ClerkErrors | 403, 404 | application/json |
models.SDKError | 4XX, 5XX | */* |