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

# Transactions

> View transaction history, stats, and export data

Transactions represent completed or in-progress payments through your payment links and checkout sessions. The transactions API is read-only -- transactions are created automatically when customers pay through your checkout flow.

<Info>
  Transaction amounts are stored in the token's smallest unit (e.g., 6 decimals for USDC). The `amount_usd` field provides the USD equivalent at the time of the transaction.
</Info>

## The Transaction object

<ResponseField name="id" type="string">
  Unique identifier for the transaction (e.g., `tx_abc123`).
</ResponseField>

<ResponseField name="status" type="string">
  Current status of the transaction. One of: `pending`, `confirming`, `completed`, `failed`.
</ResponseField>

<ResponseField name="amount" type="string">
  Transaction amount in the token's smallest unit.
</ResponseField>

<ResponseField name="amount_usd" type="string">
  USD equivalent of the transaction amount at the time of payment.
</ResponseField>

<ResponseField name="token_address" type="string">
  Contract address of the received token.
</ResponseField>

<ResponseField name="chain_id" type="number">
  Chain ID where the payment was received.
</ResponseField>

<ResponseField name="tx_hash" type="string | null">
  On-chain transaction hash. Null while `pending`.
</ResponseField>

<ResponseField name="payer_address" type="string">
  Wallet address of the payer.
</ResponseField>

<ResponseField name="recipient_address" type="string">
  Wallet address that received the payment.
</ResponseField>

<ResponseField name="customer_id" type="string | null">
  Associated customer ID, if the payer is a known customer.
</ResponseField>

<ResponseField name="payment_link_id" type="string | null">
  Payment link that originated this transaction.
</ResponseField>

<ResponseField name="session_id" type="string | null">
  Checkout session that originated this transaction.
</ResponseField>

<ResponseField name="source_chain_id" type="number | null">
  If the payer paid from a different chain, this is the chain they paid from.
</ResponseField>

<ResponseField name="source_token_address" type="string | null">
  If the payer paid with a different token, this is the token they paid with.
</ResponseField>

<ResponseField name="source_amount" type="string | null">
  The amount the payer sent (before swap/bridge), in the source token's smallest unit.
</ResponseField>

<ResponseField name="fee_amount" type="string | null">
  Platform fee amount in the received token's smallest unit.
</ResponseField>

<ResponseField name="form_data" type="object | null">
  Custom form data submitted by the customer during checkout.
</ResponseField>

<ResponseField name="shipping_address" type="object | null">
  Shipping address provided by the customer.

  <Expandable title="shipping address fields">
    <ResponseField name="name" type="string">Recipient name.</ResponseField>
    <ResponseField name="line1" type="string">Address line 1.</ResponseField>
    <ResponseField name="line2" type="string | null">Address line 2.</ResponseField>
    <ResponseField name="city" type="string">City.</ResponseField>
    <ResponseField name="state" type="string">State or province.</ResponseField>
    <ResponseField name="postal_code" type="string">Postal or ZIP code.</ResponseField>
    <ResponseField name="country" type="string">Two-letter country code.</ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="shipping_option" type="object | null">
  Selected shipping option.

  <Expandable title="shipping option fields">
    <ResponseField name="id" type="string">Shipping option ID.</ResponseField>
    <ResponseField name="name" type="string">Shipping option name.</ResponseField>
    <ResponseField name="amount" type="string">Shipping cost.</ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="metadata" type="object | null">
  Metadata from the checkout session.
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp when the transaction was initiated.
</ResponseField>

<ResponseField name="confirmed_at" type="string | null">
  ISO 8601 timestamp when the transaction reached `confirming` status.
</ResponseField>

<ResponseField name="completed_at" type="string | null">
  ISO 8601 timestamp when the transaction reached `completed` status.
</ResponseField>

### Transaction statuses

| Status       | Description                                                       |
| ------------ | ----------------------------------------------------------------- |
| `pending`    | Transaction initiated, waiting for on-chain submission.           |
| `confirming` | Transaction submitted on-chain, waiting for block confirmations.  |
| `completed`  | Transaction confirmed and payment received by the recipient.      |
| `failed`     | Transaction failed due to revert, timeout, or insufficient funds. |

***

## List transactions

Retrieve a paginated list of transactions with optional filters.

<ParamField query="status" type="string">
  Filter by status: `pending`, `confirming`, `completed`, `failed`.
</ParamField>

<ParamField query="customer_id" type="string">
  Filter by customer ID.
</ParamField>

<ParamField query="payment_link_id" type="string">
  Filter by payment link ID.
</ParamField>

<ParamField query="from" type="string">
  Filter transactions created on or after this ISO 8601 date (e.g., `2026-01-01`).
</ParamField>

<ParamField query="to" type="string">
  Filter transactions created on or before this ISO 8601 date (e.g., `2026-02-28`).
</ParamField>

<ParamField query="page" type="number" default={1}>
  Page number for pagination.
</ParamField>

<ParamField query="limit" type="number" default={20}>
  Number of results per page (max 100).
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://platform-api.anyspend.com/api/v1/transactions?status=completed&from=2026-02-01&to=2026-02-28&page=1&limit=20" \
    -H "Authorization: Bearer asp_xxx"
  ```

  ```typescript SDK theme={null}
  import { AnySpend } from "@b3dotfun/sdk";

  const anyspend = new AnySpend(process.env.ANYSPEND_API_KEY!);

  const { data, pagination } = await anyspend.transactions.list({
    status: "completed",
    from: "2026-02-01",
    to: "2026-02-28",
    page: 1,
    limit: 20,
  });
  ```
</CodeGroup>

<Tabs>
  <Tab title="Response">
    ```json theme={null}
    {
      "data": [
        {
          "id": "tx_abc123",
          "status": "completed",
          "amount": "50000000",
          "amount_usd": "50.00",
          "token_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "chain_id": 1,
          "tx_hash": "0x9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e",
          "payer_address": "0xaabb1234ccdd5678eeff9900aabb1234ccdd5678",
          "recipient_address": "0x1234567890abcdef1234567890abcdef12345678",
          "customer_id": "cust_abc123",
          "payment_link_id": "pl_abc123",
          "session_id": "cs_sess001",
          "source_chain_id": 8453,
          "source_token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "source_amount": "50000000",
          "fee_amount": "500000",
          "form_data": {
            "company_name": "Acme Inc."
          },
          "shipping_address": null,
          "shipping_option": null,
          "metadata": null,
          "created_at": "2026-02-25T08:15:00Z",
          "confirmed_at": "2026-02-25T08:15:45Z",
          "completed_at": "2026-02-25T08:16:30Z"
        }
      ],
      "pagination": {
        "page": 1,
        "limit": 20,
        "total": 156,
        "total_pages": 8,
        "has_more": true
      }
    }
    ```
  </Tab>
</Tabs>

***

## Retrieve a transaction

<ParamField path="id" type="string" required>
  The transaction ID (e.g., `tx_abc123`).
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://platform-api.anyspend.com/api/v1/transactions/tx_abc123" \
    -H "Authorization: Bearer asp_xxx"
  ```

  ```typescript SDK theme={null}
  const transaction = await anyspend.transactions.retrieve("tx_abc123");
  ```
</CodeGroup>

<Tabs>
  <Tab title="Response">
    Returns the full [Transaction object](#the-transaction-object).
  </Tab>
</Tabs>

***

## Get transaction stats

Retrieve aggregate statistics across all your transactions.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://platform-api.anyspend.com/api/v1/transactions/stats" \
    -H "Authorization: Bearer asp_xxx"
  ```

  ```typescript SDK theme={null}
  const stats = await anyspend.transactions.stats();
  ```
</CodeGroup>

<Tabs>
  <Tab title="Response">
    ```json theme={null}
    {
      "total_transactions": 1250,
      "completed_transactions": 1180,
      "failed_transactions": 45,
      "pending_transactions": 25,
      "total_volume_usd": "58750.00",
      "last_24h": {
        "transactions": 18,
        "completed": 17,
        "volume_usd": "920.00"
      },
      "status_breakdown": {
        "pending": 15,
        "confirming": 10,
        "completed": 1180,
        "failed": 45
      }
    }
    ```
  </Tab>
</Tabs>

***

## Export transactions

Export transaction data in CSV or JSON format. The response is streamed as a file download.

<ParamField query="format" type="string" required>
  Export format. One of: `csv`, `json`.
</ParamField>

<ParamField query="status" type="string">
  Filter by status: `pending`, `confirming`, `completed`, `failed`.
</ParamField>

<ParamField query="from" type="string">
  Filter transactions created on or after this ISO 8601 date.
</ParamField>

<ParamField query="to" type="string">
  Filter transactions created on or before this ISO 8601 date.
</ParamField>

<Info>
  Exports are limited to 50,000 records. For larger datasets, use date range filters to break exports into smaller chunks.
</Info>

<CodeGroup>
  ```bash cURL theme={null}
  # Export completed transactions for February 2026 as CSV
  curl -X GET "https://platform-api.anyspend.com/api/v1/transactions/export?format=csv&status=completed&from=2026-02-01&to=2026-02-28" \
    -H "Authorization: Bearer asp_xxx" \
    -o transactions.csv

  # Export as JSON
  curl -X GET "https://platform-api.anyspend.com/api/v1/transactions/export?format=json&status=completed" \
    -H "Authorization: Bearer asp_xxx" \
    -o transactions.json
  ```

  ```typescript SDK theme={null}
  // Export as CSV stream
  const csvStream = await anyspend.transactions.export({
    format: "csv",
    status: "completed",
    from: "2026-02-01",
    to: "2026-02-28",
  });

  // Export as JSON array
  const transactions = await anyspend.transactions.export({
    format: "json",
    status: "completed",
  });
  ```
</CodeGroup>

<Tabs>
  <Tab title="CSV Response">
    ```csv theme={null}
    id,status,amount,amount_usd,token_address,chain_id,tx_hash,payer_address,recipient_address,customer_id,payment_link_id,created_at,completed_at
    tx_abc123,completed,50000000,50.00,0xA0b8...eB48,1,0x9f8e...1f0e,0xaabb...5678,0x1234...5678,cust_abc123,pl_abc123,2026-02-25T08:15:00Z,2026-02-25T08:16:30Z
    tx_def456,completed,25000000,25.00,0xA0b8...eB48,1,0x1a2b...3c4d,0xccdd...9012,0x1234...5678,cust_def456,pl_abc123,2026-02-24T12:00:00Z,2026-02-24T12:01:15Z
    ```
  </Tab>

  <Tab title="JSON Response">
    ```json theme={null}
    {
      "data": [
        {
          "id": "tx_abc123",
          "status": "completed",
          "amount": "50000000",
          "amount_usd": "50.00",
          "token_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "chain_id": 1,
          "tx_hash": "0x9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e",
          "payer_address": "0xaabb1234ccdd5678eeff9900aabb1234ccdd5678",
          "recipient_address": "0x1234567890abcdef1234567890abcdef12345678",
          "customer_id": "cust_abc123",
          "payment_link_id": "pl_abc123",
          "session_id": "cs_sess001",
          "created_at": "2026-02-25T08:15:00Z",
          "completed_at": "2026-02-25T08:16:30Z"
        }
      ],
      "total": 1180
    }
    ```
  </Tab>
</Tabs>
