Run it locally
These examples run the self-serve API on your machine against Sui testnet, on port 8790.
Start the server#
From the repository root, with dependencies installed (npm ci):
SUI_NETWORK=testnet \
SELF_SERVE_DEPLOYMENT=deployments/testnet-selfserve.json \
npx tsx services/selfserve/serve.tsThe container image runs the same command on Node.js 24.
SUI_NETWORK=testnetis required for the testnet deployment: without it the server targets a local network and refuses to start, because the chain does not match the deployment.PORTchanges the port.- Locally the server listens on
127.0.0.1only.
On first start the server creates its operator key in its local key folder; the operator pays gas for every transaction, so send its address some testnet SUI. The address is the sponsor field of GET /v1/config. A key whose address holds mainnet funds is refused.
The server keeps its state, including the admin token, in its data directory. The server prints its data directory when it starts: self-serve (data <directory>) on http://127.0.0.1:8790. A hosted server takes its admin token from SELF_SERVE_ADMIN_TOKEN, at least 32 characters, and its data directory from SELF_SERVE_DATA_DIR.
1. Check it is up#
curl -s http://127.0.0.1:8790/healthz
# {"ok":true}
curl -s http://127.0.0.1:8790/v1/config2. Sign in#
curl -s -X POST http://127.0.0.1:8790/v1/auth/challenge \
-H "Content-Type: application/json" -d "{\"address\": \"$ADDR\"}"Sign the returned message as a Sui personal message with the key for $ADDR (see Authentication), then:
curl -s -X POST http://127.0.0.1:8790/v1/auth/session \
-H "Content-Type: application/json" \
-d "{\"address\": \"$ADDR\", \"message\": $MESSAGE_JSON, \"signature\": \"$SIG\"}"
export TOKEN=… # the "token" field$MESSAGE_JSON is the message as a JSON string, exactly as returned, newlines included.
3. Create an agent and read it back#
curl -s -X POST http://127.0.0.1:8790/v1/agents \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"name": "my-lender", "preset": "steady"}'
curl -s http://127.0.0.1:8790/v1/agents -H "Authorization: Bearer $TOKEN"4. Quote a loan#
curl -s -X POST http://127.0.0.1:8790/v1/borrow/quote \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"collateral": "30", "amount": "5"}'From here, follow Agent transactions to set the agent up, or Borrow transactions to borrow from your own wallet.