from portkey_ai import Portkey
# Initialize the Portkey client
portkey = Portkey(
api_key="PORTKEY_API_KEY",
)
# Update the API key
updated_api_key = portkey.api_keys.update(
id="API_KEY_ID",
name="API_KEY_NAME_0909",
rate_limits=[
{
"type": "requests",
"unit": "rpm",
"value": 100
}
],
scopes=[
"organisation_users.create", "organisation_users.read", "organisation_users.update",
"organisation_users.delete", "organisation_users.list",
"organisation_service_api_keys.create", "organisation_service_api_keys.update",
"organisation_service_api_keys.read", "organisation_service_api_keys.delete",
"organisation_service_api_keys.list", "workspaces.delete", "workspaces.create",
"workspaces.read", "workspaces.update", "workspaces.list", "logs.export",
"logs.list", "logs.view", "configs.create", "configs.update", "configs.delete",
"configs.read", "configs.list", "virtual_keys.create", "virtual_keys.update",
"virtual_keys.delete", "virtual_keys.duplicate", "virtual_keys.read",
"virtual_keys.list", "virtual_keys.copy", "workspace_service_api_keys.create",
"workspace_service_api_keys.delete", "workspace_service_api_keys.update",
"workspace_service_api_keys.read", "workspace_service_api_keys.list",
"workspace_user_api_keys.create", "workspace_user_api_keys.delete",
"workspace_user_api_keys.update", "workspace_user_api_keys.read",
"workspace_user_api_keys.list", "workspace_users.create", "workspace_users.read",
"workspace_users.update", "workspace_users.delete", "workspace_users.list",
"analytics.view"
]
)
print(updated_api_key){}Update API Key
Updates an existing API key. The API key type (user vs service) and associated user_id cannot be changed after creation.
from portkey_ai import Portkey
# Initialize the Portkey client
portkey = Portkey(
api_key="PORTKEY_API_KEY",
)
# Update the API key
updated_api_key = portkey.api_keys.update(
id="API_KEY_ID",
name="API_KEY_NAME_0909",
rate_limits=[
{
"type": "requests",
"unit": "rpm",
"value": 100
}
],
scopes=[
"organisation_users.create", "organisation_users.read", "organisation_users.update",
"organisation_users.delete", "organisation_users.list",
"organisation_service_api_keys.create", "organisation_service_api_keys.update",
"organisation_service_api_keys.read", "organisation_service_api_keys.delete",
"organisation_service_api_keys.list", "workspaces.delete", "workspaces.create",
"workspaces.read", "workspaces.update", "workspaces.list", "logs.export",
"logs.list", "logs.view", "configs.create", "configs.update", "configs.delete",
"configs.read", "configs.list", "virtual_keys.create", "virtual_keys.update",
"virtual_keys.delete", "virtual_keys.duplicate", "virtual_keys.read",
"virtual_keys.list", "virtual_keys.copy", "workspace_service_api_keys.create",
"workspace_service_api_keys.delete", "workspace_service_api_keys.update",
"workspace_service_api_keys.read", "workspace_service_api_keys.list",
"workspace_user_api_keys.create", "workspace_user_api_keys.delete",
"workspace_user_api_keys.update", "workspace_user_api_keys.read",
"workspace_user_api_keys.list", "workspace_users.create", "workspace_users.read",
"workspace_users.update", "workspace_users.delete", "workspace_users.list",
"analytics.view"
]
)
print(updated_api_key){}Documentation Index
Fetch the complete documentation index at: https://portkey-docs-feat-byteplus-provider.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Reset API key usage
Usereset_usage when you want to clear the API key’s current usage without changing other fields.
{
"reset_usage": true
}
exhausted, this reset reactivates it to active (when applicable). After the update, confirm the key reflects reset behavior in response fields such as status and last_reset_at.
Use Rotate API Key when you need a newly generated API key value while maintaining transition support for the previous key.Authorizations
Path Parameters
Body
"Development API Key"
"API key for development environment"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
{
"credit_limit": 10,
"periodic_reset": "monthly",
"alert_threshold": 8
}Whether to reset current usage. If the current status is exhausted, this will change it back to active.
true
["completions.write"]Show child attributes
Show child attributes
ISO 8601 datetime at which this key expires.
"2026-12-31T23:59:59Z"
Update or replace the automatic key rotation configuration. Requires either rotation_period or next_rotation_at.
Show child attributes
Show child attributes
Response
OK
The response is of type object.
Was this page helpful?

