// complete REST surface — 37 handlers, typed inputs, literal responses

API Reference

Every live AgentKit endpoint in one place. Find a resource, inspect its exact path and request fields, then copy a complete response shape into your integration tests.

37 live handlers JSON over HTTPS idempotency-aware
base url https://agentkit-2.polsia.app

Common contract. Authenticated endpoints accept X-API-Key or the Authorization: Bearer <key> fallback described in authentication.

API errors include code, message, and request_id; see Errors & rate limits. API responses also expose X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset; throttled responses add Retry-After.

Wallets 21 endpoints

Provision, inspect, constrain, fund, reserve, transact, transfer, and settle wallet balances. The legacy /api/wallets routes remain live alongside the /api/v1 surfaces.

POST /api/wallets No auth 201 Created

Create a wallet

Creates one wallet for an agent, applies the optional provider allowlist, and returns the new API key exactly once.

request parameters
Location Field Type Required / default Notes
body agent_id string required Unique agent identifier.
body spending_limit_cents number optional; default 0 Wallet-wide spending limit in cents.
body initial_balance_cents number optional; default 0 Must be non-negative.
body currency string optional; default "USD" Uppercase three-letter wallet currency, persisted on the wallet.
body allowed_providers string[] optional; default [] Provider names to allow on charges.
request example
curl -X POST https://agentkit-2.polsia.app/api/wallets \
  -H "Content-Type: application/json" \
  -d '{
  "agent_id": "my-agent-001",
  "spending_limit_cents": 50000,
  "initial_balance_cents": 10000,
  "currency": "USD",
  "allowed_providers": [
    "openai",
    "anthropic"
  ]
}'
response201 Created
{
  "wallet": {
    "id": 12,
    "agent_id": "my-agent-001",
    "spending_limit_cents": 50000,
    "settlement_limit_cents": null,
    "current_balance_cents": 15000,
    "reserved_balance_cents": 0,
    "currency": "USD",
    "per_call_max_cents": null,
    "per_day_max_cents": null,
    "label": "primary",
    "status": "active",
    "deleted_at": null,
    "created_at": "2026-08-10T12:00:00.000Z",
    "updated_at": "2026-08-10T12:05:00.000Z",
    "policies": [
      {
        "provider": "openai",
        "daily_limit_cents": 20000,
        "per_merchant_max_cents": null
      },
      {
        "provider": "anthropic",
        "daily_limit_cents": null,
        "per_merchant_max_cents": 5000
      }
    ]
  },
  "api_key": "ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
  "warning": "Store api_key — it is shown once and cannot be retrieved"
}

Store api_key immediately. It cannot be retrieved after this response.

GET /api/wallets API key 200 OK

Get the authenticated wallet

Returns the wallet identified by the API key, including balances, limits, timestamps, and provider policies.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/wallets \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "wallet": {
    "id": 12,
    "agent_id": "my-agent-001",
    "spending_limit_cents": 50000,
    "settlement_limit_cents": null,
    "current_balance_cents": 15000,
    "reserved_balance_cents": 0,
    "currency": "USD",
    "per_call_max_cents": null,
    "per_day_max_cents": null,
    "label": "primary",
    "status": "active",
    "deleted_at": null,
    "created_at": "2026-08-10T12:00:00.000Z",
    "updated_at": "2026-08-10T12:05:00.000Z",
    "policies": [
      {
        "provider": "openai",
        "daily_limit_cents": 20000,
        "per_merchant_max_cents": null
      },
      {
        "provider": "anthropic",
        "daily_limit_cents": null,
        "per_merchant_max_cents": 5000
      }
    ]
  }
}
PATCH /api/wallets API key 200 OK

Update wallet limits

Updates one or both limits on the authenticated wallet and returns the updated wallet row. settlement_limit_cents must be a strictly positive safe integer, or null to disable the settlement ceiling.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body spending_limit_cents number optional New wallet-wide spending limit in cents.
body settlement_limit_cents integer | null optional Strictly positive safe integer in cents, or null to remove the settlement limit.
request example
curl -X PATCH https://agentkit-2.polsia.app/api/wallets \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "spending_limit_cents": 75000,
  "settlement_limit_cents": 5000
}'
response200 OK
{
  "wallet": {
    "id": 12,
    "agent_id": "my-agent-001",
    "spending_limit_cents": 75000,
    "settlement_limit_cents": 5000,
    "current_balance_cents": 15000,
    "reserved_balance_cents": 0,
    "currency": "USD",
    "per_call_max_cents": null,
    "per_day_max_cents": null,
    "label": "primary",
    "status": "active",
    "deleted_at": null,
    "created_at": "2026-08-10T12:00:00.000Z",
    "updated_at": "2026-08-10T12:10:00.000Z",
    "policies": [
      {
        "provider": "openai",
        "daily_limit_cents": 20000,
        "per_merchant_max_cents": null
      },
      {
        "provider": "anthropic",
        "daily_limit_cents": null,
        "per_merchant_max_cents": 5000
      }
    ]
  }
}
POST /api/wallets/policies API key 200 OK

Set provider policies

Replaces the authenticated wallet’s provider policies. The providers array must be non-empty.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body providers { provider: string, daily_limit_cents?: number }[] required; non-empty Each entry names an allowed provider and may set a daily limit.
request example
curl -X POST https://agentkit-2.polsia.app/api/wallets/policies \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "providers": [
    {
      "provider": "openai",
      "daily_limit_cents": 25000
    },
    {
      "provider": "anthropic"
    }
  ]
}'
response200 OK
{
  "wallet": {
    "id": 12,
    "agent_id": "my-agent-001",
    "spending_limit_cents": 50000,
    "settlement_limit_cents": null,
    "current_balance_cents": 15000,
    "reserved_balance_cents": 0,
    "currency": "USD",
    "per_call_max_cents": 10000,
    "per_day_max_cents": 40000,
    "label": "primary",
    "status": "active",
    "deleted_at": null,
    "created_at": "2026-08-10T12:00:00.000Z",
    "updated_at": "2026-08-10T12:20:00.000Z",
    "policies": [
      {
        "provider": "openai",
        "daily_limit_cents": 25000,
        "per_merchant_max_cents": null
      },
      {
        "provider": "anthropic",
        "daily_limit_cents": null,
        "per_merchant_max_cents": 5000
      }
    ]
  }
}
POST /api/wallets/api-key API key 201 Created

Rotate the API key

Creates another key scoped to the authenticated wallet. The optional label is stored with the key.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body label string optional Human-readable key label; primary is used when omitted.
request example
curl -X POST https://agentkit-2.polsia.app/api/wallets/api-key \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "label": "production-worker"
}'
response201 Created
{
  "api_key": "ak_live_fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210",
  "warning": "Store api_key — it is shown once and cannot be retrieved"
}

The new api_key is a one-time secret. Store it before replacing the old key in your caller.

POST /api/wallets/:id/credit API key 200 OK

Credit a wallet

Adds a positive amount to the authenticated wallet. The numeric id must match the wallet owned by the key.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required The key must own the wallet identified by id.
path id integer required Numeric wallet ID.
body amount_cents number required; positive Amount to add to the balance.
request example
curl -X POST https://agentkit-2.polsia.app/api/wallets/12/credit \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "amount_cents": 5000
}'
response200 OK
{
  "wallet": {
    "id": 12,
    "agent_id": "my-agent-001",
    "spending_limit_cents": 50000,
    "settlement_limit_cents": null,
    "current_balance_cents": 20000,
    "reserved_balance_cents": 0,
    "currency": "USD",
    "per_call_max_cents": null,
    "per_day_max_cents": null,
    "label": "primary",
    "status": "active",
    "deleted_at": null,
    "created_at": "2026-08-10T12:00:00.000Z",
    "updated_at": "2026-08-10T12:15:00.000Z",
    "policies": [
      {
        "provider": "openai",
        "daily_limit_cents": 20000,
        "per_merchant_max_cents": null
      },
      {
        "provider": "anthropic",
        "daily_limit_cents": null,
        "per_merchant_max_cents": 5000
      }
    ]
  }
}
POST /api/v1/wallets No auth 201 Created

Provision a wallet (v1)

The v1 provisioning surface creates a wallet without issuing an API key and returns the persisted initial balance and uppercase three-letter currency.

request parameters
Location Field Type Required / default Notes
body agent_id string required Unique agent identifier.
body initial_balance_cents number optional; default 0 Must be non-negative.
body currency string optional; default "USD" Must be an uppercase three-letter currency code; the value is persisted on the wallet.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets \
  -H "Content-Type: application/json" \
  -d '{
  "agent_id": "my-agent-001",
  "initial_balance_cents": 10000,
  "currency": "USD"
}'
response201 Created
{
  "wallet_id": 12,
  "currency": "USD",
  "initial_balance": 10000
}
GET /api/v1/wallets API key 200 OK

List the caller’s wallets (v1)

Lists non-deleted wallets owned by the authenticated agent with newest-first keyset pagination and optional status filtering.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required The caller identity comes from this key.
query limit integer optional; default 20 Must be between 1 and 100.
query cursor string optional Opaque wallet keyset cursor from next_cursor.
query status "active" | "frozen" | "closed" optional Restricts the wallet status.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/wallets?limit=20&status=active \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "wallets": [
    {
      "id": 12,
      "label": "primary",
      "balance": 15000,
      "currency": "USD",
      "status": "active",
      "created_at": "2026-08-10T12:00:00.000Z"
    }
  ],
  "next_cursor": "d3wxNzEwMDAwMDAwMDAwMHwxMg==",
  "limit": 20
}

Soft-deleted wallets are always omitted. The next_cursor is opaque; pass it back exactly as returned. Results use stable newest-first keyset ordering by created_at and id, and limit echoes the requested page size.

GET /api/v1/wallets/:id/balance API key · wallet-scoped 200 OK

Read wallet balance

Returns the current wallet balance snapshot without loading transaction history. The numeric wallet ID must belong to the API key; missing and non-owned IDs return the same 404 wallet_not_found response.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must own the wallet ID in the path.
path id integer required Positive numeric wallet ID owned by the API key.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/wallets/12/balance \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "total": 15000,
  "available": 13000,
  "reserved": 2000,
  "currency": "USD",
  "status": "frozen",
  "as_of": "2026-08-10T12:24:00.000Z"
}

Absent, malformed, and non-owned wallet IDs all return 404 with { error: "wallet_not_found" }.

GET /api/v1/wallets/:id/transactions/export API key · wallet-scoped 200 OK

Export wallet transactions as CSV

Downloads the authenticated wallet's transactions as a CSV attachment. Optional transaction_status, transaction_period, transaction_reference, transaction_min_amount, and transaction_max_amount query parameters apply the wallet history filters. Optional transaction_sort accepts "newest" or "oldest" and defaults to "newest"; omitting the filters exports all wallet transactions in the selected order. The numeric wallet ID must belong to the API key; malformed, missing, and non-owned IDs return the same 404 wallet_not_found response.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must own the wallet ID in the path.
path id integer required Positive numeric wallet ID owned by the API key.
query transaction_sort "newest" | "oldest" optional Sorts by transaction date; defaults to "newest".
query transaction_status string optional Exact transaction status filter.
query transaction_period "all" | "30d" optional Restricts results to the inclusive last 30 days when set to "30d".
query transaction_reference string optional Case-insensitive literal substring match on merchant_ref.
query transaction_min_amount decimal amount optional Inclusive minimum absolute transaction amount in dollars, with up to two decimal places.
query transaction_max_amount decimal amount optional Inclusive maximum absolute transaction amount in dollars, with up to two decimal places.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/wallets/12/transactions/export?transaction_sort=oldest&transaction_status=approved&transaction_period=30d&transaction_reference=order-&transaction_min_amount=1.00&transaction_max_amount=25.00 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "content_type": "text/csv; charset=utf-8",
  "content_disposition": "attachment; filename=\"wallet-12-transactions.csv\"",
  "csv": "id,wallet_id,provider,amount_cents,status,blocked_reason,idempotency_key,memo,merchant_ref,created_at\\n..."
}

The response body is raw CSV, not JSON. Columns always appear in the order id, wallet_id, provider, amount_cents, status, blocked_reason, idempotency_key, memo, merchant_ref, created_at. Null values are empty fields, timestamps are ISO-8601 UTC, and an empty result still returns the header row plus a trailing newline. Invalid filter values return 400; malformed, missing, and non-owned wallet IDs return 404 wallet_not_found.

GET /api/v1/wallets/:agentId/ledger API key · path-scoped 200 OK

Read the wallet ledger

Returns a cursor-paginated ledger view with provider/type and ISO-8601 date filters.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must be scoped to the agentId in the path.
path agentId string required Agent identifier owned by the API key.
query cursor string optional Opaque ledger cursor.
query limit integer optional; capped at 50 Page size; the response reports the capped limit.
query type string optional Provider/type filter.
query from string optional ISO-8601 lower date bound.
query to string optional ISO-8601 upper date bound.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/ledger?limit=50&type=openai&from=2026-08-01T00:00:00.000Z \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "entries": [
    {
      "id": 4891,
      "timestamp": "2026-08-10T12:23:00.000Z",
      "type": "openai",
      "amount": 420,
      "counterparty": "openai",
      "status": "approved",
      "blocked_reason": null,
      "idempotency_key": "charge-2026-001"
    }
  ],
  "next_cursor": null,
  "limit": 50
}
POST /api/v1/wallets/:id/policy API key · wallet-scoped 200 OK

Set wallet-wide policy

Updates per-call, per-day, per-merchant, and allowed-merchant limits for the numeric wallet id.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must own the numeric wallet id in the path.
path id integer required Positive numeric wallet ID.
body perCallMax integer | null optional Non-negative cents or null.
body perDayMax integer | null optional Non-negative cents or null.
body perMerchantMax integer | null optional Non-negative cents or null.
body allowedMerchants string[] | null optional Non-empty strings, or null to clear the list.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets/12/policy \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "perCallMax": 10000,
  "perDayMax": 40000,
  "perMerchantMax": 5000,
  "allowedMerchants": [
    "merchant.example"
  ]
}'
response200 OK
{
  "wallet": {
    "id": 12,
    "agent_id": "my-agent-001",
    "spending_limit_cents": 50000,
    "settlement_limit_cents": null,
    "current_balance_cents": 15000,
    "reserved_balance_cents": 0,
    "currency": "USD",
    "per_call_max_cents": 10000,
    "per_day_max_cents": 40000,
    "label": "primary",
    "status": "active",
    "deleted_at": null,
    "created_at": "2026-08-10T12:00:00.000Z",
    "updated_at": "2026-08-10T12:20:00.000Z",
    "policies": [
      {
        "provider": "openai",
        "daily_limit_cents": 25000,
        "per_merchant_max_cents": null
      },
      {
        "provider": "anthropic",
        "daily_limit_cents": null,
        "per_merchant_max_cents": 5000
      }
    ]
  }
}
GET /api/v1/wallets/:agentId/transactions API key · path-scoped 200 OK

Read unified transaction history

Merges transaction and reservation history into one keyset-paginated feed for the agent in the path.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must be scoped to the agentId in the path.
path agentId string required Agent identifier owned by the API key.
query limit integer optional; default 20 Must be between 1 and 100.
query cursor string optional Opaque history cursor from next_cursor.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/transactions?limit=20 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "entries": [
    {
      "id": 4891,
      "kind": "transaction",
      "type": "spend",
      "amount": 420,
      "status": "approved",
      "created_at": "2026-08-10T12:23:00.000Z",
      "provider": "openai",
      "reservation_id": null,
      "split_id": null,
      "settlement_id": null,
      "direction": null,
      "memo": "model completion",
      "blocked_reason": null,
      "idempotency_key": "charge-2026-001"
    },
    {
      "id": 4898,
      "kind": "transaction",
      "type": "spend",
      "amount": 2500,
      "status": "approved",
      "created_at": "2026-08-10T12:32:00.000Z",
      "provider": "settlement_debit",
      "reservation_id": null,
      "split_id": null,
      "settlement_id": 7301,
      "direction": "debit",
      "memo": "agent invoice settlement",
      "blocked_reason": null,
      "idempotency_key": "settlement:7301:debit"
    }
  ],
  "next_cursor": null,
  "limit": 20
}
POST /api/v1/wallets/:agentId/transactions API key · path-scoped 201 Created

Post a wallet transaction

Atomically debits available balance and appends one approved transaction. Reusing an idempotency key replays the original transaction without a second debit.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must be scoped to the agentId in the path.
path agentId string required Agent identifier owned by the API key.
body amount_cents integer required; positive Amount to debit.
body currency "USD" optional; default "USD" Only USD is supported.
body memo string optional; max 500 Human-readable memo.
body merchant_ref string optional; max 255 Caller’s merchant/reference ID.
body provider string optional; default "wallet_transaction" Provider label for the ledger row.
body idempotency_key string | null optional; max 255 Retry key; null disables explicit deduplication.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/transactions \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "amount_cents": 420,
  "currency": "USD",
  "memo": "agent purchase",
  "merchant_ref": "order-1042",
  "provider": "wallet_transaction",
  "idempotency_key": "txn-2026-001"
}'
response201 Created
{
  "status": "approved",
  "replay": false,
  "transaction": {
    "id": 4893,
    "status": "approved",
    "amount_cents": 420,
    "provider": "wallet_transaction",
    "memo": "agent purchase",
    "merchant_ref": "order-1042",
    "idempotency_key": "txn-2026-001",
    "posted_at": "2026-08-10T12:25:00.000Z"
  },
  "balance": {
    "available": 15000,
    "reserved": 0,
    "currency": "USD",
    "as_of": "2026-08-10T12:23:01.000Z"
  }
}

A retry with txn-2026-001 returns replay: true and leaves the wallet balance unchanged.

POST /api/v1/wallets/:agentId/fund API key · path-scoped 201 Created

Create a Stripe funding intent

Creates a 24-hour funding intent and returns the configured Stripe payment URL. The amount must also match the configured Stripe denomination when STRIPE_TOPUP_AMOUNT_CENTS is set.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must be scoped to the agentId in the path.
path agentId string required Agent identifier owned by the API key.
body amount_cents integer required; positive USD amount to fund.
body currency "USD" optional; default "USD" Only USD is supported; configured Stripe denomination rules also apply.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/fund \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "amount_cents": 5000,
  "currency": "USD"
}'
response201 Created
{
  "fund_intent_id": 4821,
  "payment_url": "https://checkout.stripe.com/pay/cs_live_agentkit_4821",
  "amount_cents": 5000,
  "currency": "USD",
  "expires_at": "2026-08-11T12:30:00.000Z"
}

Redirect the buyer to payment_url, then use the returned fund_intent_id with the claim endpoint.

POST /api/v1/wallets/:agentId/fund/claim API key · path-scoped 200 OK

Claim a verified Stripe top-up

Verifies the Stripe Checkout session with the platform, then atomically credits the wallet and writes the stripe_topup ledger row.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must be scoped to the agentId in the path.
path agentId string required Agent identifier owned by the API key.
body session_id string required Stripe Checkout session ID returned after payment.
body fund_intent_id integer required Funding intent ID returned by the fund call.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/fund/claim \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "session_id": "cs_live_agentkit_4821",
  "fund_intent_id": 4821
}'
response200 OK
{
  "status": "completed",
  "replay": false,
  "transaction": {
    "id": 4894,
    "status": "approved",
    "amount_cents": 5000,
    "provider": "stripe_topup",
    "memo": "stripe top-up",
    "merchant_ref": "fund:4821",
    "idempotency_key": "fund:4821",
    "posted_at": "2026-08-10T12:30:00.000Z"
  },
  "balance": {
    "available": 20000,
    "reserved": 0,
    "currency": "USD",
    "as_of": "2026-08-10T12:30:01.000Z"
  }
}

A completed intent can be claimed again as status already_completed. If Stripe verification is not ready, the endpoint returns 402 payment_not_verified; retry shortly. The credit is idempotent and cannot double-post.

POST /api/v1/wallets/:agentId/reservations API key · path-scoped 201 Created

Create a fund reservation

Moves amount_cents from available into reserved for a bounded TTL. Reservations are limited to 100000000 cents and are safe to retry with an idempotency key.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must be scoped to the agentId in the path.
path agentId string required Agent identifier owned by the API key.
body amount_cents integer required; positive; max 100000000 Amount to hold.
body currency "USD" optional; default "USD" Only USD is supported.
body ttl_seconds integer required; 1..604800 Reservation lifetime in seconds.
body memo string optional; max 500 Human-readable memo.
body idempotency_key string | null optional; max 255 Retry key for the same reservation.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/reservations \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "amount_cents": 2000,
  "currency": "USD",
  "ttl_seconds": 300,
  "memo": "pre-auth openai",
  "idempotency_key": "rsv-2026-001"
}'
response201 Created
{
  "reservation_id": 71,
  "status": "active",
  "replay": false,
  "amount_cents": 2000,
  "currency": "USD",
  "memo": "pre-auth openai",
  "idempotency_key": "rsv-2026-001",
  "expires_at": "2026-08-10T12:35:00.000Z",
  "balance": {
    "available": 13000,
    "reserved": 2000,
    "currency": "USD",
    "as_of": "2026-08-10T12:24:00.000Z"
  }
}
POST /api/v1/wallets/:agentId/reservations/:reservationId/commit API key 200 OK

Commit a reservation

Finalizes an active hold, debits both current and reserved balance, and writes a reservation_commit transaction. Repeating the call replays the same transaction.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must own the agentId and reservation in the path.
path agentId string required Agent identifier owned by the API key.
path reservationId integer required; positive Reservation ID.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/reservations/71/commit \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "reservation_id": 71,
  "status": "committed",
  "replay": false,
  "transaction_id": 4895,
  "balance": {
    "available": 15000,
    "reserved": 0,
    "currency": "USD",
    "as_of": "2026-08-10T12:23:01.000Z"
  }
}
POST /api/v1/wallets/:agentId/reservations/:reservationId/release API key 200 OK

Release a reservation

Releases an active hold back to available balance and records a reservation_release transaction. A successful release returns status released.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Must own the agentId and reservation in the path.
path agentId string required Agent identifier owned by the API key.
path reservationId integer required; positive Reservation ID.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallets/my-agent-001/reservations/71/release \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "reservation_id": 71,
  "status": "released",
  "replay": false,
  "transaction_id": 4896,
  "balance": {
    "available": 15000,
    "reserved": 0,
    "currency": "USD",
    "as_of": "2026-08-10T12:23:01.000Z"
  }
}
POST /api/v1/wallet/transfer API key 201 Created

Transfer between wallets

Atomically transfers funds from the caller’s wallet to another wallet. The API key must own from_wallet_id.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required The key must own from_wallet_id.
body from_wallet_id integer required Source wallet ID.
body to_wallet_id integer required Destination wallet ID; must differ from the source.
body amount_cents number required; positive; max 100000000 Amount to transfer.
body idempotency_key string optional Caller retry key; returned as null when omitted.
body description string optional Description returned in the response.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/wallet/transfer \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "from_wallet_id": 12,
  "to_wallet_id": 18,
  "amount_cents": 2500,
  "idempotency_key": "xfer-2026-001",
  "description": "settlement"
}'
response201 Created
{
  "status": "completed",
  "transfer_id": 4897,
  "from_wallet_id": 12,
  "to_wallet_id": 18,
  "amount_cents": 2500,
  "description": "settlement",
  "from_balance_cents": 12500,
  "to_balance_cents": 22500,
  "idempotency_key": "xfer-2026-001"
}
POST /api/v1/settlements API key 201 Created

Settle between wallets

Atomically moves available funds between two active wallets in the same currency and writes linked settlement_debit and settlement_credit ledger rows. The API key must own from_wallet_id; the destination may belong to another agent.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required The key must own from_wallet_id; the destination wallet may belong to another agent.
body from_wallet_id integer required Source wallet ID.
body to_wallet_id integer required Destination wallet ID; must differ from the source.
body amount_cents integer required; positive; max 100000000 Amount to settle from available source funds.
body currency string optional; default "USD" Uppercase three-letter currency matching both wallets.
header Idempotency-Key string optional Optional; max 255 characters. Reuse the same value for retries.
body description string | null optional; max 500 Description copied to both linked ledger rows.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/settlements \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Idempotency-Key: settle-2026-001" \
  -H "Content-Type: application/json" \
  -d '{
  "from_wallet_id": 12,
  "to_wallet_id": 18,
  "amount_cents": 2500,
  "currency": "USD",
  "description": "agent invoice settlement"
}'
response201 Created
{
  "status": "completed",
  "replay": false,
  "settlement_id": 7301,
  "from_wallet_id": 12,
  "to_wallet_id": 18,
  "amount_cents": 2500,
  "currency": "USD",
  "debit_transaction_id": 4898,
  "credit_transaction_id": 4899,
  "from_balance_cents": 12500,
  "to_balance_cents": 22500,
  "idempotency_key": "settle-2026-001"
}

Malformed requests, self-settlement, and amounts above the source wallet’s settlement_limit_cents return 400. A limit violation uses settlement_limit_exceeded and includes amount_cents plus settlement_limit_cents. Source ownership and insufficient available funds return 403; missing wallets return 404; inactive wallets and idempotency conflicts return 409; currency mismatches return 422; unexpected atomic failures return settlement_failed with 500. Idempotency-Key is scoped to the authenticated source wallet: identical retries replay the persisted response, while changed parameters return idempotency_conflict without creating ledger rows.

response variant400 Bad Request
{
  "error": "settlement_limit_exceeded",
  "reason": "amount_cents exceeds configured settlement limit",
  "amount_cents": 5001,
  "settlement_limit_cents": 5000
}

The source wallet’s balances and settlement ledger remain unchanged.

Agent identities 4 endpoints

Create and retrieve one owner-scoped identity record for the authenticated wallet, including its current reputation summary, wallet activity counts, and payment-derived reputation history.

POST /api/v1/agent-identities API key 201 Created

Create an agent identity

Creates the one identity allowed for the wallet represented by the API key. agent_id comes from the authenticated key and cannot be supplied by the request.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Required. The identity is owned by the wallet associated with this key.
body name string required; max 255 Non-empty display name.
body description string | null optional; max 2000 Optional description.
body capabilities string[] optional; default [] At most 50 non-empty strings; each is limited to 255 characters.
body metadata object optional; default {} JSON object only; arrays and null are rejected.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/agent-identities \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Research Agent",
  "description": "Finds and summarizes useful papers.",
  "capabilities": [
    "search",
    "summarize"
  ],
  "metadata": {
    "team": "research"
  }
}'
response201 Created
{
  "identity": {
    "id": 91,
    "agent_id": "my-agent-001",
    "name": "Research Agent",
    "description": "Finds and summarizes useful papers.",
    "capabilities": [
      "search",
      "summarize"
    ],
    "metadata": {
      "team": "research"
    },
    "created_at": "2026-09-05T07:00:00.000Z",
    "updated_at": "2026-09-05T07:00:00.000Z",
    "reputation": {
      "score": 0,
      "review_count": 0,
      "completed_activity_count": 0,
      "failure_count": 0
    }
  }
}

The first identity for a wallet is created with reputation.score 0, reputation.review_count 0, reputation.completed_activity_count 0, and reputation.failure_count 0. The activity counters are wallet transaction aggregates: approved transactions count as completed activity and blocked transactions count as failures; both are zero when no activity exists.

response variant400 Bad Request
{
  "error": "name is required"
}

Returned when name, description, capabilities, or metadata fails validation.

response variant409 Conflict
{
  "error": "identity_already_exists"
}

Returned when the authenticated wallet already owns an identity.

GET /api/v1/agent-identities API key 200 OK

List agent identities

Returns the identities owned by the wallet represented by the authenticated API key. The owner identity is never taken from the query string, and inaccessible identities or identities on deleted wallets are omitted.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Required. Ownership comes from the authenticated API key.
query limit integer optional; default 20; max 100 Number of identities to return.
query cursor string optional Opaque keyset cursor returned as next_cursor.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/agent-identities?limit=2 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "identities": [
    {
      "id": 91,
      "agent_id": "my-agent-001",
      "name": "Research Agent",
      "description": "Finds and summarizes useful papers.",
      "capabilities": [
        "search",
        "summarize"
      ],
      "metadata": {
        "team": "research"
      },
      "created_at": "2026-09-05T07:00:00.000Z",
      "updated_at": "2026-09-05T07:00:00.000Z",
      "reputation": {
        "score": 0,
        "review_count": 0,
        "completed_activity_count": 0,
        "failure_count": 0
      },
      "status": "active",
      "kyc_status": "verified"
    }
  ],
  "next_cursor": "aXwyMDI2LTA5LTA1VDA3OjAwOjAwLjAwMFp8OTE=",
  "limit": 2
}

Identities are ordered newest first by created_at, then by id DESC. Pass the opaque next_cursor value to continue without duplicates. Each item uses the same resource fields already exposed by the individual endpoint, including status, kyc_status, and the numeric reputation summary under reputation.

response variant400 Bad Request
{
  "error": "invalid_limit"
}

Returned when limit is not an integer from 1 through 100.

response variant400 Bad Request
{
  "error": "invalid_cursor"
}

Returned when cursor is malformed or belongs to another cursor namespace.

response variant400 Bad Request
{
  "error": "invalid_query"
}

Returned when agent_id is supplied; the owner is always taken from the authenticated API key.

GET /api/v1/agent-identities/:id API key 200 OK

Get an agent identity

Returns the identity only when :id belongs to the wallet represented by the API key, with the current reputation summary nested under reputation. completed_activity_count counts approved wallet transactions and failure_count counts blocked wallet transactions; both are zero when no activity exists.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Required. Ownership is checked in the identity lookup.
path id positive safe integer required Identity record ID.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/agent-identities/91 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "identity": {
    "id": 91,
    "agent_id": "my-agent-001",
    "name": "Research Agent",
    "description": "Finds and summarizes useful papers.",
    "capabilities": [
      "search",
      "summarize"
    ],
    "metadata": {
      "team": "research"
    },
    "created_at": "2026-09-05T07:00:00.000Z",
    "updated_at": "2026-09-05T07:00:00.000Z",
    "reputation": {
      "score": 0,
      "review_count": 0,
      "completed_activity_count": 0,
      "failure_count": 0
    }
  }
}
response variant404 Not Found
{
  "error": "identity_not_found"
}

Malformed, missing, and non-owned IDs intentionally share the same error response and reveal no identity or reputation fields.

GET /api/v1/agent-identities/:id/reputation/history API key 200 OK

Get reputation history

Returns newest-first reputation events derived from completed wallet payment activity. Each approved transaction contributes one payment_completed event with a score impact of 1; split-payment rows use their parent payment reference when present.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Required. The API key must own the identity.
path id positive safe integer required Identity record ID.
query limit integer optional; default 20; max 100 Number of events to return.
query cursor string optional Opaque keyset cursor returned as next_cursor.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/agent-identities/91/reputation/history?limit=2 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "events": [
    {
      "event_type": "payment_completed",
      "payment_reference": "payment:77",
      "score_impact": 1,
      "created_at": "2026-09-07T12:00:00.000Z"
    },
    {
      "event_type": "payment_completed",
      "payment_reference": "invoice-1042",
      "score_impact": 1,
      "created_at": "2026-09-06T12:00:00.000Z"
    }
  ],
  "next_cursor": "MjAyNi0wOS0wNlQxMjowMDowMC4wMDBafDY5OQ==",
  "limit": 2
}

Events are ordered by created_at DESC, then transaction ID DESC. Use next_cursor to continue without duplicates. payment_reference is the parent payment reference for split payments, or the source transaction/payment reference for direct wallet payment rows. The stored reputation summary is not changed by this read.

response variant400 Bad Request
{
  "error": "invalid_limit"
}

Returned when limit is not an integer from 1 through 100.

response variant400 Bad Request
{
  "error": "invalid_cursor"
}

Returned when cursor is not a valid reputation history keyset cursor.

response variant404 Not Found
{
  "error": "identity_not_found"
}

Malformed, missing, and non-owned IDs intentionally share the same response, so inaccessible identities reveal no event data.

Webhooks 6 endpoints

Manage webhook registrations and delivery attempts here. The receive-side payload envelope, HMAC verification, and retry schedule are documented in the Webhooks guide.

POST /api/v1/webhooks API key 201 Created

Register a webhook

Registers an HTTPS endpoint, or an http://localhost endpoint for development, for one or more supported events.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body url string required Valid HTTPS URL, or http://localhost / http://127.0.0.1 for development.
body events string[] required; non-empty Supported names: wallet.funded, wallet.spent, reservation.committed, reservation.released, charge_sent, balance_low, test.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/webhooks \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://example.com/agentkit-hook",
  "events": [
    "wallet.funded",
    "wallet.spent"
  ]
}'
response201 Created
{
  "webhook": {
    "id": 44,
    "url": "https://example.com/agentkit-hook",
    "events": [
      "wallet.funded",
      "fund_received",
      "wallet.spent",
      "wallet_spent"
    ],
    "is_active": true
  },
  "signing_secret": "9f8e7d6c5b4a32100123456789abcdef0123456789abcdef0123456789abcdef",
  "warning": "Store signing_secret — it is shown once and cannot be retrieved"
}

The signing_secret is a one-time secret. It is never returned by list or delivery endpoints.

GET /api/v1/webhooks API key 200 OK

List active webhooks

Returns active registrations for the authenticated wallet. Signing secrets are never exposed.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/webhooks \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "webhooks": [
    {
      "id": 44,
      "url": "https://example.com/agentkit-hook",
      "events": [
        "wallet.funded",
        "fund_received",
        "wallet.spent",
        "wallet_spent"
      ],
      "status": "active",
      "created_at": "2026-08-10T12:40:00.000Z"
    }
  ]
}
POST /api/v1/webhooks/test API key 200 OK

Test all active webhooks

Dispatches an event to matching active registrations. event is optional and defaults to test.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body event string optional; default "test" Event name passed to the dispatcher.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/webhooks/test \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "event": "test"
}'
response200 OK
{
  "dispatched": 1,
  "results": [
    {
      "webhook_id": 44,
      "url": "https://example.com/agentkit-hook"
    }
  ]
}

When there are no active registrations, the exact response is { dispatched: 0, results: [] }.

POST /api/v1/webhooks/:id/test API key 200 OK

Test one webhook

Sends one synthetic webhook.test payload, records the attempt, and reports the HTTP result and HMAC attachment.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
path id integer required Numeric webhook ID owned by the API key.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/webhooks/44/test \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "webhook_id": 44,
  "url": "https://example.com/agentkit-hook",
  "event": "webhook.test",
  "status": 200,
  "latency_ms": 48,
  "ok": true,
  "error": null,
  "hmac_attached": true
}
DELETE /api/v1/webhooks/:id API key 204 No Content

Delete a webhook

Deletes the owned webhook registration. The successful response has no JSON body.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
path id integer required Numeric webhook ID owned by the API key.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X DELETE https://agentkit-2.polsia.app/api/v1/webhooks/44 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response204 No Content
204 No Content — no JSON body is returned.

204 No Content — the response body is empty; do not attempt to parse JSON.

GET /api/v1/webhooks/:id/deliveries API key 200 OK

List webhook deliveries

Returns the newest per-attempt delivery records for the owned webhook, including retry and dead-letter state.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
path id integer required Numeric webhook ID owned by the API key.
query limit integer optional; default 20; capped at 100 Number of delivery rows.
query offset integer optional; default 0 Non-negative offset.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/webhooks/44/deliveries?limit=20&offset=0 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "deliveries": [
    {
      "delivery_id": "wh_44_20260810_0001",
      "attempt_number": 1,
      "event": "wallet.spent",
      "attempted_at": "2026-08-10T12:42:00.000Z",
      "status": "delivered",
      "http_status": 200,
      "latency_ms": 48,
      "hmac_attached": true,
      "error": null,
      "next_retry_at": null
    }
  ],
  "limit": 20,
  "offset": 0
}

Providers 2 endpoints

Enumerate the public provider catalog without a key or submit an authenticated listing request. Both endpoints use the same canonical catalog categories as /providers.

GET /api/v1/providers No auth 200 OK

List providers

Returns catalog entries with keyset pagination, category filtering, and case-insensitive name/description search.

request parameters
Location Field Type Required / default Notes
query limit integer optional; default 20 Must be between 1 and 100.
query cursor string optional Opaque provider cursor from next_cursor.
query category string optional One of the CATEGORIES IDs: wallets, payments, split-routing, webhooks, sandbox.
query q string optional Case-insensitive substring search across provider name and description.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/providers?limit=20&category=wallets&q=wallet
response200 OK
{
  "providers": [
    {
      "id": "wallet-crud",
      "name": "Wallet Lifecycle",
      "category": "wallets",
      "category_label": "Wallets",
      "description": "Create, fetch, and update per-agent wallets with X-API-Key auth.",
      "capabilities": [
        "Create a wallet with an agent_id, spending cap, and initial balance",
        "Fetch the current wallet state with an X-API-Key",
        "PATCH the spending_limit_cents at any time",
        "Rotate the API key scoped to the wallet"
      ],
      "pricing": {
        "model": "free",
        "note": "No transaction fee — wallet administration only."
      },
      "auth": {
        "type": "api_key",
        "header": "X-API-Key",
        "scopes": [
          "wallet:read",
          "wallet:write"
        ]
      }
    }
  ],
  "next_cursor": null,
  "limit": 20
}

The catalog is public and in memory, so this call is useful for discovery before an agent has a wallet key.

POST /api/v1/providers/submissions API key 201 Created

Submit a provider

Creates an authenticated provider listing request for later review. The provider is not published automatically.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required Required. The authenticated wallet is recorded as the submitter; use X-API-Key or Authorization: Bearer.
body provider_name string required; max 255 Human-readable provider name.
body category string required One of: wallets, payments, split-routing, webhooks, sandbox.
body description string required; max 5000 Provider overview shown to reviewers.
body capabilities string[] required; non-empty; max 50 Non-empty capability descriptions; each is limited to 255 characters.
body pricing_model string required One of: free, per_transaction, passthrough.
body authentication_requirements string required; max 2000 Keys, headers, scopes, or no-auth requirements.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/providers/submissions \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "provider_name": "Example Inference API",
  "category": "payments",
  "description": "A provider for metered inference requests.",
  "capabilities": [
    "Metered inference calls",
    "Usage reporting"
  ],
  "pricing_model": "per_transaction",
  "authentication_requirements": "Bearer API key in the Authorization header."
}'
response201 Created
{
  "submission": {
    "id": 901,
    "wallet_id": 12,
    "provider_name": "Example Inference API",
    "category": "payments",
    "description": "A provider for metered inference requests.",
    "capabilities": [
      "Metered inference calls",
      "Usage reporting"
    ],
    "pricing_model": "per_transaction",
    "authentication_requirements": "Bearer API key in the Authorization header.",
    "status": "pending_review",
    "created_at": "2026-09-02T12:00:00.000Z",
    "updated_at": "2026-09-02T12:00:00.000Z"
  },
  "status": "pending_review"
}

The API key is used for authentication only and is never persisted with the submission.

response variant400 Bad Request
{
  "error": "category must be one of: wallets, payments, split-routing, webhooks, sandbox"
}

Returned when required fields, capabilities, category, or pricing_model fail validation.

response variant401 Unauthorized
{
  "error": "Missing X-API-Key header"
}

Returned before submission validation or insertion when the API key is missing or invalid.

Payments 6 endpoints

Charge, split, and exercise the payment surfaces. Sandbox calls are deterministic mock operations; the Stripe callback is authenticated with Stripe-Signature rather than an API key.

POST /api/pay API key 201 Created

Authorize and charge

Runs the wallet policy engine, appends a transaction row, and deducts the balance when approved.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
body provider string required Provider to charge.
body amount_cents number required; positive Charge amount in cents.
body idempotency_key string optional Stored on the transaction for caller-side retry correlation.
request example
curl -X POST https://agentkit-2.polsia.app/api/pay \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "provider": "openai",
  "amount_cents": 420,
  "idempotency_key": "charge-2026-001"
}'
response201 Created
{
  "status": "approved",
  "transaction": {
    "id": 4891,
    "wallet_id": 12,
    "provider": "openai",
    "amount_cents": 420,
    "status": "approved",
    "blocked_reason": null,
    "idempotency_key": "charge-2026-001",
    "memo": "model completion",
    "merchant_ref": "invoice-1042",
    "created_at": "2026-08-10T12:23:00.000Z"
  },
  "balance_cents": 14580
}
response variant403 Blocked
{
  "status": "blocked",
  "reason": "provider_not_allowed",
  "transaction": {
    "id": 4892,
    "wallet_id": 12,
    "provider": "openai",
    "amount_cents": 420,
    "status": "blocked",
    "blocked_reason": "provider_not_allowed",
    "idempotency_key": "charge-2026-002",
    "memo": null,
    "merchant_ref": null,
    "created_at": "2026-08-10T12:23:00.000Z"
  }
}

The blocked reason is one of per_day_max_exceeded, provider_not_allowed, per_merchant_max_exceeded, per_call_max_exceeded, daily_limit_exceeded, spending_limit_exceeded, or insufficient_balance.

GET /api/transactions API key 200 OK

List transactions

Lists the authenticated wallet’s transaction rows with optional provider/status filters and offset pagination.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required API key for the wallet that owns this resource.
query provider string optional Exact provider filter.
query status string optional Transaction status filter, such as approved or blocked.
query limit integer optional; default 50; capped at 100 Number of rows.
query offset integer optional; default 0 Offset into the result set.
body none — not accepted This endpoint does not accept a request body.
request example
curl -X GET https://agentkit-2.polsia.app/api/transactions?provider=openai&status=approved&limit=50&offset=0 \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
response200 OK
{
  "transactions": [
    {
      "id": 4891,
      "wallet_id": 12,
      "provider": "openai",
      "amount_cents": 420,
      "status": "approved",
      "blocked_reason": null,
      "idempotency_key": "charge-2026-001",
      "memo": "model completion",
      "merchant_ref": "invoice-1042",
      "created_at": "2026-08-10T12:23:00.000Z"
    }
  ],
  "limit": 50,
  "offset": 0
}
POST /api/v1/payments/split API key 201 Created

Split a payment across agents

Atomically allocates one charge across at least two unique agent IDs. All child wallet debits commit together or roll back together.

request parameters
Location Field Type Required / default Notes
header X-API-Key string required The initiator wallet is identified by the key.
body provider string required Provider label for the parent payment.
body charge_amount_cents integer required; positive Total charge to allocate.
body routing_rule { type: "percentage" | "fixed", value: integer } required For percentage, value × agents must equal 100; for fixed, value × agents must equal the charge.
body agents string[] required; at least 2 unique Agent IDs whose wallets receive the allocations.
body idempotency_key string optional; max 255 Retry key for the parent payment.
body memo string optional; max 500 Memo copied to child transaction rows.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/payments/split \
  -H "X-API-Key: ak_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" \
  -H "Content-Type: application/json" \
  -d '{
  "provider": "openai",
  "charge_amount_cents": 1000,
  "routing_rule": {
    "type": "percentage",
    "value": 50
  },
  "agents": [
    "agent-A",
    "agent-B"
  ],
  "idempotency_key": "split-2026-001",
  "memo": "shared inference cost"
}'
response201 Created
{
  "status": "completed",
  "payment_id": 77,
  "charge_amount_cents": 1000,
  "provider": "openai",
  "replay": false,
  "allocations": [
    {
      "agent_id": "agent-A",
      "wallet_id": 12,
      "amount_cents": 500,
      "status": "approved"
    },
    {
      "agent_id": "agent-B",
      "wallet_id": 18,
      "amount_cents": 500,
      "status": "approved"
    }
  ],
  "idempotency_key": "split-2026-001"
}

A retry with the same idempotency_key returns status replay and replay: true with the original allocations.

GET /api/v1/sandbox/balance No auth 200 OK

Read sandbox balance

Returns the in-memory mock wallet. It does not read or change a real wallet balance.

request parameters
Location Field Type Required / default Notes
— none — — No path, query, header, or body parameters.
request example
curl -X GET https://agentkit-2.polsia.app/api/v1/sandbox/balance
response200 OK
{
  "wallet": {
    "id": 99,
    "agent_id": "sandbox-agent",
    "spending_limit_cents": 50000,
    "current_balance_cents": 12345,
    "policies": [
      {
        "provider": "openai",
        "daily_limit_cents": null
      },
      {
        "provider": "anthropic",
        "daily_limit_cents": null
      }
    ]
  },
  "sandbox": true
}
POST /api/v1/sandbox/simulate No auth 201 Created

Simulate a sandbox charge

Runs allowlist, daily-limit, spending-limit, and balance checks against the in-memory mock without moving real funds.

request parameters
Location Field Type Required / default Notes
body provider string required Provider to simulate.
body amount_cents number required; positive Mock charge amount in cents.
request example
curl -X POST https://agentkit-2.polsia.app/api/v1/sandbox/simulate \
  -H "Content-Type: application/json" \
  -d '{
  "provider": "openai",
  "amount_cents": 420
}'
response201 Created
{
  "status": "approved",
  "transaction": {
    "id": 48210,
    "wallet_id": 99,
    "provider": "openai",
    "amount_cents": 420,
    "status": "approved",
    "blocked_reason": null,
    "idempotency_key": null,
    "created_at": "2026-08-10T12:31:00.000Z"
  },
  "balance_cents": 11925,
  "sandbox": true
}
response variant403 Blocked
{
  "status": "blocked",
  "reason": "provider_not_allowed",
  "transaction": {
    "id": 48211,
    "wallet_id": 99,
    "provider": "unknown-provider",
    "amount_cents": 420,
    "status": "blocked",
    "blocked_reason": "provider_not_allowed",
    "idempotency_key": null,
    "created_at": "2026-08-10T12:31:00.000Z"
  },
  "sandbox": true
}

Blocked sandbox responses retain the sandbox: true marker and never change current_balance_cents.

POST /api/stripe/funding-webhook Stripe-Signature 200 OK

Receive the Stripe funding callback

Verifies the Stripe signature over the raw request body, processes payment_intent.succeeded funding events, and credits the linked wallet once.

request parameters
Location Field Type Required / default Notes
header Stripe-Signature string required Stripe v1 signature with t and v1 values; API keys are not accepted.
body raw body bytes containing JSON required Expected event shape: { type: "payment_intent.succeeded", data: { object: { id: string, metadata: { fund_intent_id: string } } } }.
body event.type "payment_intent.succeeded" required for crediting Other event types are acknowledged and ignored.
body data.object.metadata.fund_intent_id string required for crediting Numeric funding intent ID as Stripe metadata.
request example
curl -X POST https://agentkit-2.polsia.app/api/stripe/funding-webhook \
  -H "Content-Type: application/json" \
  -H "Stripe-Signature: t=1787836800,v1=a1b2c3d4e5f60123456789abcdef0123456789abcdef0123456789abcdef0123" \
  --data-raw '{"type":"payment_intent.succeeded","data":{"object":{"id":"pi_3N9AgentKit001","metadata":{"fund_intent_id":"4821"}}}}'
response200 OK
{
  "received": true,
  "wallet_id": 12
}

401 invalid_signature or timestamp_too_old; 400 invalid_json; 503 webhook_not_configured when STRIPE_WEBHOOK_SECRET is absent. server.js mounts express.raw() before express.json(), so signature verification receives the original bytes.

response variant200 Acknowledged
{
  "received": true
}

Ignored event, missing payment object or metadata, unknown intent, and non-pending intent are acknowledged without a wallet_id. A completed intent returns { received: true, status: "already_completed" }.