get

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

res = s.keys.get(key_id="key_1234")

if res.key is not None:
    # handle response
    pass

Parameters

ParameterTypeRequiredDescriptionExample
key_idstr:heavy_check_mark:N/Akey_1234
decryptOptionalNullable[bool]:heavy_minus_sign:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.GetKeyResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

whoami

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

res = s.keys.whoami(request={
    "key": "sk_123",
})

if res.object is not None:
    # handle response
    pass

Parameters

ParameterTypeRequiredDescription
requestmodels.WhoamiRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.WhoamiResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

delete

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

res = s.keys.delete(request={
    "key_id": "key_1234",
})

if res.object is not None:
    # handle response
    pass

Parameters

ParameterTypeRequiredDescription
requestmodels.DeleteKeyRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.DeleteKeyResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

create

Example Usage

import os
import unkey
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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.CreateKeyInterval.DAILY,
        "amount": 100,
    },
    "ratelimit": {
        "limit": 10,
        "type": unkey.CreateKeyType.FAST,
        "duration": 60000,
    },
    "enabled": False,
})

if res.object is not None:
    # handle response
    pass

Parameters

ParameterTypeRequiredDescription
requestmodels.CreateKeyRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.CreateKeyResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

verify

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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

Parameters

ParameterTypeRequiredDescription
requestmodels.V1KeysVerifyKeyRequest:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.VerifyKeyResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

update

Example Usage

import os
import unkey
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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.UpdateKeyType.FAST,
        "refill_rate": 1,
        "refill_interval": 60,
    },
    "remaining": 1000,
    "refill": {
        "interval": unkey.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

Parameters

ParameterTypeRequiredDescription
requestmodels.UpdateKeyRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.UpdateKeyResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

update_remaining

Example Usage

import os
import unkey
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

res = s.keys.update_remaining(request={
    "key_id": "key_123",
    "op": unkey.Op.SET,
    "value": 1,
})

if res.object is not None:
    # handle response
    pass

Parameters

ParameterTypeRequiredDescription
requestmodels.UpdateRemainingRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.UpdateRemainingResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

get_verifications

Example Usage

import os
import unkey
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

res = s.keys.get_verifications(request={
    "key_id": "key_1234",
    "owner_id": "chronark",
    "start": 1620000000000,
    "end": 1620000000000,
    "granularity": unkey.Granularity.DAY,
})

if res.object is not None:
    # handle response
    pass

Parameters

ParameterTypeRequiredDescription
requestmodels.GetVerificationsRequest:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.GetVerificationsResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

add_permissions

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

res = s.keys.add_permissions(request={
    "key_id": "<id>",
    "permissions": [
        {},
    ],
})

if res.response_bodies is not None:
    # handle response
    pass

Parameters

ParameterTypeRequiredDescription
requestmodels.AddPermissionsRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.AddPermissionsResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

remove_permissions

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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

Parameters

ParameterTypeRequiredDescription
requestmodels.RemovePermissionsRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.RemovePermissionsResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

set_permissions

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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

Parameters

ParameterTypeRequiredDescription
requestmodels.SetPermissionsRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.SetPermissionsResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

add_roles

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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

Parameters

ParameterTypeRequiredDescription
requestmodels.AddRolesRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.AddRolesResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

remove_roles

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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

Parameters

ParameterTypeRequiredDescription
requestmodels.RemoveRolesRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.RemoveRolesResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

set_roles

Example Usage

import os
from unkey_py import Unkey

s = Unkey(
    bearer_auth=os.getenv("UNKEY_BEARER_AUTH", ""),
)

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

Parameters

ParameterTypeRequiredDescription
requestmodels.SetRolesRequestBody:heavy_check_mark:The request object to use for the request.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.SetRolesResponse

Errors

Error TypeStatus CodeContent Type
models.ErrBadRequest400application/json
models.ErrUnauthorized401application/json
models.ErrForbidden403application/json
models.ErrNotFound404application/json
models.ErrConflict409application/json
models.ErrTooManyRequests429application/json
models.ErrInternalServerError500application/json
models.SDKError4XX, 5XX*/*

Was this page helpful?