# Retrieve Clearing Data
source: https://developer.mastercard.com/transaction-notifications/documentation/tutorials-and-guides/clearing-data/index.md

Use the search for clearing transactions endpoint to retrieve settled transaction data for enrolled cards, such as final amounts after tips or adjustments.
Note: Clearing data is not available in real time. Updates occur at periodic intervals following transaction settlements.

## Before You Begin {#before-you-begin}

Confirm the following:

* You have enrolled a card through [Consent Management \& Enrollment](https://developer.mastercard.com/consent-management/documentation/) and obtained a `cardReference`.
* You have at least one authorization notification with a `transUid`, or you know the date range you want to query.
* You have [configured OAuth credentials](https://developer.mastercard.com/transaction-notifications/documentation/api-basics/index.md#client-authentication).

## Search for Clearing Data {#search-for-clearing-data}

Choose one of the following approaches based on your use case, then send a `POST` request to the `/notifications/transactions/search` endpoint.

1. Identify the search criteria that fits your use case:

   * **Single transaction:** specify `transUid` from the authorization notification.
   * **Date range:** specify `cardReferences`, `transactionStartDate`, and `transactionEndDate`.
   * **After a specific date:** specify `afterTransactionDate` only.
   * **Cursor-based (continuous polling):** specify `clearingCursor` to read all clearing records as they are created. See [Read Clearing Data Using a Cursor](https://developer.mastercard.com/transaction-notifications/documentation/tutorials-and-guides/clearing-data/index.md#read-clearing-data-using-a-cursor) for details.
2. Set pagination parameters by including `offset` and `limit` as query parameters. The `offset` is the starting point in the transaction data and `limit` is the number of records returned. For example, `offset=200` and `limit=100` returns the 200th through 300th transactions if more than 300 exist, or up to the last transaction if fewer exist.

   Note: Pagination parameters `offset`, `limit`, and `total` are not returned when you use `clearingCursor`.
3. Send the request.


   API Reference: `POST /notifications/transactions/search`

4. Process the response. The response contains an `items` array with clearing details including final transaction amounts, settlement dates, and merchant information.

## Read Clearing Data Using a Cursor {#read-clearing-data-using-a-cursor}

To read all clearing data as it becomes available, call the endpoint periodically using a cursor to track the records you have already read.

1. Send your first request with `clearingCursor` set to `"0"`. This returns the oldest clearing records up to the `limit` you set.
2. Read the `nextClearingCursor` value from the response.
3. Send your next request using the `nextClearingCursor` value as the new `clearingCursor`.
4. Repeat steps 2 and 3 to continue reading new clearing records as they become available.

## Receive Clearing Notifications {#receive-clearing-notifications}

You can receive clearing data through webhook notifications instead of polling. Mastercard sends outbound calls to your registered webhook endpoint when clearing records become available.

The notification body contains a `clearing` property with a list of clearing events. These events have the same structure as the objects returned by the search for clearing transactions endpoint.

### Example Notification Body {#example-notification-body}

```json
{
    "clearing": [
        {
          "cardReference": "47r45e73-7dwe-43f9-bk6b-5096F5reb5cd",
          "referenceNumber": "MCFO9EC2A",
          "transactionAmount": 12.34,
          "transactionCurrency": "USD",
          "transactionLocalDate": "2024-24-04",
          "transactionLocalTime": "16:01:00",
          "settlementDate": "2024-04-26",
          "transactionType": "05",
          "merchantName": "CENTRA",
          "cardAcceptorCity": "NEW YORK",
          "cardAcceptorState": "NY",
          "merchantCountryCode": "USA",
          "merchantCategoryCode": "4111",
          "acquirerId": "123456",
          "transUid": "20240426O9EC2A",
          "cardholderAmount": 12.34,
          "cardholderCurrency": "USD",
          "financialNetworkCode": "MCF",
          "processDate": "2024-04-25",
          "clearingUniqueId": "202404261024009777553",
          "functionCode": "200",
          "messageReasonCode": "1401",
          "banknetDate": "0424"
        }
    ]
}
```

## Next Steps {#next-steps}

* Review the [Searches for Clearing Transactions](https://developer.mastercard.com/transaction-notifications/documentation/api-reference/index.md#searchTransactionDetails) API specification for the full list of request and response fields.
* Explore the [Expense Management Use Case](https://developer.mastercard.com/transaction-notifications/documentation/use-case-expense-mangement/index.md) for a complete end-to-end example using clearing data.
* Set up a [webhook](https://developer.mastercard.com/transaction-notifications/documentation/tutorials-and-guides/webhook/index.md) if you have not configured one yet.
