⚡ Agent Quickstart

Your first 60 seconds with AgentBooks

Mint a key, post a transaction, read back your tax summary — four curl invocations stand between a fresh agent and a balanced double-entry ledger. Copy, paste, run.

See pricing
No OAuth / no webhooks Bearer-key auth Drop-in curl

From zero to a posted journal entry

Replace $BASE_URL with https://agentbooks.polsia.app, set $BOOTSTRAP_KEY with the key returned by POST /api/register, and walk the steps below in order.

1

Mint a labelled API key

Use the bootstrap key returned by POST /api/register to mint an additional, labelled key for this agent. The bootstrap key has full org authority — issue narrowly-scoped keys for production workloads.

POST $BASE_URL/api/keys
Note: Calling POST /api/auth/keys is documented in some summaries, but the live route is POST /api/keys. The /api/auth/ prefix is not mounted.
curl -X POST https://agentbooks.polsia.app/api/keys \
  -H "Authorization: Bearer $BOOTSTRAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"label": "my-agent"}'
Example response — 201 Created
{
  "api_key": "ab_a1b2c3d4e5f6...64hex",
  "prefix": "ab_a1b2c3d4",
  "last_4": "f6a9",
  "label": "my-agent",
  "note": "Save this API key — it cannot be retrieved again."
}
2

Verify the new key with whoami

Round-trip the freshly minted key to confirm it's live and the right one is wired up. Returns the org snapshot and last-4 + label of the key that authenticated the request.

GET $BASE_URL/api/keys/whoami
Note: Live route is GET /api/keys/whoami. The /api/auth/ prefix is not mounted.
curl https://agentbooks.polsia.app/api/keys/whoami \
  -H "Authorization: Bearer $NEW_KEY"
Example response — 200 OK
{
  "organization": {
    "id": 42,
    "name": "My AI Agent",
    "slug": "my-ai-agent-l8xq3f"
  },
  "key": {
    "prefix": "ab_a1b2c3d4",
    "last_4": "f6a9",
    "label": "my-agent"
  }
}
3

Record and post a journal entry

Two calls are required: POST /api/transactions records the row, and a follow-up POST /api/transactions/<id>/post closes the books with a balanced debit/credit pair. The post step is the call that actually creates the journal entry — transactions do not auto-post from the create call.

POST $BASE_URL/api/transactions
curl -X POST https://agentbooks.polsia.app/api/transactions \
  -H "Authorization: Bearer $NEW_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 49.99,
    "currency": "USD",
    "description": "Pro plan subscription",
    "source": "manual"
  }'
Example response — 201 Created
{
  "transaction": {
    "id": 182,
    "organization_id": 42,
    "amount": "49.99",
    "currency": "USD",
    "description": "Pro plan subscription",
    "source": "manual",
    "status": "pending",
    "agent_id": 7,
    "occurred_at": "2026-07-30T14:22:08.123Z"
  }
}
POST $BASE_URL/api/transactions/<id>/post
curl -X POST https://agentbooks.polsia.app/api/transactions/182/post \
  -H "Authorization: Bearer $NEW_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
Example response — 200 OK
{
  "transaction_id": 182,
  "journal_entry": {
    "id": 55,
    "reference": "TX-182",
    "memo": "Pro plan subscription",
    "agent_id": 7
  },
  "debit_account_id": 101,
  "credit_account_id": 106,
  "amount": 49.99
}
4

Compute and read back your tax obligation

Tax endpoints are per-agent: send your API key plus an X-Agent-Id header. The compute call is idempotent — running it twice for the same quarter returns the same obligation.

POST $BASE_URL/api/tax/calculate
curl -X POST https://agentbooks.polsia.app/api/tax/calculate \
  -H "Authorization: Bearer $NEW_KEY" \
  -H "X-Agent-Id: 7" \
  -H "Content-Type: application/json" \
  -d '{"tax_year": 2026, "quarter": 3}'
Example response — 200 OK
{
  "obligation": {
    "id": 11,
    "agent_id": 7,
    "tax_year": 2026,
    "quarter": 3,
    "jurisdiction": "US",
    "gross_amount": "49.99",
    "tax_due": "7.06"
  },
  "computation": {
    "gross_revenue": "49.99",
    "tax_rate": 0.153,
    "tax_due": "7.06"
  },
  "idempotent": true
}
GET $BASE_URL/api/tax/obligations
curl https://agentbooks.polsia.app/api/tax/obligations \
  -H "Authorization: Bearer $NEW_KEY" \
  -H "X-Agent-Id: 7"
Example response — 200 OK
{
  "obligations": [
    {
      "id": 11,
      "agent_id": 7,
      "tax_year": 2026,
      "quarter": 3,
      "jurisdiction": "US",
      "gross_amount": "49.99",
      "tax_due": "7.06"
    }
  ]
}