# Testing
source: https://developer.mastercard.com/small-business-credit-analytics/documentation/testing/index.md

## Testing in Sandbox {#testing-in-sandbox}

This section provides the testing guides for your API integration in the Sandbox environment.

## Test Data and Test Cases {#test-data-and-test-cases}

This tutorial explains different test cases to verify positive and negative scenarios for the Small Business Credit Analytics (SBCA) API endpoints. Sandbox data is consistent across all users, and the different use cases are differentiated based on the merchant name passed into the search. The other input fields can have arbitrary values, provided that they pass validation.

* [Merchant Match](https://developer.mastercard.com/small-business-credit-analytics/documentation/testing/merchant-match/index.md)
* [Merchant Metrics](https://developer.mastercard.com/small-business-credit-analytics/documentation/testing/merchant-metrics/index.md)
  * [Retail Sales Analytics](https://developer.mastercard.com/small-business-credit-analytics/documentation/testing/merchant-metrics/retail-sales-analytics/index.md)
  * [Retail Sales Benchmarks](https://developer.mastercard.com/small-business-credit-analytics/documentation/testing/merchant-metrics/retail-sales-benchmarks/index.md)

## End-to-End Test Scenario {#end-to-end-test-scenario}

This scenario walks through the complete match → metrics flow using consistent Sandbox test data. Use it to validate that your integration handles the full two-step workflow correctly.

### Step 1: Match the merchant {#step-1-match-the-merchant}

Call `GET /matches` with Name and Address details to identify the merchant.

**Request:**

```bash
GET /matches?country_code=USA&company_name=Artisan+Emporium&street_address=2000+Purchase+St&postal_code=10577&city=Purchase&state_province_region=NY
```

**Expected Response:**

```json
[
    {
        "locationId": "a1b2c3d4-0000-1234-abcd-000000000001",
        "matchRank": 1,
        "merchantName": "Artisan Emporium",
        "streetAddress": "2000 Purchase St",
        "city": "Purchase",
        "state": "NY",
        "postalCode": "10577",
        "countryCode": "USA"
    }
]
```

**Validate:**

* HTTP status is `200 OK`
* Response is a JSON array with at least one match
* First match contains `locationId: "a1b2c3d4-0000-1234-abcd-000000000001"`
* `matchRank` is `1`

### Step 2: Extract the locationId {#step-2-extract-the-locationid}

Copy the `locationId` value (`a1b2c3d4-0000-1234-abcd-000000000001`) from Step 1's response to use in the next call.

### Step 3: Retrieve Metrics {#step-3-retrieve-metrics}

Call `GET /metrics/{location_id}` with the extracted `locationId` and provide the required parameters

* Metric Type : Retail Sales Analytics or Retail Sales Benchmarks
* Metrics Frequency : Weekly or Monthly

**Request for RSA Monthly Metrics:**

```bash
GET /metrics/a1b2c3d4-0000-1234-abcd-000000000001?has_consent=true&metrics_type=retail_sales_analytics&metrics_frequency=Monthly
```

Response

```python
{
  "locationId": "a1b2c3d4-0000-1234-abcd-000000000001",
  "merchantCategoryCode": 478,
  "naicsCode": "454113",
  "industryName": "Arts and Craft Stores",
  "firstSeenTxnDate": "2008-08-14",
  "lastSeenTxnDate": "2023-02-18",
  "metricsFrequency": "Monthly",
  "metricsLists": [
    {
        # Month 1
        "periodStartDate": "2022-02-01",
        "periodEndDate": "2022-02-28",
        "year": 2022,
        "metrics": [
          {
            "name": "txn_amt",
            "value": 64792.24055
          },
          {
            "name": "txn_cnt",
            "value": 952
          },
          ...
          {
            "name": "small_business_cardholder_disputed_chargeback_cnt_perc",
            "value": 0.004282
          }
        ]
      },
      # Month 2 to 12
      ...
      {
          "periodStartDate": "2022-03-01",
          "periodEndDate": "2022-03-31",
          "year": 2022,
          "metrics": [
              ...
          ]
      }
    ]
}
```

**Validate:**

* HTTP status is `200 OK`
* Response contains `locationId`, `metricsFrequency: "Monthly"`, and a non-empty `metricsLists` array
* Each entry in `metricsLists` has `periodStartDate`, `periodEndDate`, and a `metrics` array

For error handling during any of these steps, see [Code and Formats](https://developer.mastercard.com/small-business-credit-analytics/documentation/code-and-formats/index.md).

## Next Steps {#next-steps}

* [Code and Formats](https://developer.mastercard.com/small-business-credit-analytics/documentation/code-and-formats/index.md) --- error codes and resolution guidance
* [Quick Start Guide](https://developer.mastercard.com/small-business-credit-analytics/documentation/quick-start-guide/index.md) --- first sandbox call walkthrough
* [Use Cases](https://developer.mastercard.com/small-business-credit-analytics/documentation/use-cases/index.md) --- business scenario walkthroughs
