def get(
id: str,
*,
timeout: float | None = None,
) -> KeyResourceasync def get(
id: str,
*,
timeout: float | None = None,
) -> KeyResourceReturns a single key. Read it before you revoke something you believe is unused: active tells you whether it is currently enabled, scopes is the effective map after clamping rather than what was requested, projectIds is the project fence, and lastUsedAt is the only evidence of live traffic.
id is the key id from a list call or from create. It is not the prefix and not the secret, and keys have no slug form, so a prefix passed here produces a 404 rather than a validation error.
The secret is never returned, on this route or any other. If the plaintext is lost the key is unrecoverable and the only path forward is to create a replacement and delete this one.
Example
from envless import envless
key = envless.keys.get('0191f3c2-8a71-7c3e-9b2d-4f5a6c7d8e90')
print(key['scopes'], key['projectIds'], key['lastUsedAt'])import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
key = await envless.keys.get('0191f3c2-8a71-7c3e-9b2d-4f5a6c7d8e90')
print(key['scopes'], key['projectIds'], key['lastUsedAt'])
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | str | Yes | The key id, ids only, no prefix and no slug form. |
timeout | float | No | Seconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
KeyResource with prefix, effective scopes, projectIds, active and lastUsedAt.
Worth knowing
- A key that
deletehas already revoked returns 404key.not_found, so a 404 here is a reliable revoked signal. lastUsedAtisNonefor a key that has never authenticated a request.
Required scopes
keys:read
Underlying endpoint
GET /keys/{id}
Request and response schema, every error code, and a live playground.
In TypeScript
envless.keys.get()
The same method in @goenvless/sdk, with the same request, retries and errors.