# Dollar Diary integration guide

Generated from the public API contract (24.12.1).

- [API reference](https://www.dollardiary.com/api-docs)
- [OpenAPI schemas](https://www.dollardiary.com/openapi.yaml)
- [MCP setup and walkthrough](https://www.dollardiary.com/mcp-overview)
- [Changelog](https://www.dollardiary.com/api-changelog.md)

## Find an operation

Paths below are relative to `https://www.dollardiary.com/api/v1`.
In MCP, use the operation ID with `describe_api` before calling it. Set
`includeResponses: true` for response schemas. The catalog includes operations your key
may not be authorized to execute; inspect the access requirements.

| Task | REST operation | MCP operation ID |
| --- | --- | --- |
| Read, paginate, or incrementally sync transactions | [`GET /transactions`](https://www.dollardiary.com/api-docs#tag/transactions/GET/transactions) | `listTransactions` |
| Create a transaction | [`POST /transactions`](https://www.dollardiary.com/api-docs#tag/transactions/POST/transactions) | `createTransaction` |
| Edit or confirm a transaction | [`PATCH /transactions/{id}`](https://www.dollardiary.com/api-docs#tag/transactions/PATCH/transactions/{id}) | `updateTransaction` |
| Discover SQL tables and columns | [`GET /queries/schema`](https://www.dollardiary.com/api-docs#tag/sql-editor/GET/queries/schema) | `getQueriesSchema` |
| Run read-only SQL | [`POST /queries`](https://www.dollardiary.com/api-docs#tag/sql-editor/POST/queries) | `executeSqlQuery` |
| Start a client-driven import | [`POST /imports`](https://www.dollardiary.com/api-docs#tag/imports/POST/imports) | `recordImportJob` |
| Start an asynchronous export | [`POST /exports`](https://www.dollardiary.com/api-docs#tag/export/POST/exports) | `createExport` |
| Poll an export job | [`GET /exports/{id}`](https://www.dollardiary.com/api-docs#tag/export/GET/exports/{id}) | `getExportJob` |

Imports are client-driven: opening a job does not ingest rows. Exports are asynchronous:
retain the returned job ID, poll until terminal, and download before expiry. Follow each
operation's lifecycle and limits. MCP downloads are limited to 10,000,000 bytes; download
larger exports through authenticated REST. See the MCP walkthrough for its result envelopes.

## Quick Start

Creating an API key requires a browser session, an editor role in the workspace, and an active subscription. [Open your account](/home), select your workspace, and open **API Keys**. Create a key with `CREATE` and `UPDATE` enabled for this walkthrough, and save the secret when it appears. Every key also includes `READ` automatically. Replace `<your-api-key>` in the commands below with that secret.

Use the following API base URL. Your API key determines which workspace you access:

```bash
BASE_URL='https://www.dollardiary.com/api/v1'
```

These tutorial commands use your shell's `BASE_URL`; the reference's server selector controls
only the generated endpoint examples.

This first request needs the `READ` scope:

```bash
curl "$BASE_URL/transactions" \
  -H "Authorization: Bearer <your-api-key>"
```

Create your first transaction with a key that has the `CREATE` scope. The example includes an
`Idempotency-Key`: reuse it when retrying this request, and choose a new value when creating
a different transaction.

```bash
curl "$BASE_URL/transactions" \
  -X POST \
  -H "Authorization: Bearer <your-api-key>" \
  -H "Content-Type: application/json" \
  -H 'Idempotency-Key: 5f447596-bf57-4bb9-8c9f-a4b6a1f92c0a' \
  -d '{
  "name": "Coffee",
  "merchantName": "Coffee shop",
  "amountCents": 525,
  "settledDate": "2026-09-04",
  "rawDescription": "  COFFEE SHOP 123  "
}'
```

Selected fields from the response's `data` object (the ID below is illustrative; save the ID returned by your request):

```json
{
  "id": "tx_a8Kf2Hp7",
  "name": "Coffee",
  "amountCents": 525,
  "rawDescription": "COFFEE SHOP 123",
  "state": "UNTAGGED"
}
```

If the list response has a non-null `nextCursor`, replace `<nextCursor>` below with that
value. Keep the same filters on subsequent pages and stop when `nextCursor` is `null`:

```bash
curl --get "$BASE_URL/transactions" \
  -H "Authorization: Bearer <your-api-key>" \
  --data-urlencode 'cursor=<nextCursor>'
```


## Essentials

- Amounts are integer minor units; timestamps are UTC.
- Cursor-paginated lists use `nextCursor`; bounded list endpoints explicitly say when they return the full set without pagination.
- Most mutations replay a repeated `Idempotency-Key` safely; check the operation's header description for exceptions, including SQL execution and API-key creation.
- Errors use Problem Details. Branch on `code`, not `detail`.
- The REST API is backend-only: it emits no CORS headers, so browsers cannot call it from another origin. Use your server or the remote MCP endpoint.


## Amounts & Currency

`amountCents` and other `*Cents` fields are integers in the smallest currency unit; never send
decimal currency values. Workspace totals and `Transaction.amountCents` use the display currency
from `GET /workspace`, which is currently always USD. A bank transaction's
`originalAmountCents` remains in its source `isoCurrencyCode`, so those two amount fields may use
different currencies. On create requests, omit `currencyCode` or send `USD`; other codes are rejected.

Transactions represent spending: `amountCents` is positive. Bank credits, income, and other
non-spending inflows are not included in the transaction collection. The API is not a complete
bank-statement feed, and transaction totals should not be used to reconstruct an account balance.


## Responses and Errors

Single-resource responses use `{ data: T }`; cursor-paginated lists use
`{ data: T[], nextCursor: string | null }`. Errors use RFC 9457 Problem Details with
`application/problem+json`. Branch on the stable `code`, use `detail` and `hint` for people,
and include `instance` when contacting support. For documented codes, the `type` URL opens
code-specific recovery guidance; otherwise it opens this reference.

JSON object property order is not significant: read fields by name, not their position in an example.
Array order follows each operation's documented sort. Nullable fields and optional fields differ:
nullable permits JSON null; optional permits omission. Follow the schema's required list.

JSON request bodies are limited to 4,000,000 bytes. Larger bodies return
`413 REQUEST_BODY_TOO_LARGE`; upload operations document their own byte limits.
Cookie-authenticated mutations require an `Origin` or `Referer` matching the API's origin;
otherwise they return `403 CSRF_ORIGIN_MISMATCH`. Bearer-authenticated requests do not require these headers.
If a replay-capable operation cannot claim its `Idempotency-Key` because storage is unavailable,
it returns `503 SERVICE_UNAVAILABLE` before executing the mutation. Retry with the same key and body.


## Safe Retries

On replay-capable mutations, send an optional `Idempotency-Key` of 1–255 letters, numbers,
underscores, or hyphens. Reuse it only for retries of the same logical operation.

- Successful responses are replayable for 24 hours from the original claim. After expiry, the
  key can execute again; reconcile the resource before retrying an old mutation.
- Keys share a namespace per workspace and authenticated member. API keys from the same member
  share it too, so use distinct keys across integrations.
- A different method, path, or serialized body returns `422 IDEMPOTENCY_KEY_CONFLICT`.
  Preserve body bytes, including JSON whitespace/property order and multipart boundaries.
  Headers and query parameters are not hashed; keep those unchanged as well.
- Authentication, authorization, and rate limits still apply. Non-2xx responses are not cached.
  Malformed keys return `400 INVALID_IDEMPOTENCY_KEY` on replay-capable operations.
- Operations that opt out ignore the header, including its format. Check the operation's
  header description for exceptions such as SQL execution and API-key creation.


## Concurrent Edits

For mutations documenting a `412` response, send the resource's `Resource-Version` response
header, or its `updatedAt` value, as `If-Resource-Version`. Copy the value without quotes or a
`W/` prefix. A stale or invalid token returns `412 PRECONDITION_FAILED`; fetch the resource and
review changes before retrying. Empty values, wildcards, and lists are invalid. Omit the header
for an unconditional write.

This token checks the resource's write version; it is not an HTTP cache validator and does not
cover every related resource or computed response field. File downloads separately use standard
ETags and `If-None-Match`. The former entity `If-Match` header is rejected with `412` on new
conditional-capable mutations so older clients cannot silently lose conflict protection.

An idempotency replay returns the original successful response before checking the current
resource version. Read the resource again when you need its latest state.


## Rate Limits

Rate-limited successful responses include structured `RateLimit-Policy` and
`RateLimit` fields. The `t` parameter is a number of seconds, not a timestamp. The legacy
`RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset` fields remain available for
compatibility. A `429 TOO_MANY_REQUESTS` response
includes `Retry-After` and `retryAfterSeconds`. Some exports, bulk operations, and AI operations
have additional buckets or quotas described on the operation; use the response headers instead of
hard-coding a universal limit. Requests sharing a policy share its bucket: per API key for Bearer calls, or per signed-in user for sessions. Separate pre-authentication IP buckets also apply. When multiple authenticated buckets apply, headers describe the one with the fewest requests remaining, not every bucket. Replays still consume rate-limit capacity. Retry TOO_MANY_REQUESTS after its indicated delay with backoff; other 429 codes can represent quotas and may need a different remedy.

For tagging, required custom fields, permissions, and individual operation schemas, continue
in the [API reference](https://www.dollardiary.com/api-docs).
