# Searching Transactions

### Introduction

You are provided multiple APIs to search and filter transactions. This document explain the key concepts behind search APIs and help you integrate with search in ways that best suite your needs.

Whenever a sale or refund is executed it is attached to payment object. Payment is a logical grouping of related transactions such as a sale and refund.&#x20;

{% hint style="info" %}
**Payment** - Logical grouping of related transactions

**Transaction** - A sale or a refund with processing information.
{% endhint %}

#### Understanding Payment and Transaction IDs

[Transaction detail API](https://docs.payengine.co/payengine-api-reference/transactions/search-transactions/transaction-detail) works with both paymentId and transaction IDs. Since every transaction is part of a payment the response remains the same regardless of how the API is called.

#### 1. Searching Transaction&#x20;

Transactions can be searched using [Transaction Search API](https://docs.payengine.co/payengine-api-reference/transactions/search-transactions/transaction). Based on the search criteria the result is always presented as an array of transactions where very item contains **`id`** attribute that is the **payment ID** that transaction belongs to; and **`transactionId`** is the unique transaction ID with its own processing data.

```json
{
    "data": [
        {
            "id": "1504ce6f-b079-4fb0-bddb-3a4d69bc4e60",
            "transactionId": "d6ecf793-c5b7-4938-b23e-907741b6cb89",
            "is_offline": false,
            "amount": "1.00",
            "data": {
                "last_4": "1111",
                "card_type": "visa",
                "card_id": "34e1523f-567d-4ce6-acb5-edb2b59d30bb"
            },
            "host_report": {
                "status": "PASS",
                "responseCode": "A0000",
                "responseMessage": "Success",
                "authCode": 887062,
                "hostReferenceNumber": "584935801236",
                "hostResponseCode": "00",
                "taskID": "36060172",
                "transactionID": "68630475",
                "transactionTimestamp": "2022-03-18T15:58:54",
                "orderNumber": "45389232",
                "returnedAmount": "1.00",
                "externalReferenceID": "45389232",
                "customerReceipt": "...",
                "merchantReceipt": "..."
            },
            "payment_method": "Credit Card",
            "type": "refund",
            "status": "succeeded",
            "created_at": "2022-03-18T15:58:54.453Z",
            "settled": false
        },
        {
            "id": "1504ce6f-b079-4fb0-bddb-3a4d69bc4e60",
            "transactionId": "e4df6407-8c0d-43de-a205-af6205e6102d",
            "is_offline": false,
            "amount": "517.76",
            "data": {
                "last_4": "1111",
                "card_type": "visa",
                "card_id": "34e1523f-567d-4ce6-acb5-edb2b59d30bb"
            },
            "host_report": {
                "status": "PASS",
                "responseCode": "A0000",
                "responseMessage": "Success",
                "authCode": 529529,
                "hostReferenceNumber": "133293843236",
                "hostResponseCode": "00",
                "taskID": "86141473",
                "transactionID": "15741297",
                "transactionTimestamp": "2022-03-18T15:38:34",
                "transactionAmount": "517.76",
                "processedAmount": "517.76",
                "totalAmount": "517.76",
                "addressVerificationCode": "Z",
                "cardHolderVerificationCode": "N",
                "cardType": "V",
                "maskedCardNumber": "1111",
                "customerReceipt": "...",
                "merchantReceipt": "..."
            },
            "payment_method": "Credit Card",
            "type": "payment",
            "status": "succeeded",
            "created_at": "2022-03-18T15:38:32.848Z",
            "settled": false
        }
    ],
    "meta": {
        "total": 2,
        "current_page": 1,
        "total_pages": 1
    }
}
```

#### 2. Transaction Detail

Using either the **`id`** that is payment ID or **`transactionId`** from the search (or even from the sale response) [Transaction Detail API](https://docs.payengine.co/payengine-api-reference/transactions/search-transactions/transaction-detail) can be called to get the payment details.&#x20;

The detail object id that is **`data.id`** represents **Payment ID** and each item in details is a transaction that is part of this Payment. The **`id`** attribute of each entry in the details object is a unique **Transaction ID**. In a typical case, a payment will only have a single transaction with one or more refund transactions.&#x20;

```json
{
"data": {
    "id": "1504ce6f-b079-4fb0-bddb-3a4d69bc4e60",
    "amount": "516.76",
    "details": [
        {
            "id": "e4df6407-8c0d-43de-a205-af6205e6102d",
            "amount": "517.76",
            "data": {
                "last_4": "1111",
                "card_type": "visa",
                "card_id": "34e1523f-567d-4ce6-acb5-edb2b59d30bb",
                "bank_account_id": null
            },
            "host_report": {
                "status": "PASS",
                "responseCode": "A0000",
                "responseMessage": "Success",
                "authCode": 529529,
                "hostReferenceNumber": "133293843236",
                "hostResponseCode": "00",
                "taskID": "86141473",
                "transactionID": "15741297",
                "transactionTimestamp": "2022-03-18T15:38:34",
                "transactionAmount": "517.76",
                "processedAmount": "517.76",
                "totalAmount": "517.76",
                "addressVerificationCode": "Z",
                "cardHolderVerificationCode": "N",
                "cardType": "V",
                "maskedCardNumber": "1111",
                "customerReceipt": "...",
                "merchantReceipt": "..."
            },
            "payment_method": "Credit Card",
            "status": "succeeded",
            "type": "payment",
            "is_offline": false,
            "updated_at": "2022-03-18T15:38:32.848Z",
            "created_at": "2022-03-18T15:38:32.848Z",
            "settled": false
        },
        {
            "id": "d6ecf793-c5b7-4938-b23e-907741b6cb89",
            "amount": "1.00",
            "data": {
                "last_4": "1111",
                "card_type": "visa",
                "card_id": "34e1523f-567d-4ce6-acb5-edb2b59d30bb",
                "bank_account_id": null
            },
            "host_report": {
                "status": "PASS",
                "responseCode": "A0000",
                "responseMessage": "Success",
                "authCode": 887062,
                "hostReferenceNumber": "584935801236",
                "hostResponseCode": "00",
                "taskID": "36060172",
                "transactionID": "68630475",
                "transactionTimestamp": "2022-03-18T15:58:54",
                "orderNumber": "45389232",
                "returnedAmount": "1.00",
                "externalReferenceID": "45389232",
                "customerReceipt": "...",
                "merchantReceipt": "..."
            },
            "payment_method": "Credit Card",
            "status": "succeeded",
            "type": "refund",
            "is_offline": false,
            "updated_at": "2022-03-18T15:58:54.453Z",
            "created_at": "2022-03-18T15:58:54.453Z",
            "settled": false
        }
    ]
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.payengine.co/developer-docs/processing-payments/searching-transactions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
