API keys

envless.keys.delete()

Revoke an API key permanently

ts
delete(id: string, options?: RequestScope): Promise<DeletedKeyResource>

Revokes a key. The effect is immediate: the next request presenting that secret gets 401. The row is soft-deleted, so the key disappears from list, returns 404 from get, and the id is never reused.

There is no undelete, and the secret was never recoverable in the first place, so ordering matters when you are replacing something that is live. Create the replacement first, deploy it everywhere, confirm lastUsedAt on the old key has stopped advancing, and only then revoke. That sequence gives you an overlap window that an in place rotate would not.

A key cannot revoke itself. Passing the id of the key making the request fails with 409 auth.self_mutation_forbidden, so any automated cleanup has to run under a different credential.

Example

ts
const replacement = await envless.keys.create({ name: 'ci-deploy-next', scopes: { variables: 'read' } })

console.log(replacement.prefix)

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

console.log(revoked.name)

Parameters

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

Returns

DeletedKeyResource with the id and name of the revoked key.

Worth knowing

  • The response has no deleted boolean. That shape belongs to webhooks.delete.
  • Revoking an already revoked key returns 404 key.not_found, so the call is not idempotent.
  • Emits key.deleted to any webhook endpoint subscribed to it.

Required scopes

keys:write

Underlying endpoint

DELETE /keys/{id}

Request and response schema, every error code, and a live playground.

In Python

envless.keys.delete()

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

In Ruby

Envless.keys.delete

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

In PHP

$envless->keys->delete()

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