> ## Documentation Index
> Fetch the complete documentation index at: https://docs.near-intents.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Owner Signing

> How NEAR, EVM and passkey owners sign, and how to add signing to your app

The owner approves every change to their agent with their own wallet: a NEAR account, an EVM wallet or a passkey. Your backend prepares the request, your frontend has the wallet sign it, and your backend submits it.

> [!NOTE]
>
> **At a glance**
>
> * **Three calls:** `generate-intent` → wallet signs `intent.payload` → `submit-intent`, then follow `GET /v1/status`.
> * **Same API for every wallet:** only the frontend wallet call differs, and `intent.standard` (`nep366`, `nep413`, `eip712` or `webauthn`) tells you which one.
> * **To go live:** two signatures, `agent_create` then `grant_issue`. Every later change is one signature.
> * **Sign promptly:** the owner has about 290 s for most intents and about 600 s for on-chain wallet requests. See [Signing windows](#signing-windows).
> * **Never in the browser:** your partner API key, grant tokens and the SDK stay on your backend.

***

## Who does what

> [card] Your backend
>
> Keeps the partner API key and grant tokens. Calls `generate-intent`, `submit-intent` and `status`. Saves each `correlation_id` with your user and agent.

> [card] Your frontend
>
> Connects the owner's wallet. Shows the `preview`, asks the wallet to sign `intent.payload`, and sends the result to your backend.

The browser never needs your partner API key, a grant token or the SDK. Before you create or submit an intent for a user, check that this user owns the agent. Don't trust a `correlation_id` sent from a browser without that check.

***

## The signing flow

Every owner intent works the same way.

**1. Generate (your backend)**

Call `POST /v1/generate-intent` with the intent `type` and its fields. The response has the `correlation_id` (starts with `intent_`), the `signer` whose wallet must sign, `intent: { standard, payload }`, a readable `preview` and an `expires_at`.

**2. Sign (your frontend)**

Show the `preview` to the owner. The wallet signs `intent.payload` unchanged, using the method that matches `intent.standard`.

**3. Submit (your backend)**

Call `POST /v1/submit-intent` with `type`, `correlation_id` and `signed_data`: the intent you generated plus the wallet's output. Resubmitting the same signature is safe.

**4. Wait for the result (your backend)**

Call `GET /v1/status?correlation_id=…&wait_ms=30000` until the status is `SUCCESS` or `FAILED`.

Here is the whole round trip for a `grant_issue`. Every owner intent uses the same three pieces: two backend routes and one frontend call.

```typescript Backend (SDK) theme={null}
import { createAgentApi, createGrantCredential } from "@near-intents-agent-api/sdk";
import type { GenerateIntentResponse, SignedData } from "@near-intents-agent-api/sdk";

const api = createAgentApi({ apiKey: process.env.NEAR_INTENTS_AGENT_API_KEY! });

// Owner intents waiting for a signature, by correlation_id. Use your database in production.
const pending = new Map<string, { userId: string; type: GenerateIntentResponse["type"] }>();

// Route 1: the signed-in owner's browser asks for a grant. Check first that userId owns agentId.
export async function generateGrant(userId: string, agentId: string, sessionId: string) {
  const { token, commitment } = createGrantCredential(); // store `token` encrypted, never send it out
  const generated = await api.generateIntent(
    {
      type: "grant_issue",
      agent_id: agentId,
      label: "Trading assistant",
      credential: commitment,
      expires_at: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(),
    },
    { idempotencyKey: `grant-${agentId}-${sessionId}` },
  );
  pending.set(generated.correlation_id, { userId, type: generated.type });
  // Only these three go to the browser.
  return { correlation_id: generated.correlation_id, intent: generated.intent, preview: generated.preview };
}

// Route 2: the browser sends back the wallet's output.
export async function submitSigned(userId: string, body: { correlation_id: string; signed_data: SignedData }) {
  const stored = pending.get(body.correlation_id);
  if (!stored || stored.userId !== userId) throw new Error("not this user's intent");
  await api.submitIntent({
    type: stored.type,
    correlation_id: body.correlation_id,
    signed_data: body.signed_data,
  });
  return api.getStatus(body.correlation_id, { waitMs: 30_000 });
}
```

```typescript Frontend theme={null}
// signWithWallet is defined below, under "What the owner signs".
const generated = await fetch("/api/owner-intents/grant", { method: "POST" }).then((r) => r.json());

showPreview(generated.preview); // your UI: what the owner is agreeing to
const signed_data = await signWithWallet(generated.intent);

await fetch("/api/owner-intents/submit", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ correlation_id: generated.correlation_id, signed_data }),
});
```

The routes, `/api/owner-intents/grant` and `/api/owner-intents/submit`, are your app's own. Your backend wires them to `generateGrant` and `submitSigned`, with the signed-in user's ID from your session.

Keep the `Idempotency-Key` stable for one logical request: a retry with the same key and body returns the same intent. Store the generated intent if signing has to survive a page reload.

***

## What the owner signs

`standard` tells you which wallet call to make. [Signing Standards](https://docs.near-intents.org/integration/agent-api/signing-standards.md) explains each one. The wallet signs `payload` exactly as it is. Your frontend then sends back the intent plus the wallet's output, called `signed_data`.

| Owner | Standard | Used for |
| - | - | - |
| NEAR | `nep366` (delegate action) | `agent_create`, `agent_freeze`, `agent_unfreeze`, `agent_delete`, and `policy_update` when it changes the wallet's rules |
| NEAR | `nep413` (signed message) | Every other intent, including `approval_vote` and a `policy_update` that changes only `destinations`, `budget`, `timelock_ms`, `schedule` or `limit_order` (its `max_deviation_bps`) |
| EVM | `eip712` (typed data) | Every intent type |
| Passkey | `webauthn` (assertion) | Every intent type |

For a NEAR owner, a `policy_update` can come back as either standard. Always choose the wallet call from `intent.standard`, never from the intent type.

```typescript Frontend theme={null}
import type { GenerateIntentResponse, SignedData } from "@near-intents-agent-api/sdk";

// wallet, walletClient, account and startAuthentication come from your own wallet
// integration: a NEAR wallet selector, viem and @simplewebauthn/browser. The SDK has no signers.
export async function signWithWallet(intent: GenerateIntentResponse["intent"]): Promise<SignedData> {
  switch (intent.standard) {
    case "nep366": {
      const { signedDelegateActions } = await wallet.signDelegateActions({ delegateActions: [intent.payload] });
      return { ...intent, signed_delegate: signedDelegateActions[0] };
    }
    case "nep413": {
      const nonce = Uint8Array.from(atob(intent.payload.nonce), (c) => c.charCodeAt(0));
      const { publicKey, signature } = await wallet.signMessage({ ...intent.payload, nonce });
      return { ...intent, public_key: publicKey, signature };
    }
    case "eip712":
      return { ...intent, signature: await walletClient.signTypedData({ account, ...intent.payload }) };
    case "webauthn":
      return { ...intent, credential: await startAuthentication({ optionsJSON: intent.payload }) };
  }
}
```

| Standard | `signed_data` fields added to the intent |
| - | - |
| `nep366` | `signed_delegate`: base64 Borsh `SignedDelegate` |
| `nep413` | `public_key` and `signature` |
| `eip712` | `signature`: `0x`-prefixed, 65 bytes |
| `webauthn` | `credential`: the `AuthenticationResponseJSON` |

Your wallet library may name the results differently. Adjust the code to match. The API accepts common signature encodings (base58, base64 and hex). Don't rebuild, hash or reorder the payload: the API checks that it's exactly what it sent.

### Signing windows

Every intent has an `expires_at`. Sign and submit before it, or you get `intent_expired` and have to generate a new intent. The window depends on the kind of request ([Signing Standards](https://docs.near-intents.org/integration/agent-api/signing-standards.md#two-kinds-of-owner-requests) explains the two kinds):

| Request | Window | Notes |
| - | - | - |
| Wallet requests: `agent_create`, `agent_freeze`, `agent_unfreeze`, `agent_delete`, and a `policy_update` that changes the wallet's rules | 600 s | EVM and passkey requests are stamped 30 s in the past to absorb clock skew, so about 570 s remain when you receive them. |
| Consent messages: every other intent | about 290 s | For passkey owners about 270 s, because the signed timestamp is also 30 s in the past. |
| `approval_vote` | about 290 s (passkey about 270 s) | Never longer than the approval's own expiry. |

A delegate action that a NEAR wallet signs has its own nonce and block height limit. If the owner's key can no longer execute it by the time you submit, you get `policy_delegate_expired`: generate a new intent.

### Show the preview

Always show `preview` next to the wallet prompt. It says what the owner is agreeing to:

* `preview.summary`: a one-line description.
* `preview.policy`: for `agent_create` and `policy_update`, the complete policy being signed. It is the whole resulting policy, not a diff against the current one.
* `preview.deletion`: for `agent_delete`, what would be lost.
* `preview.approval`: for `approval_vote`, the request being voted on.

***

## Owner identities

The `owner` field in `agent_create` holds only public information. [Owner Accounts](https://docs.near-intents.org/integration/agent-api/owner-accounts.md#what-to-pass-as-the-owner) shows each shape in full, and how to get an EVM public key or convert a passkey key.

| Owner | Fields | The owner needs |
| - | - | - |
| NEAR | `account_id`, `public_key` (a full-access `ed25519` key) | Their own NEAR account |
| EVM | `address` (lowercase), `chain_id`, `public_key` (64-byte uncompressed secp256k1, no `04`) | A regular wallet (EOA). No NEAR account. New EVM-owned agents need EVM owners to be enabled on the deployment. |
| Passkey | `credential_id`, `public_key` (P-256 SPKI, base64url), `rp_id`, `origin` | A passkey that verifies the user. No NEAR account. |

New agents currently take NEAR or passkey owners. With EVM owners off, `agent_create` for an EVM owner returns `owner_type_unsupported` (400) and `GET /v1/network` lists only `near` and `passkey` in `supported_owner_types`. Agents that already have an EVM owner keep working and sign as described on this page.

> [!WARNING]
>
> For EVM and passkey owners, the NEAR account comes from the public key. A different key means a different account, and keys can't be changed later. Make sure the owner keeps access to the same key.

***

## Passkey registration

Your app registers passkeys. The Agent API doesn't do it for you.

* Register with `pubKeyCredParams` set to ES256 (`alg: -7`), and require user verification.
* Save the public key in SPKI format. If your library gives you a COSE key, convert it on your backend (see [Owner Accounts](https://docs.near-intents.org/integration/agent-api/owner-accounts.md#what-to-pass-as-the-owner)).
* Save the credential ID, public key, `rp_id` and `origin`, and pass them as the `owner` in `agent_create`.

***

## Owner intent types

| Type | Fields | Purpose |
| - | - | - |
| `agent_create` | `name`, `owner`, `policy`, optional `external_user_id` | Create an agent with its complete first policy |
| `policy_update` | `agent_id`, `policy`, `expected_revision` | Replace the complete policy. See [Policies & Limits](https://docs.near-intents.org/integration/agent-api/policies-and-limits.md). |
| `agent_freeze` / `agent_unfreeze` | `agent_id` | Stop or resume all actions |
| `grant_issue` | `agent_id`, `label`, `credential`, `expires_at` | Let a credential act for the agent. `credential` is the token's SHA-256 fingerprint, or an object the owner signs as is: `{ type: "oidc", issuer, claims }` for a workload identity, or `{ type: "public_key", jwk }` for a workload key. `expires_at` is at most 365 days ahead. See [Workload Identity](https://docs.near-intents.org/integration/agent-api/workload-identity.md). |
| `grant_revoke` | `agent_id`, `grant_id` | End a grant |
| `execution_cancel` | `agent_id`, `correlation_id` | Cancel a `QUEUED` action before it runs |
| `approval_vote` | `agent_id`, `approval_id`, `verdict` | Approve or reject an action waiting for approval. NEAR, EVM and passkey owners can all vote. See [Approval votes](#approval-votes). |
| `agent_archive` / `agent_restore` | `agent_id` | Hide or restore an agent. Archive needs a frozen agent, restore an unfrozen one. |
| `agent_delete` | `agent_id` | Delete the agent with one signature over its wallet's `delete_wallet_policy`. `preview.deletion` shows what would be lost. See [Deleting an agent](#deleting-an-agent). |

For a federated `credential`, the signed grant message carries the whole object in `owner_message.credential` instead of a fingerprint string: for `oidc`, the issuer, the audience, the pinned claims and any signed issuer keys (`jwks`); for `public_key`, the public JWK. The API adds the audience for every issuer except Microsoft Entra ID, so leave it out of the request. `preview.summary` says in words who will be able to act, and your UI should show it. Claim names and values are printable ASCII, like the label.

`policy_update` needs the complete policy and the `expected_revision` you read from `GET /v1/agents/{agent_id}/policy`. If the policy changed since, you get `policy_revision_conflict`: read it again and generate a new intent.

### Approval votes

When the policy sets `owner_approval: true`, every outgoing agent action waits for the owner's vote. The owner is the only approver, and the vote needs no grant. All owner types vote the same way through `approval_vote`: generate the intent, have the wallet sign `intent.payload`, submit. The vote is sent to the wallet provider off-chain, so it costs no gas. At most 100 requests from one agent wait for a vote at once; the next is refused with `approval_backlog_full` until the owner votes on one.

What gets signed is one short string:

```text theme={null}
${verdict}:${approval_id}:${wallet_pubkey}:${request_hash}
```

* `verdict` is `approve` or `reject`.
* `approval_id` and `request_hash` identify the approval and the exact request it decides.
* `wallet_pubkey` is the agent wallet's key as the approval reports it.

A `reject` ends the request. It never ran, so the API releases its USD budget charge once it observes the rejection: the operation settles `FAILED` with `details.never_executed`. A `reject` cast within a block or two of a policy change can be stored by the wallet provider without cancelling the request. The API sends the owner's signed reject again, up to 3 times, 2.5 seconds apart. The vote's status `details` are `{ approval_id, verdict, repeat_required, confirmation? }`. If `repeat_required` is `true`, the request is still pending: generate the `approval_vote` intent again and have the owner sign another `reject` for the same approval. `null` means this is not known yet because the vote is not applied, and `false` means there is nothing more to do. `confirmation: "cancellation_observed"` means a fresh reject lost its reply and the API observed the cancellation from the earlier receipt, so the reject took effect. Approves are unaffected. An `approve` releases the request to run, so the API first re-runs the checks that admitted it: the grant must still be live and unexpired, the policy applied and not frozen, and the destination still allowed by `destinations`. If one no longer holds, the vote is refused with `authorization_stale`, `wallet_frozen` or `policy_destination_denied`, nothing reaches the wallet provider, and the request stays held for a `reject` while the refusal can still clear, such as a frozen account. A refusal that can never clear ends the request instead. Once the policy, owner or lifecycle has moved on since the request was admitted, or its grant was revoked or expired, the API fails it with `authorization_stale`. Once the approval's `expires_at` passes, it fails with `expired`. Either way the operation settles `FAILED` with `details.never_executed`, its budget charge is released, it leaves the approvals list, and a later `approve` is refused with `authorization_stale` or `approval_closed`. A vote intent already refused with `authorization_stale` then ends `FAILED` with that code instead of waiting out its signing window. A request with a vote already recorded is left to the wallet provider's own report. An `approve` for a request the API has not yet recorded under its approval (its dispatch reply was lost in transport) is refused with `approval_not_recorded` after the API has looked once itself; send the same vote again a few minutes later. The schedule is not re-judged: the vote is the owner's own decision. The approval's `votes` (on `GET /v1/agents/{agent_id}/approvals` and `.../approvals/{approval_id}`) list the votes submitted through this API, oldest first, as `{ voter, verdict, voted_at }`, with `voter` the owner's principal id (`near:<account>:<public_key>`, `evm:<account>` or `passkey:<account>`). A vote cast directly at the provider is not listed. A limit order's price is judged against the market when it is placed, and again when a timelock or the owner's approval releases it.

You never build this string. It is in `intent.payload`, and `preview.approval` shows the owner what is being decided. How it is signed depends on the owner:

| Owner | Standard | How the vote is signed |
| - | - | - |
| NEAR | `nep413` | The vote string is the `message`, signed by the owner's key from `agent_create`. The `recipient` is the wallet provider's contract, not the API's hostname. |
| EVM | `eip712` | The vote string is the `payload` of an `Authorization` message. The owner's `0s` wallet contract confirms the signature. |
| Passkey | `webauthn` | The vote string is the payload of an off-chain message, and the passkey signs its hash. The owner's `0s` wallet contract confirms the signature. |

### Deleting an agent

`agent_delete` is one owner signature, and it's irreversible. The owner signs the agent wallet's `delete_wallet_policy` call, so it is a wallet request like `agent_create` and the freeze intents, not an off-chain consent message:

| Owner | What the wallet signs |
| - | - |
| NEAR | A `nep366` delegate action from the owner's account and key |
| EVM | The `eip712` `WalletMessage` for the owner's `0s` account |
| Passkey | A `webauthn` assertion over the wallet request hash |

The agent doesn't need to be frozen or archived first. The signing window is the wallet-request window, 600 s (see [Signing windows](#signing-windows)).

> [!WARNING]
>
> Nothing is swept before deletion. Public and confidential balances still in the wallet are destroyed. Before the owner signs, show `preview.deletion`: `assets_lost`, the `public` and `confidential` balances and the `beneficiary`. Have the owner withdraw all funds first, for example by asking the agent to do it. The preview can go stale, so read it just before signing. A submission is refused with `limit_orders_open` while the agent has resting limit orders that are not payout-final (`preview.deletion.open_limit_orders` counts them): freeze the agent, which cancels them, then submit again once their payouts settle. This is checked before the balances. A submission is refused with `deletion_assets_remaining` while the wallet holds any public or confidential balance, whatever the preview showed. The API reads the balances again right before it commits: funds that arrived since fail the deletion with `deletion_assets_remaining`, and a balance it cannot read with `provider_unavailable`. Both are recorded as `failed`, nothing is retired and the agent stays archived and restorable. Before that, a read of the account that the configured NEAR RPC operators do not answer, or do not agree on, answers `near_rpc_unavailable` (503, retryable): send the same request again. A signature from a deletion that was later restored is refused with `owner_command_stale`: sign again. The preview doesn't count the agent's native accounts: the API doesn't read them, so native NEAR in its NEAR account and funds at its EVM or Solana address aren't inventoried. Deletion loses them: native NEAR goes to the sponsor (`beneficiary`). Tell the owner to move them first. `preview.deletion` has no `native_balance` field: SDK 0.7.3 removed it from `DeletionPreview`, so drop any code that read it. See [Native Accounts](https://docs.near-intents.org/integration/agent-api/native-accounts.md).

Once the signed request is accepted:

1. The API retires the agent's wallet and archives the agent, so no new agent request is admitted.
2. When the retirement is complete, the sponsor relays the owner's signed `delete_wallet_policy` call and pays the gas. The relay runs in the background: the deletion is answered without waiting for it.
3. The policy's storage deposit goes back to the sponsor, together with any native NEAR left in the wallet, which the API doesn't read or return.
4. Deposit addresses still waiting for payment, unpaid or paid in part, are closed as `FAILED` with `agent_deleted`. They never hold up the deletion, but anything sent to one afterwards lands in the retired account and is lost, so tell payers to stop first.

Step 3 is best-effort and the deletion stands either way. `GET /v1/status` reports it in `details.policy_record`, which reads `pending` first and settles to `deleted`, `kept`, `unknown` or `absent` as the relay reports:

| Field | Meaning |
| - | - |
| `status` | `pending`: the deletion is complete and the relay hasn't reported yet. This is the first answer. `deleted`: the policy record is gone and the deposit refunded. `absent`: no record was stored any more. `kept`: the record wasn't deleted, and `reason` says why. `unknown`: the call was broadcast but its outcome wasn't observed. |
| `transaction_hash` | The relay transaction, when one was sent |
| `refund_to` | The account the storage deposit returns to |
| `storage_deposit_yocto` | The deposit held by the record, in yoctoNEAR |
| `reason` | Why a record was `kept`, as a short code |

Keep following the status while `policy_record.status` is `pending`. A record that stays `kept` still refunds the same account whenever it is deleted later.

If the signed request doesn't delete exactly this agent's wallet policy, you get `wallet_request_mismatch` (409). If a NEAR delegate can no longer be executed by the owner's key, or an EVM or passkey owner's `0s` wallet no longer accepts signatures, you get `policy_delegate_expired` (409), nothing is retired and nothing changes: generate a new intent.

***

## Errors

| Code | Status | What to do |
| - | - | - |
| `intent_expired` | 409 | The signing window closed (about 290 s for most intents, 600 s for wallet requests). Generate a new intent. |
| `intent_payload_mismatch` | 409 | Submit `signed_data.payload` exactly as `generate-intent` returned it. |
| `intent_standard_mismatch` | 409 | Sign with the standard `generate-intent` returned in `intent.standard`. |
| `intent_type_mismatch` | 409 | `type` doesn't match the intent behind this `correlation_id`. |
| `intent_not_found` | 404 | Check the `correlation_id`. |
| `signer_mismatch` | 409 | A signed message (`nep413`) or passkey assertion came from a different key or credential than the intent's `signer`. |
| `policy_delegate_owner_mismatch` | 403 | A NEAR delegate action (`nep366`) was signed by a different account or key than the owner's. |
| `owner_key_not_full_access` | 403 | The owner's NEAR key isn't a live full-access key on the account. |
| `policy_delegate_expired` | 409 | The signed request can no longer execute on NEAR: the owner's key is gone or no longer full access, the owner's `0s` wallet no longer accepts signatures, its nonce was used or is out of range, or its block height passed. Nothing changed. Generate a new intent. |
| `wallet_request_mismatch` | 409 | The signed wallet request isn't the one generated for this agent, for example an `agent_delete` signed for another wallet. Submit what the wallet signed for `intent.payload`. |
| `signature_invalid` | 400 | The submitted signature is not in a format the signer's wallet produces. Submit exactly what the wallet returned. |
| `owner_proof_invalid`, `policy_delegate_signature_invalid`, `wallet_request_signature_invalid` | 401 | The signature doesn't verify. Sign `intent.payload` unchanged and submit the wallet's output. Branch on the code you get, not on one universal signature error. |
| `owner_nonce_invalid` | 409 | This intent was already used or has expired. Generate a new intent. |
| `policy_revision_conflict` | 409 | The policy changed since you read it. Read it again and generate a new intent. |
| `policy_too_large` | 400 | The policy is too large for the agent wallet to record in one write (its encrypted form is over 15,360 bytes). It is refused when you generate the intent, before the owner signs, and again when you submit it. Allow fewer assets, per-asset limits or contracts, then generate again. |
| `policy_change_throttled` | 429 | Policy changes have a per-agent cooldown. Retry at `meta.available_at`. |
| `agent_not_bound` | 409 | The agent is still onboarding. Wait for its `agent_create` intent to reach `SUCCESS`. |
| `owner_type_unsupported` | 400 | `agent_create` with an owner type this deployment doesn't accept for new agents. EVM owners are off by default: check `supported_owner_types` in `GET /v1/network`. |

### Which key error you get

The owner's NEAR key must be a **full-access** key on the owner's account. Which code a wrong or weak key produces depends on the flow:

| Flow | Different key or account | Key not full access |
| - | - | - |
| NEAR delegate action (`nep366`): `agent_create`, `agent_freeze`, `agent_unfreeze`, `agent_delete`, wallet-rule `policy_update` | `policy_delegate_owner_mismatch` (403) | `owner_key_not_full_access` (403) when `agent_create` is submitted. For a later intent, a delegate the key can no longer execute fails with `policy_delegate_expired` (409). |
| NEAR signed message (`nep413`): consent intents and `approval_vote` | `signer_mismatch` (409) | `owner_key_not_full_access` (403) |
| Passkey assertion (consent message or wallet request) | `signer_mismatch` (409) when the credential isn't the owner's | Not applicable |
| EVM typed data, or a passkey signature that doesn't verify | `owner_proof_invalid` (consent) or `wallet_request_signature_invalid` (wallet request), both 401 | Not applicable |

***

## Not supported

* Changing the owner's key
* Recovering a lost wallet
* Moving an agent to a different owner

Protocol references: [NEP-366](https://github.com/near/NEPs/blob/master/neps/nep-0366.md), [NEP-413](https://github.com/near/NEPs/blob/master/neps/nep-0413.md), [NEP-616](https://github.com/near/NEPs/blob/master/neps/nep-0616.md), [EIP-712](https://eips.ethereum.org/EIPS/eip-712).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.