# Transactions tutorial
source: https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/seachtrans-tutorial/index.md

## Overview {#overview}

Transaction search is used by an issuer or an acquirer to search for information on an original transaction.
Tip: A claim is always associated with a transaction. You must have a transaction to create a claim.

#### What you will learn {#what-you-will-learn}

> * How to search for a transaction

## Before you start {#before-you-start}

Before starting this tutorial, ensure that you have already completed the following:

* [Mastercom Extended API Client Generation Tutorial](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/clientgeneration-tutorial/index.md)
* [Quick Start Guide](https://developer.mastercard.com/mastercom-extended/documentation/quick-start-guide/index.md)

## Step 1: Search for transactions {#step-1-search-for-transactions}

The issuer or acquirer searches for transactions.
Note: The transaction search response will contain any claims in Mastercom Extended already associated with the transaction. Claims from the Mastercom API v6 system will not be included in this response.
API Reference: `POST /transactions/searches`

To retrieve transactions, create a `TransactionsApi` object. Then use method `transactionsApi.transactionSearch` to search for the transactions for a given time period.

This method expects the request body to be provided. The request body is an instantiation of `TransactionSearch` object.

Available Claim Entities: TRANSACTION, COLLABORATION, CHARGEBACK, VALID_ACTIONS, ADJUSTMENT, REPRESENTMENT, CASE_FILING, SEND_PAYMENT, FEE_COLLECTION, GOOD_FAITH

```java
public class Main {
  public static void main(String[] args) {
    // API client set up here...    

    TransactionsApi transactionsApi = new TransactionsApi(client);
    
    TransactionSearch body = new TransactionSearch();
    body.setPrimaryAccountNumber("5456456868978964");
    body.setTransactionAmountFrom("1");
    body.setTransactionAmountTo("10000");
    body.setStartDate(LocalDate.now().minusDays(3L).toString());
    body.setEndDate(LocalDate.now().toString());

    try {
      TransactionList result = transactionsApi.transactionSearch(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling TransactionsApi#transactionSearch");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Review the possible error codes associated with this request {#review-the-possible-error-codes-associated-with-this-request}

| HTTP Code |                  Error                  |                                                                   Error Description                                                                    | Error Code |
|-----------|-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
| 400       | END_DATE_BEFORE_START_DATE_ERROR        | The `endDate` cannot be before the `startDate`                                                                                                         | 210006     |
| 400       | MAX_DATE_RANGE_ERROR                    | `tranEndDate` can not be more than 30 days after `tranStartDate`                                                                                       | 210007     |
| 400       | START_DATE_TOO_EARLY_ERROR              | Searches can only be completed for up to 1095 days of history                                                                                          | 210010     |
| 400       | TRANSACTION_AMOUNT_FROM_TOO_HIGH_ERROR  | The `transactionAmountFrom` cannot be higher than `transactionAmountTo`                                                                                | 210011     |
| 400       | TRANSACTION_AMOUNT_TO_TOO_LOW_ERROR     | The `transactionAmountTo` cannot be higher than `transactionAmountFrom`                                                                                | 210012     |
| 400       | ARN_OR_PAN_USER_BIN_MUST_MISMATCH_ERROR | Please provide `acquirerRefNumber` or `primary Account Number` that match to the ARN or PAN BIN.                                                       | 210013     |
| 400       | INVALID_FORMAT                          | This is an invalid input format                                                                                                                        | 220000     |
| 400       | MIN_TXN_SEARCH_CRITERIA                 | Provide at minimum a `switchSerialNumber` or `primaryAccountNumber` or `acquirerReferenceNumber` or `banknetReferenceNumber` or `financialNetworkCode` | 220004     |
| 400       | INVALID_TXN_SEARCH_COMBINATION          | Provide a valid combination for the Transaction Search                                                                                                 | 220005     |
| 400       | INVALID_INPUT                           | Invalid input                                                                                                                                          | 230004     |

Review additional error codes [here](https://developer.mastercard.com/mastercom-extended/documentation/code-and-formats/errorsandexceptions/index.md).

#### Verify response {#verify-response}

You should receive a 200 OK response. The `contextId` is returned by the transaction search.

The transaction search response contains any `claimIds` in Mastercom Extended already associated with the transaction. `claimIds` from the Mastercom API v6 system will not be in this response.

Return to [Tutorials](https://developer.mastercard.com/mastercom-extended/documentation/tutorials-and-guides/index.md).
