# Transactions

List and read posted transactions, parse free text into a draft, and create, correct or delete transactions.

## Overview

Listing returns posted, non-archived transactions. Use page for offset pagination or after for cursor pagination; the two are mutually exclusive.

Parsing turns natural-language text into a canonical transaction draft using the workspace context. It does not create anything, so review the draft before posting it.

Creating posts one withdrawal, deposit or transfer. The account requirements depend on the type, and an Idempotency-Key header makes the request safe to retry. The categories endpoint lists the categories that can be assigned.

Updating changes the category, description, date or account of a posted transaction and keeps every other field. Deleting removes it. Both need the revision from the latest read as expected\_revision and an Idempotency-Key header.

## Required scopes

- `transactions:read` — Read posted transactions and categories, and parse transaction text into a draft.
- `transactions:create` — Create transactions.
- `transactions:update` — Change the category, description, date or account of transactions.
- `transactions:delete` — Delete transactions.

See [Scopes](https://tetri.app/docs/api/v1/getting-started/scopes) for how scopes are granted.

## Typical workflow

1. List transaction categories
2. Parse transaction text
3. Create a transaction
4. Get a transaction
5. Update a transaction
6. Delete a transaction

## Endpoints

- `GET` List transaction categories — `/api/v1/programmatic/categories`
- `GET` List transactions — `/api/v1/programmatic/transactions`
- `POST` Create a transaction — `/api/v1/programmatic/transactions`
- `GET` Get a transaction — `/api/v1/programmatic/transactions/{id}`
- `PATCH` Update a transaction — `/api/v1/programmatic/transactions/{id}`
- `DELETE` Delete a transaction — `/api/v1/programmatic/transactions/{id}`
- `POST` Parse transaction text — `/api/v1/programmatic/transactions/parse`

## GET /api/v1/programmatic/categories

List transaction categories

Returns active categories that can be assigned while parsing or creating transactions.

Required scope: `transactions:read`

### Parameters

- `page` (query, optional, number): One-based result page.
- `limit` (query, optional, number): Maximum resources returned per page.
- `group_id` (query, optional, string): Return active categories from this category group only.

### Responses

- `200`: Active transaction categories and pagination metadata.
- `400`: Request parameters or payload failed validation. Inspect `code` and `details`.
- `401`: The personal access token is missing, invalid, expired, or revoked.
- `403`: The token lacks the required scope or no longer has workspace access.
- `429`: The credential exceeded its request rate limit.

## GET /api/v1/programmatic/transactions

List transactions

Returns posted, non-archived transactions with offset or cursor pagination.

Required scope: `transactions:read`

### Parameters

- `type` (query, optional, withdrawal | deposit | transfer | loan_payment): Return only transactions with this journal type.
- `start` (query, optional, string): Inclusive start of the financial date range.
- `end` (query, optional, string): Inclusive end of the financial date range.
- `page` (query, optional, number): One-based offset page. Mutually exclusive with `after`; omit it for cursor pagination.
- `limit` (query, optional, number): Maximum transactions returned per page.
- `query` (query, optional, string): Case-insensitive transaction description search.
- `account_id` (query, optional, string): Return transactions that include this account.
- `category_id` (query, optional, string): Return transactions assigned to this category.
- `after` (query, optional, string): Opaque cursor returned as `meta.next_cursor`. Mutually exclusive with `page`.

### Responses

- `200`: Posted transactions with offset pagination metadata, or cursor metadata when `after` is supplied.
- `400`: Request parameters or payload failed validation. Inspect `code` and `details`.
- `401`: The personal access token is missing, invalid, expired, or revoked.
- `403`: The token lacks the required scope or no longer has workspace access.
- `429`: The credential exceeded its request rate limit.

## POST /api/v1/programmatic/transactions

Create a transaction

Creates one withdrawal, deposit, or transfer. The request is replay-safe per PAT and idempotency key.

Required scope: `transactions:create`

### Parameters

- `Idempotency-Key` (header, required, string): Unique 16–128 character retry key. Reuse it only when retrying the identical request.

### Request body

`application/json`: One posted withdrawal, deposit, or transfer. Account requirements depend on `type`.

```json
{
  "type": "withdrawal",
  "date": "2026-07-12T12:00:00.000Z",
  "amount": "12.50",
  "description": "Lunch",
  "source_account_id": "<asset-account-id>"
}
```

### Responses

- `201`: Transaction created. The response includes cache side effects and mutation metadata.
- `400`: Request parameters or payload failed validation. Inspect `code` and `details`.
- `401`: The personal access token is missing, invalid, expired, or revoked.
- `403`: The token lacks the required scope or no longer has workspace access.
- `409`: The idempotency key was reused with a different request or the resource state conflicts.
- `429`: The credential exceeded its request rate limit.

## GET /api/v1/programmatic/transactions/{id}

Get a transaction

Returns one posted transaction from the PAT workspace.

Required scope: `transactions:read`

### Parameters

- `id` (path, required, string): Transaction journal identifier.

### Responses

- `200`: The requested posted transaction.
- `400`: Request parameters or payload failed validation. Inspect `code` and `details`.
- `401`: The personal access token is missing, invalid, expired, or revoked.
- `403`: The token lacks the required scope or no longer has workspace access.
- `404`: The resource does not exist in the token workspace or is not visible to this API.
- `429`: The credential exceeded its request rate limit.

## PATCH /api/v1/programmatic/transactions/{id}

Update a transaction

Changes the category, description, date or account of one posted transaction; every other field is kept. Read `revision` first and send it as `expected_revision`. Transactions with amount splits are rejected, and only a withdrawal or deposit can change its account. The request is replay-safe per PAT and idempotency key.

Required scope: `transactions:update`

### Parameters

- `id` (path, required, string): Transaction journal identifier.
- `Idempotency-Key` (header, required, string): Unique 16–128 character retry key. Reuse it only when retrying the identical request.

### Request body

`application/json`: The fields to change and the `revision` from the latest read. Omitted fields keep their value; `category_id: null` removes the category.

```json
{
  "expected_revision": "2026-07-12T12:00:00.000Z",
  "category_id": "<category-id>"
}
```

### Responses

- `200`: Transaction updated. The response includes cache side effects and mutation metadata.
- `400`: Request parameters or payload failed validation. Inspect `code` and `details`.
- `401`: The personal access token is missing, invalid, expired, or revoked.
- `403`: The token lacks the required scope or no longer has workspace access.
- `404`: The resource does not exist in the token workspace or is not visible to this API.
- `409`: The idempotency key was reused with a different request or the resource state conflicts.
- `429`: The credential exceeded its request rate limit.

## DELETE /api/v1/programmatic/transactions/{id}

Delete a transaction

Soft-deletes one posted transaction. Read `revision` first and send it as the `expected_revision` query parameter. The request is replay-safe per PAT and idempotency key.

Required scope: `transactions:delete`

### Parameters

- `id` (path, required, string): Transaction journal identifier.
- `expected_revision` (query, required, string): The `revision` returned by the latest read of this transaction. A stale value is rejected with 409.
- `Idempotency-Key` (header, required, string): Unique 16–128 character retry key. Reuse it only when retrying the identical request.

### Responses

- `200`: Transaction deleted.
- `400`: Request parameters or payload failed validation. Inspect `code` and `details`.
- `401`: The personal access token is missing, invalid, expired, or revoked.
- `403`: The token lacks the required scope or no longer has workspace access.
- `404`: The resource does not exist in the token workspace or is not visible to this API.
- `409`: The idempotency key was reused with a different request or the resource state conflicts.
- `429`: The credential exceeded its request rate limit.

## POST /api/v1/programmatic/transactions/parse

Parse transaction text

Parses natural-language text into a canonical transaction draft using the PAT workspace context.

Required scope: `transactions:read`

### Request body

`application/json`: Natural-language input plus optional locale, timezone, date anchor, and current form context.

```json
{
  "text": "wolt 42 gel yesterday",
  "locale": "en",
  "timezone": "Asia/Tbilisi",
  "reference_date": "2026-07-22"
}
```

### Responses

- `200`: Canonical natural-language transaction draft parse.
- `400`: Request parameters or payload failed validation. Inspect `code` and `details`.
- `401`: The personal access token is missing, invalid, expired, or revoked.
- `403`: The token lacks the required scope or no longer has workspace access.
- `429`: The credential exceeded its request rate limit.
