Skip to main content
Everything on this page uses the one key you’ve had since Quickstart, plus the agent you created and funded in Create Your Organisation. In this walkthrough you play two roles:
  • The customer: you store your own record and decide what the agent may do with it.
  • The developer: you own the contract and the agent.
In production the customer is someone else, signed in with their own key, and they make the same calls you make in steps 1 and 2. Append each block to quickstart.ts and run it with ORG_DID, AGENT_DID and AGENT_API_KEY exported (see Running the code samples in this guide).

1. Store your record (as the customer)

A call you make for yourself is a self call: calling_user_did is you and is_delegated is false, so store accepts it. It needs no grant.
The record is now sealed in z:<tid>:vault under your DID. Only the contract can read it, and the contract only ever answers yes or no.

2. Grant your agent check — and nothing else (as the customer)

Being created and funded doesn’t let the agent call anything. The customer grants it one function of one contract:
updateMemberDelegation read-merge-writes, so grants you already gave other agents survive. Grants expire after 90 days by default — renew them the same way. See Member Delegation for the grant shape, time-boxing and revocation.

3. Ask the vault a question (as the agent)

The agent doesn’t open a session. It sends one request with its API key, naming the customer it acts for in pii_did:
Inside the enclave, calling_user_did is the customer and authenticated_did is the agent. The node only accepts the call because the customer granted this agent check on this contract. The answer has no name, date, balance or income in it — and the agent had no way to ask for one.
The agent paid for that call, not you. The node charges the authenticated caller — the agent — so the check comes out of the 5 credits you funded it with, not your balance. Each run of quickstart.ts still costs you its own session calls, so your balance drops a little whatever flag you run. If the call fails with an insufficient-credit error, top the agent up.

4. Confirm the boundary

The agent wasn’t granted store, so it can’t change the record:
The node refuses it before your contract runs. invoke() throws an InvokeError with err.status 403 and a fixed message: the SDK deliberately drops the response body, so a key can never leak through an error. The 403 response body, which the SDK drops, carries the node’s reason: Forbidden (function_not_delegated): <agent> not permitted to act on behalf of <you> for z:<tid>:vault store. Had the customer granted store by mistake, the contract would still refuse it: store rejects every delegated call. An agent that has run out of credit gets the same bare 403 from invoke(), so if a call you did grant fails this way, top the agent up.

5. See the call in your activity log

As your organisation’s admin you can read every member’s activity, including your agent’s. The custom labels the vault returned are on each entry, so you can filter by them:
actor is the agent and on_behalf_of is the customer. See Read your organization’s activity log for paging (next_seq) and every field.

You’re done

You now have one key, one organisation, one agent created through it and funded with 5 credits from your own balance, and a contract that agent can call — billed to the agent, and limited to yes/no answers. Next, test your contract. Then build on the same setup: let your agent check real documents with the Private Doc Scanner, or book flights through an outside API with Flight Booking.