> ## Documentation Index
> Fetch the complete documentation index at: https://docs.manka.tz/llms.txt
> Use this file to discover all available pages before exploring further.

# Extract Transactions

> Synchronously parse a bank statement PDF into account metadata and a transaction list.

Parses a bank statement PDF and returns the raw transaction list along with account metadata. Unlike [`/analysis`](/api-reference/analysis/submit), this endpoint is **synchronous** — the parsed result is returned in the same response.

<Note>
  Request body must be `multipart/form-data`. One analysis credit is deducted per successful call.
</Note>

### Request body

<ParamField body="file" type="file" required>
  Bank statement PDF.
</ParamField>

<ParamField body="password" type="string">
  Password for protected PDFs. Required if the file is encrypted.
</ParamField>

### Response

<ResponseField name="name" type="string">
  Account holder name as printed on the statement.
</ResponseField>

<ResponseField name="account" type="string">
  Account or mobile number.
</ResponseField>

<ResponseField name="contacts" type="string">
  Contact number on file with the issuer.
</ResponseField>

<ResponseField name="company" type="string">
  Issuing institution, e.g. `"Equity Bank"`, `"Vodacom"`.
</ResponseField>

<ResponseField name="currency" type="string">
  Currency name or ISO code as printed on the statement.
</ResponseField>

<ResponseField name="currency_code" type="string">
  ISO 4217 currency code (e.g. `"KES"`, `"TZS"`).
</ResponseField>

<ResponseField name="start_date" type="string">
  ISO 8601 date of the first transaction in the statement period.
</ResponseField>

<ResponseField name="end_date" type="string">
  ISO 8601 date of the last transaction in the statement period.
</ResponseField>

<ResponseField name="no_of_transactions" type="integer">
  Total number of transactions returned in `transactions`.
</ResponseField>

<ResponseField name="transactions" type="array">
  Ordered list of parsed transactions.

  <Expandable title="Transaction fields">
    <ResponseField name="date" type="string">
      ISO 8601 date of the transaction.
    </ResponseField>

    <ResponseField name="description" type="string">
      Raw description as printed on the statement.
    </ResponseField>

    <ResponseField name="amount" type="number">
      Transaction amount in the account's currency.
    </ResponseField>

    <ResponseField name="type" type="string">
      `"credit"` or `"debit"`.
    </ResponseField>

    <ResponseField name="balance" type="number">
      Running account balance after the transaction.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "name": "Jane Doe",
    "account": "0012345678",
    "contacts": "+254712345678",
    "company": "Equity Bank",
    "currency": "KES",
    "currency_code": "KES",
    "start_date": "2024-01-01",
    "end_date": "2024-01-31",
    "no_of_transactions": 142,
    "transactions": [
      {
        "date": "2024-01-03",
        "description": "MPESA RECEIVED",
        "amount": 5000,
        "type": "credit",
        "balance": 23450.5
      }
    ]
  }
  ```
</ResponseExample>

### Error responses

| Status | Reason                                                   |
| ------ | -------------------------------------------------------- |
| `400`  | PDF is password-protected or in an unrecognisable format |
| `401`  | Missing or invalid API token                             |
| `402`  | Insufficient analysis credits                            |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://gateway.manka.tz/v1/api/transactions \
    -H "Authorization: Bearer $MANKA_API_TOKEN" \
    -F "file=@statement.pdf"
  ```

  ```python Python theme={null}
  import requests

  with open("statement.pdf", "rb") as f:
      r = requests.post(
          "https://gateway.manka.tz/v1/api/transactions",
          headers={"Authorization": f"Bearer {token}"},
          files={"file": f},
      )

  data = r.json()
  print(data["no_of_transactions"], "transactions")
  ```

  ```javascript Node.js theme={null}
  import fs from "node:fs";
  import FormData from "form-data";
  import fetch from "node-fetch";

  const form = new FormData();
  form.append("file", fs.createReadStream("statement.pdf"));

  const r = await fetch("https://gateway.manka.tz/v1/api/transactions", {
    method: "POST",
    headers: { Authorization: `Bearer ${process.env.MANKA_API_TOKEN}` },
    body: form,
  });

  const data = await r.json();
  ```
</CodeGroup>
