API keys

envless.keys.get()

Read one API key by id

ts
get(id: string, options?: RequestScope): Promise<KeyResource>

Resolves 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

ts
const key = await envless.keys.get('0191f3c2-8a71-7c3e-9b2d-4f5a6c7d8e90')

console.log(key.scopes, key.projectIds, key.lastUsedAt)

Parameters

ParameterTypeRequiredDescription
idstringYesThe key id, ids only, no prefix and no slug form.
options.signalAbortSignalNoCancels the request.

Returns

KeyResource with prefix, effective scopes, projectIds, active and lastUsedAt.

Worth knowing

  • A key that delete has already revoked returns 404 key.not_found, so a 404 here is a reliable revoked signal.
  • lastUsedAt is null for 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 Python

envless.keys.get()

The same method in envless-sdk, the Python SDK, with the same request, retries and errors.

In Ruby

Envless.keys.get

The same method in envless-sdk, the Ruby gem, with the same request, retries and errors.

In PHP

$envless->keys->get()

The same method in envless/sdk, the PHP SDK, with the same request, retries and errors.