A grant says who may act for the agent. Your backend creates a secret grant token, the owner signs only its commitment, and your backend then runs agent actions with the token, with no further owner signature. A grant carries no permissions of its own. What any grant may do, where funds may go and how much is the account’s policy, which every grant on the agent shares. So:
  • Changing the policy never requires a new grant.
  • Create one grant per assistant, session or bot. An agent holds up to 50 live grants, and revoking one stops only that one.
  • There are no per-grant budgets. Two grants under a 50 USD daily cap share 50 USD.

Prerequisites

  • An ACTIVE agent from Create an Agent, with its ID saved as AGENT_ID in .env.
  • The signWithWallet function from that page. A NEAR owner signs grants as a message (nep413), and the same function handles it.
1

Create a grant token

The token is the secret that authorizes actions under this one grant. The commitment is its SHA-256 fingerprint. Store the token encrypted on your backend, next to your user and agent. It’s shown nowhere else, and the API never sees it.
2

Generate the grant_issue intent

This grant lasts 7 days. label is up to 64 characters. It’s shown to the owner when signing and on every operation the grant authorizes. expires_at is required and at most 365 days ahead.
The response has the same shape as in Create an Agent. For a NEAR owner, intent.standard is nep413.
3

Have the owner sign and submit

Show preview.summary, have the wallet sign intent.payload as it is with signWithWallet, then submit what it returned and wait. For cURL, set CORRELATION_ID and SIGNED_DATA as in Create an Agent.
When the status is SUCCESS, details.grant describes the live grant. Save the token as GRANT_TOKEN in .env. You can list an agent’s grants at any time:
4

Use the grant

Send the token as X-Grant-Token on agent actions. With the SDK, create one client per grant, so each assistant or bot always acts under its own grant:
TypeScript SDK
forGrant sends the token only on the calls that need it: swap, withdraw, transfer, shield, unshield, recover and sign.To end a grant early, the owner signs a grant_revoke intent with its grant_id. Work the API had already committed to dispatch can’t be recalled. The status lists it in details.committed_correlation_ids.
You now have a live grant. Its token is in .env as GRANT_TOKEN. That was the owner’s last signature: from here on, your backend acts alone.

Next: Execute Actions

Fund the agent, quote and run a swap, then transfer and withdraw.