This quickstart takes an agent from nothing to a funded account that swaps and pays out inside rules its owner signed. Plan on about 30 minutes and about 10 USDC on Base. The owner signs twice; everything after that runs from your backend.
There is no testnet version of NEAR Intents or the Agent API. Everything here runs on mainnet with real funds, so use a dedicated owner account and small amounts.

What you’ll build

1

Create an agent (owner signature 1 of 2)

The owner signs one complete policy. The agent becomes ACTIVE with its own wallet.
2

Issue a grant (owner signature 2 of 2)

Your backend creates a grant token. The owner signs its commitment, which says who may act for the agent. That is the owner’s last signature in this quickstart.
3

Fund the agent

Your backend asks for a deposit address and sends USDC to it. No grant and no owner signature are needed.
4

Swap, transfer and withdraw

Your backend quotes and runs the actions with the grant token, then follows each one to SUCCESS.

Prerequisites

  • Node.js 24 or later. Every step also shows cURL.
  • A partner API key. Create one in the Partner Dashboard. It starts with naa_ and is shown once. See Partner API Key.
  • An owner wallet to sign with: a NEAR account or a passkey. The snippets use a NEAR account, alice.near. EVM wallets work only where GET /v1/network lists evm in supported_owner_types, and they aren’t enabled by default. See Owner Signing for the other wallets.
  • About 10 USDC on Base, sent from any wallet, to fund the agent.
Owner signing runs in your frontend with the owner’s own wallet. The SDK has no wallet signers, so the signing step shows the wallet code you add to your app. To run this whole flow from one script with a throwaway key instead, use the runnable examples.

Set up your backend

1

Install the SDK

2

Set your environment

Keep the partner API key out of git and out of every browser. The other values come from the pages that follow.
.env
Run every script with node --env-file=.env script.ts. For cURL, load the file with set -a; source .env; set +a.
3

Create the shared client

The client talks to NEAR_INTENTS_AGENT_API_URL, or to https://api.agentsonintents.com when it isn’t set. settled follows an operation until it stops moving. Each getStatus call waits up to 30 seconds for a change.
agent-api.ts
The .ts imports in the later pages run on Node 24 as they are.

Check your key

GET /v1/whoami confirms the key works. It returns your key ID and tenant ID, never the key. GET /v1/network is public and reports whether the services the API depends on are healthy. It’s advisory and about a minute old at most. Check it first whenever a quote or route fails.
whoami
network
A 401 with invalid_api_key means the key is wrong, revoked or has stray whitespace. GET /v1/quotas (api.getPartnerQuota()) shows how many agents and keys you can create and what you’ve used.

Start building

Create an Agent

Sign one complete policy and wait for the agent to go live.

Issue a Grant

Create a grant token and have the owner sign its commitment.

Execute Actions

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

Status & Errors

Read statuses, retry safely and handle error codes.