Agent SDK quickstart

Register an agent and submit a signed payment intent. Three ways: TypeScript, Python, or curl + openssl.

SDKs not published yet

@sorenpay/agent-sdk and sorenpay-agent-sdk aren't on npm or PyPI yet, so the install commands below don't work today. Use curl + openssl, or ask support@sorenpay.com for a copy. The SDK clients also default to a base URL that doesn't resolve: pass https://sorenpay.com as the base URL.

TypeScript

Installbash
npm install @sorenpay/agent-sdk
quickstart.tstypescript
import { SorenAgent } from "@sorenpay/agent-sdk";

const soren = new SorenAgent({
apiKey: process.env.SOREN_API_KEY!, // apk_…
baseUrl: "https://sorenpay.com",
});

// 1. Register (generates Ed25519 keypair locally; returns the private key ONCE)
const { agent, privateKeyPem } = await soren.register({
agentName: "research-assistant",
protocols: ["TAP", "MPP", "ACP"],
});
// → persist privateKeyPem to your secret store

// 2. Sign + submit a payment intent
const result = await soren.submitIntent({
agentId: agent.id,
privateKeyPem,
merchant: { name: "OpenAI API", mcc: "5734" },
amount: { currency: "USD", cents: 1500 },
protocol: "TAP",
ttlSeconds: 300,
});

console.log(result);
// → { accepted: true, log_id: "…", intent_id: "…", next: { message: "…" } }

Python

Installbash
pip install sorenpay-agent-sdk
quickstart.pypython
import os
from sorenpay_agent import SorenAgent

soren = SorenAgent(api_key=os.environ["SOREN_API_KEY"], base_url="https://sorenpay.com")

# 1. Register (generates Ed25519 locally)
register = soren.register(
  agent_name="research-assistant",
  protocols=["TAP", "MPP", "ACP"],
)
# → persist register.private_key_pem to your secret store

# 2. Sign + submit
result = soren.submit_intent(
  agent_id=register.agent.id,
  private_key_pem=register.private_key_pem,
  merchant={"name": "OpenAI API", "mcc": "5734"},
  amount={"currency": "USD", "cents": 1500},
  protocol="TAP",
  ttl_seconds=300,
)

print(result)

curl and openssl (no SDK)

Generate Ed25519 keypairbash
openssl genpkey -algorithm Ed25519 -out agent.key
openssl pkey -in agent.key -pubout -out agent.pub
Register the agentbash
PUBKEY=$(cat agent.pub | tr -d '\n')
curl -X POST https://sorenpay.com/api/agents \
-H "Authorization: Bearer $SOREN_API_KEY" \
-H "Content-Type: application/json" \
-d "{
  \"agentName\": \"research-assistant\",
  \"protocols\": [\"TAP\", \"MPP\", \"ACP\"],
  \"publicKeyPem\": \"$PUBKEY\"
}"

Signing the canonical JSON is the fiddly part — use one of the SDKs unless you have to. The signing step requires:

  1. Sort all keys recursively
  2. Strip whitespace
  3. Sign with Ed25519 one-shot (crypto.sign(null, …) in Node)
  4. Base64url-encode the signature

Error codes

HTTPCodeWhat
401signature_invalidThe signature doesn't check out. reason says why: bad_signature, kid_mismatch, intent_expired or intent_iat_future
422intent_replayDuplicate intent_id
403kyb_requiredRegistering an agent while the request is live and the workspace's business verification isn't approved
429rate_limitedMore than 100 requests a minute on one key. Wait for Retry-After

Next