<!-- tempo-docs-context -->
> Source: [/docs/accounts/access-keys](https://tempo.com/developers/docs/accounts/access-keys.md)
> Section: [Accounts](https://tempo.com/developers/docs/accounts.md). Create accounts, set up signing methods, policies, access keys, key rotation, and fees, and follow guides for users, automations, agents, and teams.
> [Documentation index](https://tempo.com/developers/llms.txt) · [Docs skill](https://tempo.com/developers/SKILL.md)

> Tempo MCP: Use `search`, `find_pages`, `read_page`, and `code` at `https://mcp.tempo.xyz` for Tempo and related documentation.
> If an indexed page is missing or reflects an older site, read this site’s [documentation index](https://tempo.com/developers/llms.txt) and Markdown pages directly.

# Access Keys

Lets a customer's phone, your backend, or an AI agent pay without the account's signers approving each payment.

<span id="access-keys" />

<span id="how-it-works" />

<span id="what-an-access-key-is" />

## Overview

An access key signs transactions from an account's address and pays from its balance. The account's signers authorize it once. From then on, the key signs by itself. Tempo checks the key's bounds on every transaction, so a leaked key spends only what those bounds allow.

An access key holds no funds itself. The account stores only the key's address, type, and bounds, never its private key.

Access keys work on mainnet and testnet with a [single-key account](https://tempo.com/developers/docs/accounts/how-it-works#address). Until T14, access keys on a configurable account run only on the Tempo Accounts devnet.

<span id="access-keys-and-signers" />

<span id="choose-the-authority-to-delegate" />

## Signers

An access key isn't a signer:

* **No Threshold Weight:** It never counts toward the [signing threshold](https://tempo.com/developers/docs/accounts/policies/signing-thresholds), so it can't change the account's signers.
* **Survives Signer Changes:** Changing a configurable account's signers leaves every access key in place.

<span id="access-key-controls" />

<span id="controls" />

<span id="set-limits-that-match-the-task" />

<span id="access-key-lifecycle" />

<span id="read-the-remaining-permission" />

<span id="read-an-access-key" />

<span id="change-an-access-key" />

<span id="access-key-expiry" />

<span id="scopes" />

<span id="scope-an-access-key" />

<span id="bound-what-a-key-can-do" />

<span id="admin-access-keys" />

## Bounds

Each key carries up to three bounds: a spending limit, scopes, and an expiry. Every bound is optional. Leaving one out removes that check. A key without scopes can call any contract, so give a backend, agent, or [card program](https://tempo.com/developers/docs/accounts/automations/pay-from-an-embedded-wallet) key all three.

[Spending Limits](https://tempo.com/developers/docs/accounts/access-keys/spending-limits): Cap how much of each stablecoin the key can spend, in total or per period.

[Scopes](https://tempo.com/developers/docs/accounts/access-keys/scopes): Limit which contracts and functions the key can call, and whom it can pay.

[Expiry](https://tempo.com/developers/docs/accounts/access-keys/expiry): Set when the key stops working. You can replace a key, not extend it.

[Revocation](https://tempo.com/developers/docs/accounts/access-keys/revocation): Stop a key immediately, and clean up what it left behind.

<span id="access-key-types" />

<span id="access-key-patterns" />

<span id="access-keys-by-holder" />

<span id="backend-services" />

<span id="automations" />

<span id="recommended-limits-for-common-automations" />

<span id="agents" />

<span id="ai-agents" />

<span id="authorize-the-agents-task" />

<span id="keep-account-and-request-budgets-distinct" />

<span id="one-key-per-holder" />

<span id="give-each-holder-its-own-key" />

## Key Types

Give each device, service, agent, or team its own key, so you can revoke one without touching the rest. The key type depends on where its holder signs.

| Holder | Key type |
| --- | --- |
| A customer's browser or phone | A P-256 [device key](https://tempo.com/developers/docs/accounts/authentication/device-keys) the device can't export, or a WebAuthn [passkey](https://tempo.com/developers/docs/accounts/authentication/passkeys) |
| Your backend or an [AI agent](https://tempo.com/developers/docs/accounts/automations/give-an-agent-a-wallet) | A P-256 key it generates, or a secp256k1 key in your [KMS or HSM](https://tempo.com/developers/docs/accounts/automations/pay-out-from-a-backend#keep-the-key-in-your-kms) |
| A wallet | A secp256k1 key |
| A [team](https://tempo.com/developers/docs/accounts/custodians/team-multisig) | A configurable account, whose own signers and threshold approve as the key. Devnet until [T14](https://tempo.com/developers/docs/protocol/upgrades/t14). |

## Try It

The demo authorizes a key with a daily limit and pays with it. Tempo rejects a payment over the limit, then the demo revokes the key.

<span id="try-an-access-key" />

In the interactive web page, create a test account on the Tempo Accounts devnet whose signer is a non-extractable P-256 key in this browser, fund it with test AlphaUSD from the devnet faucet, authorize a second non-extractable P-256 browser key as an access key with a 10 AlphaUSD daily limit, a one-hour expiry, and transfers only, pay 2 AlphaUSD with it, attempt a 20 AlphaUSD payment that Tempo rejects, and revoke the key. Each step is a real devnet transaction.

<span id="authorize-a-limited-key" />

<span id="authorize-an-access-key" />

## Authorize a Key

Enough signers to reach the threshold sign a key authorization. It's a message that names the key and its bounds. Submit it in one of two ways:

* **With the Key's First Payment:** `signAuthorization` returns a `keyAuthorization` that travels with the first transaction the key signs. The key stays authorized even if that transaction's calls revert.
* **On Its Own:** `authorizeSync` sends the authorization in a separate transaction, before the key pays.

This example takes the first path. A new account's signer gives a payout key 10 OUSD for one hour, payable to one recipient.

`account.ts` is the configurable account with one signer from [Create an account](https://tempo.com/developers/docs/accounts/create#create-an-account-in-code). The [devnet faucet](https://tempo.com/developers/docs/accounts/create#fund-an-account-on-devnet) funds it. `client.ts` connects to the Tempo Accounts devnet ([set up the devnet key](https://tempo.com/developers/docs/accounts/create#connect-to-the-devnet)). To run the example on the Moderato testnet with a single-key account, set `account` to that signer. Then connect `client` to [testnet](https://tempo.com/developers/docs/quickstart/connection-details#testnet).

:::code-group
```ts [access-keys.ts]
import { parseUnits } from 'viem'
import { Account, Expiry, P256 } from 'viem/tempo'
import { account } from './account'
import { client } from './client'

export { account }
// A test stablecoin on the devnet
export const stablecoin = '0x20c0000000000000000000000000000000000001'
export const recipient = process.env.TEMPO_RECIPIENT as `0x${string}`

export const accessKey = Account.fromP256(P256.randomPrivateKey(), { access: account }) // [!code hl]
const keyAuthorization = await client.accessKey.signAuthorization({ // [!code hl]
  accessKey, // [!code hl]
  account, // [!code hl]
  expiry: Expiry.hours(1), // [!code hl]
  limits: [{ token: stablecoin, limit: parseUnits('10', 6), period: 0 }], // [!code hl]
  scopes: [{ address: stablecoin, recipients: [recipient], selector: 'transfer(address,uint256)' }], // [!code hl]
}) // [!code hl]

await client.token.transferSync({
  account: accessKey,
  amount: parseUnits('2', 6),
  keyAuthorization, // [!code hl]
  to: recipient,
  token: stablecoin,
})
```

```ts [client.ts]
import { http } from 'viem'
import { tempoDevnet } from 'viem/chains'
import { createClient } from 'viem/tempo'

// The Tempo Accounts devnet. Its RPC needs a key, which Tempo gives you.
const rpcKey = process.env.TEMPO_DEVNET_RPC_KEY

export const client = createClient({
  chain: tempoDevnet,
  transport: http('https://rpc-stack-mdtgf.devnet.tempoxyz.dev', {
    fetchOptions: { headers: { Authorization: `Basic ${btoa(`previews:${rpcKey}`)}` } },
  }),
})
```
:::

The other pages in this section import `account`, `accessKey`, `stablecoin`, and `recipient` from this file. To confirm the key landed, read it back with `client.accessKey.getMetadata({ account, accessKey })`.

Tempo stores each limit and scope with the key, so each one adds to the network fee for authorizing it. This example's authorization and first payment cost under a cent together.

To cancel a signed authorization before anyone submits it, sign it with a 32-byte [`witness`](https://viem.sh/tempo/guides/access-keys/witnesses). Burning the witness cancels the authorization. Viem's [Authorize access keys](https://viem.sh/tempo/guides/access-keys/authorize) guide shows both.

<span id="key-revocation" />

<span id="key-revocation-by-situation" />

<span id="revoke-an-access-key" />

<span id="revoke-and-audit-keys" />

## Revoke and Audit

[Revoke](https://tempo.com/developers/docs/accounts/access-keys/revocation) a key to end it permanently, for example when a device is lost or a service is retired. Payments the key already made stay final, and its token approvals stay until you set them to zero.

<span id="see-an-accounts-keys" />

Tempo emits `KeyAuthorized` when an account adds a key and `KeyRevoked` when it revokes one. The [public indexer](https://tempo.com/developers/docs/api/indexer-api) lists every key an account has had from these events. Replace the address with your account's.

Save this query as `query.sql` and run it against the public Tempo mainnet indexer (chain ID 4217).

```sql
SELECT 'authorized' AS event, publicKey AS access_key, expiry, block_num, tx_hash
FROM KeyAuthorized
WHERE account = '0x6028375ea6ae3339b16f29b343f8f32f7bb3ee8a'
UNION ALL
SELECT 'revoked' AS event, publicKey AS access_key, NULL AS expiry, block_num, tx_hash
FROM KeyRevoked
WHERE account = '0x6028375ea6ae3339b16f29b343f8f32f7bb3ee8a'
ORDER BY block_num DESC
LIMIT 20
```

```bash
curl --get "https://indexer.tempo.xyz/query" \
  --data-urlencode "chainId=4217" \
  --data-urlencode "engine=clickhouse" \
  --data-urlencode "signature=KeyAuthorized(address indexed account, address indexed publicKey, uint8 signatureType, uint64 expiry)" \
  --data-urlencode "signature=KeyRevoked(address indexed account, address indexed publicKey)" \
  --data-urlencode "sql@query.sql"
```

<span id="troubleshoot-backend-payments" />

<span id="access-key-limits" />

## Limits

* An access key can't create a contract at the top level of a transaction ([scope limits](https://tempo.com/developers/docs/accounts/access-keys/scopes#scope-limits)).
* All of an account's transactions share one sequence number (nonce) by default, whichever key signs them. They land in order. To send payments concurrently, use expiring nonces or separate nonce keys ([parallel payments](https://tempo.com/developers/docs/guide/payments/send-parallel-transactions)).
* Calls that authorize, change, or revoke keys must come from the account's own transaction (`msg.sender == tx.origin`), not through a contract.

The [Account Keychain specification](https://tempo.com/developers/docs/protocol/transactions/AccountKeychain) defines these rules in full.

## Related

[Pay Out From a Backend](https://tempo.com/developers/docs/accounts/automations/pay-out-from-a-backend): Use for paying out from a server with a bounded access key.

[Give an Agent a Wallet](https://tempo.com/developers/docs/accounts/automations/give-an-agent-a-wallet): Use for letting an AI agent pay within limits you set.

[Pay From a User's Embedded Wallet](https://tempo.com/developers/docs/accounts/automations/pay-from-an-embedded-wallet): Use for card programs and other payments from a user's embedded wallet.

[Account Keychain Precompile](https://tempo.com/developers/docs/protocol/transactions/AccountKeychain): Covers the contract that stores access keys and enforces their bounds.
