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

# Get Recent Completed Transactions With Order Details

> Returns a paginated list of completed transactions with their associated order details.
This endpoint combines data from both the `transactions` and `orders` tables.

## Authentication & Authorization

- Requires Bearer token authentication
- **Without `user_id` parameter**: Returns ALL completed transactions for ALL users
- **With `user_id` parameter**: Returns completed transactions for the specified user only

## Usage Examples

### Get all completed transactions (all users)
```
GET /api/v1/auth/transactions/completed?page_id=1&page_size=10
```
Returns all completed transactions across all users, ordered by creation date (most recent first).

### Get completed transactions for a specific user
```
GET /api/v1/auth/transactions/completed?page_id=1&page_size=10&user_id=682e85d1-50c8-4242-bc78-21309ca34bc7
```
Returns completed transactions filtered by the specified user_id.

## Response Fields

The response includes:
- **Transaction fields**: `user_id`, `from_wallet_id`, `to_wallet_id`, `status`, `to_address`, `token_type`, `token_symbol`, `usd_value`, `transaction_hash`, `fee`
- **Order fields**: `vendor_id`, `offer_id`, `usdt_amount`, `fiat_amount`, `fiat_currency`, `wallet_address`, `order_status`, `payment_method`, `payment_txn_id`, `blockchain_txn_hash`, `completed_at`, `mpesa_receipt_number`, `payment_phone_number`, `order_type`, `escrow_wallet_address`, `escrow_network`, `escrow_reference`, `deposit_tx_hash`, `deposit_confirmations`, `deposit_detected_at`

**Note**: Nullable fields (e.g., `to_address`, `transaction_hash`, `payment_txn_id`, `completed_at`) are omitted from the response when null, or included as `null` when explicitly set to null.




## OpenAPI

````yaml /openapi.yaml get /api/v1/auth/transactions/completed
openapi: 3.1.0
info:
  title: EmaalCoin API
  description: >
    EmaalCoin API reference. These APIs power cryptocurrency exchange between
    USDT and Fiat trading.


    - **On-Ramp**: Buy USDT with fiat (KES) via mobile money (STK Push for
    Kenya)

    - **Off-Ramp**: Sell USDT for KES with mobile money payout (Kenya)

    - **Ethereum, TRON, and Solana**: Multi-chain wallet support

    - **Merchant Offers**: Create and manage trading offers

    - **OTC Flows**: Bank and mobile money deposits/withdrawals for merchants

    - **Pricing engine**: FX quotes and fee profiles for quote-backed orders and
    transfers

    - **P2P/B2B transfers**: Internal and external stablecoin sends (USDT/USDC)
    with optional pricing snapshots

    - **Stablecoin swaps**: Treasury-backed two-leg USDT ↔ USDC conversion with
    BitGo confirmation, inventory reservation, and automatic refunds

    - **Multisig**: Collaborative and platform-managed multisig flows for
    high-value B2B
  version: 1.1.0
servers:
  - url: https://crypto.westminister.tech
    description: Production API (requires DNS for this hostname).
  - url: http://13.42.110.185:8080
    description: >-
      UAT on EC2 (direct). Use this base when building proof PDF URLs if the
      production hostname does not resolve.
security: []
tags:
  - name: Pricing
    description: >-
      Commercial pricing profiles and FX rate quotes (admin). Used with orders
      and transfers for auditable snapshots.
  - name: Transfers
    description: >-
      P2P and B2B stablecoin transfers (USDT/USDC). Optional fiat-equivalent
      pricing fields. B2B multisig behavior depends on wallet registration
      (synchronous completion vs proposal flow).
  - name: Stablecoin Swaps
    description: >-
      Treasury-backed USDT ↔ USDC conversions for BitGo provider-managed wallets
      on `tron`, `ethereum`, or `solana`. Collection confirms before treasury
      payout starts. Completion requires both legs and dual-asset balance
      synchronization.
  - name: Multisig
    description: >-
      Multisig wallet registration and TRON proposal/confirm flows
      (vendor/admin).
  - name: Escrow Wallets
    description: Escrow pool wallet metadata for off-ramp and operations.
  - name: Users
    description: >-
      User-related operations (registration, lookup, updates, counts, status
      changes)
  - name: Wallets-Users
    description: User wallet operations (create, manage, query balances)
  - name: Offers
    description: Offer operations (create, read, list, counts)
  - name: Orders
    description: Order operations (create, update, list, counts, stats)
  - name: Payment
    description: Payment initiation operations
  - name: Merchants
    description: >
      Merchant (vendor) onboarding and hierarchy operations.

      USE **GET /API/V1/AUTH/MERCHANTS** WITH **PAGE_ID** AND **PAGE_SIZE** TO
      PAGE MASTER VENDORS.

      USE **GET /API/V1/AUTH/MERCHANTS/{MERCHANT_ID}** FOR ONE MASTER VENDOR,
      **MERCHANT_WALLETS**, AND ALL **SUBVENDOR** ROWS WITH **WALLETS** (FULL
      TREE).
  - name: OTC Deposits
    description: >
      OTC fiat-to-crypto deposits (bank or mobile money). Rows live in
      **`otc_deposits`**. Merchants create drafts or one-shot deposits.
      **admin**, **otc_officer**, or **treasury** list all deposits.

      B2B bank flow uses draft, quote, submit, proof, assign, claim, settlement,
      and audit. **`credited_to_address`** is the merchant on-chain wallet
      treasury credits (resolved from the default wallet for
      **`requested_network`** on the master merchant ledger user or any
      **sub-vendor** under that merchant).

      **`GET /api/v1/auth/otc/deposits`** backfills missing
      **`credited_to_address`**/**`to_wallet_id`** when a wallet can be
      resolved. One-shot **`POST /api/v1/auth/otc/deposits`** persists the
      payout address when **`requested_network`** is sent.

      Bank proof PDFs upload via `POST .../proof` and are viewed at **`GET
      /otc-deposits-proof/{deposit_id}/{file}.pdf`** (relative
      **`proof_url`**/**`file_url`** plus API base URL).

      Merchants may edit tab-1 draft fields with **`PATCH
      /api/v1/auth/otc/deposits/{id}/draft`** while **`status`** is **`draft`**.
  - name: OTC Withdrawals
    description: >-
      OTC crypto-to-fiat withdrawals (bank or mobile money). Merchants create.
      Admin approves and executes.
  - name: OTC Config
    description: OTC display config (bank details, mobile money paybill) for merchant UI
  - name: Fiat Currencies
    description: >
      Shared platform **fiat_currencies** catalog. **GET
      /api/v1/auth/fiat-currencies** lists active rows for UI pickers. **GET
      /api/v1/auth/fiat-currencies/admin** lists all rows including inactive
      (admin). Admin manages rows with **GET
      /api/v1/auth/fiat-currencies/{id}**, **POST
      /api/v1/auth/fiat-currencies**, **PATCH
      /api/v1/auth/fiat-currencies/{id}**, and **DELETE
      /api/v1/auth/fiat-currencies/{id}**. Use for OTC, pricing, orders,
      remittance, and backoffice — not under **`/otc/...`**. Prefer **PATCH**
      with **`is_active: false`** over delete when a currency is referenced.
  - name: Countries
    description: >-
      Shared platform **countries** catalog. Public **GET /api/v1/countries**
      lists active rows for pickers. Auth **GET /api/v1/auth/countries** returns
      the same active catalog. Admin manages rows with **GET
      /api/v1/auth/countries/admin**, **GET /api/v1/auth/countries/{id}**,
      **POST /api/v1/auth/countries**, **PATCH /api/v1/auth/countries/{id}**,
      and **DELETE /api/v1/auth/countries/{id}**.
  - name: Files
    description: Authenticated file uploads for OTC receipts and proof artifacts.
paths:
  /api/v1/auth/transactions/completed:
    get:
      tags:
        - Transactions
      summary: Get Recent Completed Transactions With Order Details
      description: >
        Returns a paginated list of completed transactions with their associated
        order details.

        This endpoint combines data from both the `transactions` and `orders`
        tables.


        ## Authentication & Authorization


        - Requires Bearer token authentication

        - **Without `user_id` parameter**: Returns ALL completed transactions
        for ALL users

        - **With `user_id` parameter**: Returns completed transactions for the
        specified user only


        ## Usage Examples


        ### Get all completed transactions (all users)

        ```

        GET /api/v1/auth/transactions/completed?page_id=1&page_size=10

        ```

        Returns all completed transactions across all users, ordered by creation
        date (most recent first).


        ### Get completed transactions for a specific user

        ```

        GET
        /api/v1/auth/transactions/completed?page_id=1&page_size=10&user_id=682e85d1-50c8-4242-bc78-21309ca34bc7

        ```

        Returns completed transactions filtered by the specified user_id.


        ## Response Fields


        The response includes:

        - **Transaction fields**: `user_id`, `from_wallet_id`, `to_wallet_id`,
        `status`, `to_address`, `token_type`, `token_symbol`, `usd_value`,
        `transaction_hash`, `fee`

        - **Order fields**: `vendor_id`, `offer_id`, `usdt_amount`,
        `fiat_amount`, `fiat_currency`, `wallet_address`, `order_status`,
        `payment_method`, `payment_txn_id`, `blockchain_txn_hash`,
        `completed_at`, `mpesa_receipt_number`, `payment_phone_number`,
        `order_type`, `escrow_wallet_address`, `escrow_network`,
        `escrow_reference`, `deposit_tx_hash`, `deposit_confirmations`,
        `deposit_detected_at`


        **Note**: Nullable fields (e.g., `to_address`, `transaction_hash`,
        `payment_txn_id`, `completed_at`) are omitted from the response when
        null, or included as `null` when explicitly set to null.
      parameters:
        - name: page_id
          in: query
          required: true
          schema:
            type: integer
            minimum: 1
            description: Page number (1-indexed)
          example: 1
        - name: page_size
          in: query
          required: true
          schema:
            type: integer
            minimum: 5
            maximum: 50
            description: Number of items per page
          example: 10
        - name: user_id
          in: query
          required: false
          schema:
            type: string
            format: uuid
            description: >
              Optional user ID filter. If provided, returns transactions for
              that specific user only.

              If omitted, returns all completed transactions for all users.
          example: 682e85d1-50c8-4242-bc78-21309ca34bc7
      responses:
        '200':
          description: Successfully retrieved completed transactions with order details
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CompletedTransactionWithOrder'
              examples:
                with_user_id:
                  summary: Response With User_id Parameter (Filtered By User)
                  description: >
                    Example response when querying with user_id parameter -
                    returns transactions for that specific user.

                    GET
                    /api/v1/auth/transactions/completed?page_id=1&page_size=10&user_id=682e85d1-50c8-4242-bc78-21309ca34bc7
                  value:
                    - transaction:
                        user_id: 682e85d1-50c8-4242-bc78-21309ca34bc7
                        from_wallet_id: 40ded662-bb48-4be1-820f-b91fe0dae56a
                        to_wallet_id: 05d84d84-54ed-470f-801f-c4e70a6c8439
                        status: completed
                        to_address: TSmoRyo3HTTsQPPzSUGUfJqZDdnS5X4pYa
                        token_type: TRC20
                        token_symbol: USDT
                        usd_value: '2.00'
                        transaction_hash: >-
                          ff30520ce955090212339465934eb037c0a5153cb154e9c4b6dd01678ead5c9c
                        fee: '1.72570000'
                      order:
                        vendor_id: 16a2e461-92ad-4c84-8730-c6492cc604fa
                        offer_id: 24977612-84dc-46ab-8cbc-dbacb0b40c34
                        usdt_amount: '2.00000000'
                        fiat_amount: '30.00'
                        fiat_currency: KES
                        wallet_address: TSmoRyo3HTTsQPPzSUGUfJqZDdnS5X4pYa
                        order_status: completed
                        payment_method: mpesa
                        payment_txn_id: UALGN4HVKN
                        blockchain_txn_hash: >-
                          ff30520ce955090212339465934eb037c0a5153cb154e9c4b6dd01678ead5c9c
                        completed_at: '2026-01-21T17:36:19.221636Z'
                        mpesa_receipt_number: UALGN4HVKN
                        payment_phone_number: '254727648169'
                        order_type: ON_RAMP_BUY
                        deposit_confirmations: 0
                without_user_id:
                  summary: Response Without User_id Parameter (All Users)
                  description: >
                    Example response when querying without user_id parameter -
                    returns all completed transactions for all users.

                    GET
                    /api/v1/auth/transactions/completed?page_id=1&page_size=10
                  value:
                    - transaction:
                        user_id: 682e85d1-50c8-4242-bc78-21309ca34bc7
                        from_wallet_id: 40ded662-bb48-4be1-820f-b91fe0dae56a
                        to_wallet_id: 05d84d84-54ed-470f-801f-c4e70a6c8439
                        status: completed
                        to_address: TSmoRyo3HTTsQPPzSUGUfJqZDdnS5X4pYa
                        token_type: TRC20
                        token_symbol: USDT
                        usd_value: '13.00'
                        transaction_hash: >-
                          8a91d35cdae486b9b68c2d7957b46ef7f6dea3065393ab9ae38410bbb699a7bc
                        fee: '2.88070000'
                      order:
                        vendor_id: 16a2e461-92ad-4c84-8730-c6492cc604fa
                        offer_id: e7c1a009-607f-4f57-93c5-76d3e877300e
                        usdt_amount: '13.00000000'
                        fiat_amount: '169.00'
                        fiat_currency: KES
                        wallet_address: TSmoRyo3HTTsQPPzSUGUfJqZDdnS5X4pYa
                        order_status: completed
                        payment_method: mpesa
                        payment_txn_id: UAKGN4DTY7
                        blockchain_txn_hash: >-
                          8a91d35cdae486b9b68c2d7957b46ef7f6dea3065393ab9ae38410bbb699a7bc
                        completed_at: '2026-01-20T15:32:42.358416Z'
                        mpesa_receipt_number: UAKGN4DTY7
                        payment_phone_number: '254727648169'
                        order_type: ON_RAMP_BUY
                        deposit_confirmations: 0
                empty_result:
                  summary: No Completed Transactions Found
                  value: []
        '400':
          description: Bad request (invalid query parameters)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_page_id:
                  summary: Invalid Page_id
                  value:
                    error: >-
                      Key: 'getRecentCompletedTransactionsRequest.PageID'
                      Error:Field validation for 'PageID' failed on the 'min'
                      tag
                invalid_page_size:
                  summary: Invalid Page_size (Too Small)
                  value:
                    error: >-
                      Key: 'getRecentCompletedTransactionsRequest.PageSize'
                      Error:Field validation for 'PageSize' failed on the 'min'
                      tag
                invalid_user_id:
                  summary: Invalid User_id Format
                  value:
                    error: 'invalid user_id: invalid UUID format'
        '401':
          description: Unauthorized (missing or invalid token)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missing_token:
                  summary: Missing Authorization Token
                  value:
                    error: authorization payload missing
                invalid_token:
                  summary: Invalid Authorization Token
                  value:
                    error: invalid authorization payload
        '404':
          description: User not found (when resolving authenticated user)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                user_not_found:
                  summary: Authenticated User Not Found In Database
                  value:
                    error: user not found
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                database_error:
                  summary: Database Query Failed
                  value:
                    error: 'failed to query transactions: connection timeout'
      security:
        - bearerAuth: []
components:
  schemas:
    CompletedTransactionWithOrder:
      type: object
      required:
        - transaction
        - order
      properties:
        transaction:
          $ref: '#/components/schemas/CompletedTransactionRow'
        order:
          $ref: '#/components/schemas/CompletedTransactionOrderRow'
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message
    CompletedTransactionRow:
      type: object
      required:
        - user_id
        - status
        - token_type
        - token_symbol
        - usd_value
        - fee
      properties:
        user_id:
          type: string
          format: uuid
        from_wallet_id:
          type: string
          format: uuid
          nullable: true
        to_wallet_id:
          type: string
          format: uuid
          nullable: true
        status:
          type: string
          example: completed
        to_address:
          type: string
          nullable: true
        token_type:
          type: string
          example: TRC20
        token_symbol:
          type: string
          example: USDT
        usd_value:
          type: string
        transaction_hash:
          type: string
          nullable: true
        fee:
          type: string
    CompletedTransactionOrderRow:
      type: object
      required:
        - vendor_id
        - offer_id
        - usdt_amount
        - fiat_amount
        - fiat_currency
        - wallet_address
        - order_status
        - payment_method
        - order_type
        - deposit_confirmations
      properties:
        vendor_id:
          type: string
          format: uuid
        offer_id:
          type: string
          format: uuid
          description: Empty string when the order has no offer (e.g. Remittance).
        usdt_amount:
          type: string
        fiat_amount:
          type: string
        fiat_currency:
          type: string
        wallet_address:
          type: string
        order_status:
          type: string
          example: completed
        payment_method:
          type: string
          example: mpesa
        payment_txn_id:
          type: string
          nullable: true
        blockchain_txn_hash:
          type: string
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
        mpesa_receipt_number:
          type: string
          nullable: true
        payment_phone_number:
          type: string
          nullable: true
        order_type:
          type: string
          example: ON_RAMP_BUY
        escrow_wallet_address:
          type: string
          nullable: true
        escrow_network:
          type: string
          nullable: true
        escrow_reference:
          type: string
          nullable: true
        deposit_tx_hash:
          type: string
          nullable: true
        deposit_confirmations:
          type: integer
        deposit_detected_at:
          type: string
          format: date-time
          nullable: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: PASETO

````