(keys)
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.get(key_id="key_1234")
if res.key is not None:
# handle response
pass
Parameter |
Type |
Required |
Description |
Example |
key_id |
str |
✔️ |
N/A |
key_1234 |
decrypt |
OptionalNullable[bool] |
➖ |
N/A |
|
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
|
models.GetKeyResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.whoami(request={
"key": "sk_123",
})
if res.object is not None:
# handle response
pass
models.WhoamiResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.delete(request={
"key_id": "key_1234",
})
if res.object is not None:
# handle response
pass
models.DeleteKeyResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
import unkey_py
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.create(request={
"api_id": "api_123",
"name": "my key",
"external_id": "team_123",
"meta": {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z",
},
"roles": [
"admin",
"finance",
],
"permissions": [
"domains.create_record",
"say_hello",
],
"expires": 1623869797161,
"remaining": 1000,
"refill": {
"interval": unkey_py.CreateKeyInterval.MONTHLY,
"amount": 100,
"refill_day": 15,
},
"ratelimit": {
"limit": 10,
"type": unkey_py.CreateKeyType.FAST,
"duration": 60000,
},
"enabled": False,
})
if res.object is not None:
# handle response
pass
models.CreateKeyResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.verify(request={
"key": "sk_1234",
"api_id": "api_1234",
"ratelimits": [
{
"name": "tokens",
"limit": 500,
"duration": 3600000,
},
{
"name": "tokens",
"limit": 20000,
"duration": 86400000,
},
],
})
if res.v1_keys_verify_key_response is not None:
# handle response
pass
models.VerifyKeyResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
import unkey_py
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.update(request={
"key_id": "key_123",
"name": "Customer X",
"external_id": "user_123",
"meta": {
"roles": [
"admin",
"user",
],
"stripeCustomerId": "cus_1234",
},
"expires": 0,
"ratelimit": {
"limit": 10,
"type": unkey_py.UpdateKeyType.FAST,
"refill_rate": 1,
"refill_interval": 60,
},
"remaining": 1000,
"refill": {
"interval": unkey_py.UpdateKeyInterval.DAILY,
"amount": 100,
},
"enabled": True,
"roles": [
{
"id": "perm_123",
},
{
"name": "dns.record.create",
},
{
"name": "dns.record.delete",
"create": True,
},
],
"permissions": [
{
"id": "perm_123",
},
{
"name": "dns.record.create",
},
{
"name": "dns.record.delete",
"create": True,
},
],
})
if res.object is not None:
# handle response
pass
models.UpdateKeyResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
import unkey_py
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.update_remaining(request={
"key_id": "key_123",
"op": unkey_py.Op.SET,
"value": 1,
})
if res.object is not None:
# handle response
pass
models.UpdateRemainingResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
import unkey_py
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.get_verifications(request={
"key_id": "key_1234",
"owner_id": "chronark",
"start": 1620000000000,
"end": 1620000000000,
"granularity": unkey_py.Granularity.DAY,
})
if res.object is not None:
# handle response
pass
models.GetVerificationsResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.add_permissions(request={
"key_id": "<id>",
"permissions": [
{},
],
})
if res.response_bodies is not None:
# handle response
pass
models.AddPermissionsResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.remove_permissions(request={
"key_id": "<id>",
"permissions": [
{
"id": "perm_123",
},
{
"name": "dns.record.create",
},
],
})
if res.object is not None:
# handle response
pass
models.RemovePermissionsResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.set_permissions(request={
"key_id": "<id>",
"permissions": [
{
"id": "perm_123",
},
{
"name": "dns.record.create",
},
{
"name": "dns.record.delete",
"create": True,
},
],
})
if res.response_bodies is not None:
# handle response
pass
models.SetPermissionsResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.add_roles(request={
"key_id": "<id>",
"roles": [
{
"id": "role_123",
},
{
"name": "dns.record.create",
},
{
"name": "dns.record.delete",
"create": True,
},
],
})
if res.response_bodies is not None:
# handle response
pass
models.AddRolesResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.remove_roles(request={
"key_id": "<id>",
"roles": [
{
"id": "role_123",
},
{
"name": "dns.record.create",
},
],
})
if res.object is not None:
# handle response
pass
models.RemoveRolesResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |
from unkey_py import Unkey
with Unkey(
bearer_auth="UNKEY_ROOT_KEY",
) as s:
res = s.keys.set_roles(request={
"key_id": "<id>",
"roles": [
{
"id": "role_123",
},
{
"name": "dns.record.create",
},
{
"name": "dns.record.delete",
"create": True,
},
],
})
if res.response_bodies is not None:
# handle response
pass
models.SetRolesResponse
Error Type |
Status Code |
Content Type |
models.ErrBadRequest |
400 |
application/json |
models.ErrUnauthorized |
401 |
application/json |
models.ErrForbidden |
403 |
application/json |
models.ErrNotFound |
404 |
application/json |
models.ErrConflict |
409 |
application/json |
models.ErrTooManyRequests |
429 |
application/json |
models.ErrInternalServerError |
500 |
application/json |
models.SDKError |
4XX, 5XX |
*/* |