API quickstart: your first spend in five requests

DevelopersUpdated

This walks through the API with curl: sign in, read your household's table, record a spend, check it, then undo it so your real numbers aren't touched. You need a Dura account with a household and about ten minutes.

1. Get a token

The easiest way is the account screen: Settings, Your account, Apps and agents, Create a token. Or exchange your email and password for one:

curl -X POST https://dura.muchiround.com/api/v1/tokens \
  -H "Content-Type: application/json" \
  -d '{"email_address": "you@example.com", "password": "...", "name": "My script"}'

The answer contains data.token, shown this once. Keep it in a variable for the next steps:

export DURA_TOKEN=dura_...
export DURA=https://dura.muchiround.com/api/v1

2. Find your household

curl $DURA/households -H "Authorization: Bearer $DURA_TOKEN"
{ "data": [ { "id": 1, "name": "Moyo family", "role": "owner", "currency_code": "USD", "currency_symbol": "$", ... } ] }

Everything else lives under /households/1/.... A household you're not in returns 404.

3. Read the table

curl $DURA/households/1 -H "Authorization: Bearer $DURA_TOKEN"

This is the home screen in one call: totals for the month, every envelope with balance_cents, monthly_budget_cents, spent_this_month_cents and needs_cents, the IOUs, and how many receipts are waiting. Note the id of the envelope you'll spend from.

4. Record a spend

curl -X POST $DURA/households/1/spends \
  -H "Authorization: Bearer $DURA_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: quickstart-test-1" \
  -d '{"envelope_id": 1, "amount": "2.50", "note": "API test"}'
{ "data": {
    "entry": { "id": 42, "kind": "spend", "summary": "Spent $2.50 from Groceries: API test", ... },
    "envelopes": [ { "id": 1, "name": "Groceries", "balance_cents": 8250, "balance": "$82.50", ... } ] } }

Run the same command again: you get the same entry back with an Idempotent-Replayed: true header, and nothing new is recorded. If your partner has Dura open, they'll have seen "added a spend" appear.

5. Check it and undo it

curl "$DURA/households/1/entries?kind=spend&per_page=3" -H "Authorization: Bearer $DURA_TOKEN"

curl -X POST $DURA/households/1/entries/42/reverse -H "Authorization: Bearer $DURA_TOKEN"

The undo writes a mirror entry and puts the $2.50 back. Both drop out of the default activity list.

Next

More for developers