Index of every page on this site: llms.txt
All skills
tkhq avatar

/revoking-agent-keys

@6fd5c16
by Turnkeytkhq/tk72 stars
3
Run it yourself

Revoke a Turnkey agent's API key before it expires with tk through a non-root revoker user scoped to an explicit set of agent users. Use when you want to revoke a key after a scoped task is complete or when a credential may have leaked; not for routine key rotation or for deleting a whole user.

  • 1 file
  • 5.6 KB
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/tkhq/tk/revoking-agent-keys

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈79 tokens for metadata: the name and description. ≈1.3k when used: this file.

Description uses 4.0% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈317 characters, or 4.0%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Revoking agent keys

Expiry is the main control on an agent's key. Turnkey does not know when a task ends, so nothing revokes a key on its own; api-key delete revokes it at once. Revoke through a scoped revoker user, never with root: root signs only to create the revoker and its policy.

Reference

  • resources: user, user tag, api-key, and policy create records and flags.
  • authentication: profile create and whoami records.
  • activities: activity get and policy evaluations on a refused or pending delete.

Rules

  • Deleting a local key file revokes nothing. Only api-key delete does.
  • Turnkey keeps one permanent credential per user. Deleting a user's last non-expiring key fails with api_error 400. A session agent keeps its anchor key, so deleting its session key succeeds. To cut a user off entirely, delete the user with managing-identities.
  • Policy sees activity.params.user_id and activity.params.api_key_ids on ACTIVITY_TYPE_DELETE_API_KEYS, not the target's tags. The revoker ALLOW lists every target user id; resolve each with user get before writing it. Never list a root-quorum user.
  • The revoker carries only the revoker tag. Deleting a key is a CREDENTIAL activity, so the credential DENY on the agent, broker, or provisioner tag overrides the revoker ALLOW.
  • A leaked revoker credential can delete keys on the listed users and do nothing else: no signing, minting, or export.

Instructions

Inputs: the root profile (admin), AGENT_USER_ID for each agent user to cover (one quoted entry each in the in [...] list), and the host that runs the revoker.

  1. Create the revoker's profile and tag. On the revoker host, generate its credential and send data.publicKey (PUBLIC_KEY) to root:

    <!-- example: revoking.profile-create -->
    tk --message-format json --organization-id ORG_UUID profile create --profile-name revoker

    Root creates the tag and sets REVOKER_TAG to data.activity.result.createUserTagResult.userTagId:

    <!-- example: revoking.tag-create -->
    tk --profile admin --message-format json user tag create --name revoker
  2. Create the revoker user. Root.

    <!-- example: revoking.user-create -->
    tk --profile admin --message-format json user create --user-name revoker --tag-name revoker --public-key PUBLIC_KEY

    Set REVOKER_USER_ID to data.activity.result.createUsersResult.userIds[0].

  3. Allow deletion on the listed agents. Root. Show each id from user get first:

    <!-- example: revoking.policy -->
    tk --profile admin --message-format json user get --id AGENT_USER_ID
    tk --profile admin --message-format json policy create --name revoker-delete-agent-keys --effect allow \
      --consensus "approvers.any(user, user.tags.contains('${REVOKER_TAG}'))" \
      --condition "activity.type == 'ACTIVITY_TYPE_DELETE_API_KEYS' && activity.params.user_id in ['${AGENT_USER_ID}']"

    A new agent user is added to this list, as to the provisioner's mint ALLOW.

  4. Revoke. Revoker host. List first and pick the key to cut off; on a session agent it is the key with a non-null expiresAt:

    <!-- example: revoking.delete -->
    tk --profile revoker --message-format json api-key list --user-id AGENT_USER_ID
    tk --profile revoker --message-format json api-key delete --user-id AGENT_USER_ID --id API_KEY_ID

    Proceed when data.activity.result.deleteApiKeysResult.apiKeyIds names API_KEY_ID. The deleted key now fails whoami with unauthorized; a sidecar holding it stops signing.

  5. Hand off. Report REVOKER_USER_ID, the policy id, the covered agent user ids, and each deleted key id. A revoked session agent resumes only after a new key is provisioned. Stop.

Verified by

Examples Test
revoking.profile-create, revoking.tag-create, revoking.user-create, revoking.policy, revoking.delete api_keys::revoking_agent_keys_scoped_revoker_deletes_listed_session_key
revoking.policy, revoking.delete api_keys::revoking_agent_keys_credential_deny_blocks_tagged_revoker

Troubleshooting

  • api-key delete fails unauthorized 403: the target user is not in the ALLOW's list, or the revoker also carries a tag with the credential DENY. Check with policy evaluations when an activity id exists. Do not widen the condition to every user; do not fall back to root.
  • api-key delete fails api_error 400 "missing valid credential": the key is the user's last permanent credential. Register a replacement first, or delete the user.
  • whoami with the deleted key still succeeds: the delete is pending or ran against another key id. activity get the delete and compare ids.

Related Skills

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 6fd5c16. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated last month

README badge

README badge for tkhq/tk/revoking-agent-keys