---
title: "Query API (Classic)"
method: POST
path: "/query.php"
tags: ["Data and Transaction Reporting"]
---

# Query API (Classic)

`POST /query.php`

## Request

- Base URL: `https://sandbox.nmi.com/api`
- URL: `https://sandbox.nmi.com/api/query.php`
- Auth: none required

<details>
<summary>Methodology</summary>

**Overview**

While our online reporting interface allows merchants to quickly and easily retrieve detailed information about past transactions, a need for additional flexibility may be required. For example, a merchant may have custom accounting software that requires up-to-date information about the settlement status of all credit card transactions every day.

This document describes how developers can query our reporting engine directly to retrieve transaction reports in a machine readable format. Once the data has been retrieved, it can then be parsed and imported into a variety of software applications.

**Communication**

The communication protocol used to send messages to the Payment Gateway is through the HTTP protocol over an SSL connection (HTTPS). The format you must use is name/value pairs delimited by ampersand.

| URL                                     | Example Post Data                                     |
|:----------------------------------------|:------------------------------------------------------|
| `https://sandbox.nmi.com/api/query.php`  | `security_key=security_key&transaction_id=123456789`  |

You should POST your request to the Query API. The name/value pairs that are accepted by the Payment Gateway can be found in the 'Variables' section of this API.

The Query API can be tested with live credentials or a dedicated test account only. Please contact your Merchant Service Provider for more information.

The Query API will respond in Universal Time Coordinated (UTC).

</details>

<details>
<summary>Example Response</summary>

**Query with no report_type or report_type "transaction"**

```xml
<nm_response>
    <transaction>
        <transaction_id>2612675976</transaction_id>
        <partial_payment_id></partial_payment_id>
        <partial_payment_balance></partial_payment_balance>
        <platform_id></platform_id>
        <transaction_type>cc</transaction_type>
        <condition>complete</condition>
        <order_id>1234567890</order_id>
        <authorization_code>123456</authorization_code>
        <ponumber></ponumber>
        <order_description></order_description>
        <first_name>John</first_name>
        <last_name>Smith</last_name>
        <address_1>123 Main St</address_1>
        <address_2>Apt B</address_2>
        <company></company>
        <city>New York City</city>
        <state>NY</state>
        <postal_code>10001</postal_code>
        <country>US</country>
        <email>johnsmith@example.com</email>
        <phone>1234567890</phone>
        <fax></fax>
        <cell_phone></cell_phone>
        <customertaxid></customertaxid>
        <customerid></customerid>
        <website></website>
        <shipping_first_name></shipping_first_name>
        <shipping_last_name></shipping_last_name>
        <shipping_address_1></shipping_address_1>
        <shipping_address_2></shipping_address_2>
        <shipping_company></shipping_company>
        <shipping_city></shipping_city>
        <shipping_state></shipping_state>
        <shipping_postal_code></shipping_postal_code>
        <shipping_country></shipping_country>
        <shipping_email></shipping_email>
        <shipping_carrier></shipping_carrier>
        <tracking_number></tracking_number>
        <shipping_date></shipping_date>
        <shipping>1.00</shipping>
        <shipping_phone></shipping_phone>
        <cc_number>4xxxxxxxxxxx1111</cc_number>
        <cc_hash>f6c609e195d9d4c185dcc8ca662f0180</cc_hash>
        <cc_exp>1215</cc_exp>
        <cavv></cavv>
        <cavv_result></cavv_result>
        <xid></xid>
        <eci></eci>
        <directory_server_id></directory_server_id>
        <three_ds_version></three_ds_version>
        <avs_response>N</avs_response>
        <csc_response>M</csc_response>
        <cardholder_auth></cardholder_auth>
        <cc_start_date></cc_start_date>
        <cc_issue_number></cc_issue_number>
        <check_account></check_account>
        <check_hash></check_hash>
        <check_aba></check_aba>
        <check_name></check_name>
        <account_holder_type></account_holder_type>
        <account_type></account_type>
        <sec_code></sec_code>
        <drivers_license_number></drivers_license_number>
        <drivers_license_state></drivers_license_state>
        <drivers_license_dob></drivers_license_dob>
        <social_security_number></social_security_number>
        <processor_id>processora</processor_id>
        <tax>1.00</tax>
        <currency>USD</currency>
        <surcharge></surcharge>
        <convenience_fee></convenience_fee>
        <misc_fee></misc_fee>
        <misc_fee_name></misc_fee_name>
        <cash_discount></cash_discount>
        <tip></tip>
        <card_balance></card_balance>
        <card_available_balance></card_available_balance>
        <entry_mode>Keyed</entry_mode>
        <cc_bin>411111</cc_bin>
        <cc_type>visa</cc_type>
        <signature_image>
            iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1BAA
                Cxjwv8YQUAAAAJcEhZcwAAEnQA
            ABJ0Ad5mH3gAAACGSURBVDhPlZGBEoAgCEO1//9nG83mxMrr3dkBG0hVW2vFqLX26CYbPIc7yS
                AVe8LBq5u4elyV4M0NXIoGXYqA
            w4QqMAwJCRu+Az7HSlvgHtexlFKwGrLjG/h/rESmhrhRnLCKwjiNeLYv5QsXOoNSig8IsNYaZ0
                tXJoGU9hU1k18XlZLOQHTenf7I
            cf3BwAAAABJRU5ErkJggg==
        </signature_image>
        <product>
            <sku>RS-100</sku>
            <quantity>1.0000</quantity>
            <description>Red Shirt</description>
            <amount>10.0000</amount>
        </product>
        <action>
            <amount>11.00</amount>
            <action_type>sale</action_type>
            <date>20150312215205</date>
            <success>1</success>
            <ip_address>1.1.1.1</ip_address>
            <source>virtual_terminal</source>
            <api_method></api_method>
            <username>demo</username>
            <response_text>SUCCESS</response_text>
            <batch_id>0</batch_id>
            <processor_batch_id></processor_batch_id>
            <response_code>100</response_code>
            <processor_response_text>NO MATCH</processor_response_text>
            <processor_response_code>00</processor_response_code>
            <requested_amount>11.00</requested_amount>
            <device_license_number></device_license_number>
            <device_nickname></device_nickname>
        </action>
        <action>
            <amount>11.00</amount>
            <action_type>level3</action_type>
            <date>20150312215205</date>
            <success>1</success>
            <ip_address>1.1.1.1</ip_address>
            <source>virtual_terminal</source>
            <api_method></api_method>
            <username>demo</username>
            <response_text></response_text>
            <batch_id>0</batch_id>
            <processor_batch_id></processor_batch_id>
            <response_code>100</response_code>
            <processor_response_text></processor_response_text>
            <processor_response_code></processor_response_code>
            <device_license_number></device_license_number>
            <device_nickname></device_nickname>
        </action>
        <action>
            <amount>11.00</amount>
            <action_type>settle</action_type>
            <date>20150313171503</date>
            <success>1</success>
            <ip_address></ip_address>
            <source>internal</source>
            <api_method></api_method>
            <username></username>
            <response_text>ACCEPTED</response_text>
            <batch_id>76158269</batch_id>
            <processor_batch_id>782</processor_batch_id>
            <response_code>100</response_code>
            <processor_response_text></processor_response_text>
            <processor_response_code>0000000000021980</processor_response_code>
            <device_license_number></device_license_number>
            <device_nickname></device_nickname>
        </action>
    </transaction>
</nm_response>
```
</details>

<details>
<summary>Example Response With Processor Details</summary>

**Query with report_type "profile" and processor_details "true"**

```xml
<nm_response>
    <protected>false</protected>
    <is_gateway>false</is_gateway>
    <merchant>
        <company>Test Company</company>
        <email>johnsmith@example.com</email>
        <phone>123-456-7890</phone>
        <url></url>
        <address1>123 Fake St</address1>
        <address2></address2>
        <city>Beverly Hills</city>
        <state>CA</state>
        <zip>90210</zip>
        <country>US</country>
        <timezone>America/New_York (GMT-05:00) Eastern Time (US & Canada)</timezone>
        <card_schemes>Visa,Mastercard,American Express,Discover,Diner's Club,JCB,Maestro,Banco Popular,Isracard,Hipercard,Credomatic Card,EBT</card_schemes>
    </merchant>
    <gateway>
        <company>Test Reseller</company>
        <url></url>
        <email>johnsmith@example.com</email>
        <phone>123-456-7890</phone>
        <primary_color>36175F</primary_color>
        <complimentary_color_1>F1577B</complimentary_color_1>
        <complimentary_color_2>26CC9D</complimentary_color_2>
    </gateway>
    <merchant_defined_fields></merchant_defined_fields>
    <merchant_favicon>iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAMAAAAKE/YAAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAACfUExURUdwTPX19fX19fb29vn5+fX19fX19fb29vX19fX19fb29vb29v////b29vX19f////n5+fX19fn5+fX19ff39/X19fb29vX19fb29vX19f////X19fX19fb29vX19fb29vX19fX19fb29mRkZBcXF/X19e7u7hsbGx8fH0dHR8rKytjY2IWFhb6+vqysrDk5OTg4OFBQUCgoKCEhISIiIjOJ5RMAAAAjdFJOUwD83x8tUeeStfk9rAbl7w8wzDHsINJ82Y42CcFnf/0/9v4+JiMvSAAAAqRJREFUeNrt3dlSwkAUBNBhkSTsyCqr4lyRffP/v81dS0wmQCnc1u5Hn85DhAxV022MK+1ht+XXk9VATpSgmqz7re6wbY7MVa9zMuw3fKd3dbi41mjKmdNs1A4iX+b6oiD93OXe5LIvauKX9yKXvIQoSsIrxZsvMqIsmYsYct4ThfHyLnOqIipTSUWb0wVRmkI6ypwtitoUsxHma1Gc61B1uiiqUwx5QlIFUZ7Ct//GfEXUp7L7yecJQLyd70GByJfvxlIGA50poT0cOw9IOYGCTny+qfoCE//jnCJAeT/L5JDQubcz7A0Suv962m0IVBov6CYWuvnym4yA5flXnB4auveE7qChO8a0AzR00DYDgcvAdPHQXdPCQ7eQXpY+X5rqeOi6SeKhk6aKh66aiI/pyWy92tpzZrtazybhH9Qm9M+LpdWR5SKMF4aejq2ejKd7oecbqymb+R7o+cjqymgei55urLZspnHosdWXcQx6YTVm4UYvVaKXTvTE6szEhZ4pRc9c6LVS9NqFXilFr1zorVL01oW2WkM00Uei77XGhb7VGqKJJppoookmmmiiiSaaaKKJJloTeqQ1/FmMaKKJJppoookm+qfQd78aookmmmiiiSaaaKKJ/ttonlyIJhrgYEs00UQTTTTR/wPNdw+iMS6cPfy5q32Qlyghr6tCXgyGvIKNedkdslYAs8ABsioDs5QEs/4Fs2hHe6VRJFp1TIBnDjBruiAL0SCr5yBL/iDrFCGLKwErQoeYZayQtbeYBcOQVc6QpdmY9eSQRfCQlfuY4waQMxKYgx2Q0yiYIzSQcz+Yw0qYE1aQY2GYs2yYA3iYU4OYo46Y85mYQ6WYk7Cg47uYM8evg9Iqzo2HDEqDTneDjqS/zdEPzjNHP3DP0T8C4oBc15g2YiAAAAAASUVORK5CYII=</merchant_favicon>
    <account_details>
        <account_status>active</account_status>
        <test_mode_enabled>false</test_mode_enabled>
    </account_details>
</nm_response>
```
</details>

## Request body `application/x-www-form-urlencoded`

- object
  - `security_key` string: API Security Key assigned to a merchant account. New keys can be generated from the merchant control panel in Settings > Security Keys
  - `condition` 'pending' | 'pendingsettlement' | 'in_progress' | 'abandoned' | 'failed' | 'canceled' | 'complete' | 'unknown': A combination of values can be passed and should be separated by commas. For example, to retrieve all transactions pending settlement or complete, the following could be used: `condition=pendingsettlement,complete` <details> <summary>Conditions</summary> | Condition | Description | |:-------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------| | pending | 'Auth Only' transactions that are awaiting capture. | | pendingsettlement | Transaction is awaiting settlement. | | in_progress | Three-Step Redirect API transaction has not yet been completed. The transaction <br>condition will change to 'abandoned' if 24 hours pass with no further action. | | abandoned | Three-Step Redirect API transaction has not been completed, and has timed out. | | failed | Transaction has failed. | | canceled | Transaction has been voided. | | complete | Transaction has settled. | | unknown | An unknown error was encountered while processing this transaction. | </details>
  - `transaction_type` 'cc' | 'ck' | 'cs': Retrieves only transactions with the specified transaction type. <details> <summary>Transaction Types</summary> | Transaction Type | Description | |:------------------|:----------------------------| | cc | A credit card transaction. | | ck | A check transaction. | | cs | A cash transaction. | </details>
  - `action_type` 'sale' | 'refund' | 'credit' | 'auth' | 'capture' | 'void' | 'return' | 'validate': Retrieves only transactions with the specified action types. A combination of the values can be used and <br>should be separated by commas. For example, to retrieve all transactions with credit or refund actions, use the following: `action_type=refund,credit` <details> <summary>Action Types</summary> | Action Type | Description | |:-------------|:-------------------------------------------------------------------------------------------------| | sale | Sale transactions. | | refund | Refund transactions. | | credit | Credit transactions. | | auth | 'Auth Only' transactions. | | capture | Captured transactions. | | void | Voided transactions. | | return | Electronic Check (ACH) transactions that have returned, as well as credit card <br>chargebacks. | | validate | Validated transactions. | </details>
  - `source` 'api' | 'batch_upload' | 'mobile' | 'quickclick' | 'quickbooks' | 'recurring' | 'swipe' | 'virtual_terminal' | 'internal': Retrieves only transactions with a particular 'transaction source'. A combination of the values can be used <br>and should be separated by commas. For example, to retrieve all transactions with api or recurring actions, use the following: `source=api,recurring` <details> <summary>Sources</summary> | Source | Description | |:-----------------|:--------------------------------------------------------------------------------------------------| | api | API transactions. | | batch_upload | Batch Upload transactions. | | mobile | Mobile (iProcess) transactions. | | quickclick | QuickClick transactions. | | quickbooks | QuickBooks SyncPay transactions. | | recurring | Recurring transactions when using Recurring module. | | swipe | Swipe transactions. | | virtual_terminal | Virtual Terminal transactions. | | internal | Internal transactions. Typically indicates settlement. | </details>
  - `transaction_id` string: Specify a transaction ID or a comma separated list of transaction IDs to retrieve information on.<br>Alternatively, provide a Subscription ID to retrieve processed (approved and declined) transactions <br>associated with it.
  - `subscription_id` string: Set a specific subscription record or comma separated list of records. Using this with a transaction search <br>will return all transactions associated with this subscription. This will return this subscription's payment/plan <br>information when used with `report_type=recurring`.
  - `invoice_id` string: Set a specific Invoice ID. Should only be used when `report_type=invoicing`.
  - `partial_payment_id` string: Retrieves only transactions with the specified partial payment ID.
  - `order_id` string: Retrieves only transactions with the specified Order ID.
  - `first_name` string: Retrieves only transactions with the specified first name.
  - `last_name` string: Retrieves only transactions with the specified last name.
  - `address1` string: Retrieves only transactions with the specified specified address.
  - `city` string: Retrieves only transactions with the specified city.
  - `state` string: Retrieves only transactions with the specified state. Format: `CC`
  - `zip` string: Retrieves only transactions with the specified zip/postal code.
  - `phone` string: Retrieves only transactions with the specified phone number.
  - `fax` string: Retrieves only transactions with the specified fax number.
  - `order_description` string: Retrieves only transactions with the specified order description.
  - `drivers_license_number` string: Retrieves only transactions with the specified driver's license number.
  - `drivers_license_dob` string: Retrieves only transactions with the specified driver's license date of birth.
  - `drivers_license_state` string: Retrieves only transactions with the specified driver's license state.
  - `email` string: Retrieves only transactions with the specified billing email address.
  - `cc_number` '4111111111111111' | '5431111111111111' | '6011000991300009' | '341111111111111' | '30205252489926' | '3541963594572595' | '6799990100000000019' | '1111' | '0009' | '9926' | '2595' | '0019': Retrieves only transactions with the specified credit card number. You can use either the full number or the last 4 digits of the credit card number. **Note:** The last four digits in the test card number for Visa, MasterCard, and American Express are identical. In order to receive type-specific transactions, use the full test card number. <details> <summary>Allowed Card Numbers:</summary> | Card Type | Test Card Number | |:-------------------------------------|:--------------------| | Visa | 4111111111111111 | | MasterCard | 5431111111111111 | | Discover | 6011000991300009 | | American Express | 341111111111111 | | Diner's Club | 30205252489926 | | JCB | 3541963594572595 | | Maestro | 6799990100000000019 | | Visa, MasterCard, & American Express | 1111 | | Discover | 0009 | | Diner's Club | 9926 | | JCB | 2595 | | Maestro | 0019 | </details>
  - `merchant_defined_field_1` string: Retrieves only transactions with the specified merchant defined field value.<br>Replace the '1' with a field number (1-20) (Example: `merchant_defined_field_12=value`)
  - `start_date` string, date-time: Only transactions that have been modified on or after this date will be retrieved.<br>Note that any actions performed on a transaction will cause the modified date to be updated.<br><br>Format: `YYYYMMDDhhmmss`
  - `end_date` string, date-time: Only transactions that have been modified on or before this date will be retrieved.<br>Note that any actions performed on a transaction will cause the modified date to be updated.<br><br>Format: `YYYYMMDDhhmmss`
  - `report_type` 'receipt' | 'customer_vault' | 'recurring' | 'recurring_plans' | 'invoicing' | 'gateway_processors' | 'account_updater' | 'test_mode_status' | 'profile': Sets the report type. * If you would like to query the Customer Vault to view what customer information is stored in the Customer Vault, you must set the customer_vault variable. * If you omit the customer_vault_id, the system will return all customers that are stored in the vault. * If you include a customer_vault_id, it will return the customer record associated with that ID. Example: `report_type=customer_vault&customer_vault _id=123456789` <details> <summary>Report Types</summary> | Report Type | Description | |:-------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | receipt | Will return an html receipt for a specified transaction id. | | customer_vault | Set the Query API to return Customer Vault data. | | recurring | Set the Query API to return subscription data. | | recurring_plans | Set the Query API to return plan data. | | invoicing | Set the Query API to return invoicing data. | | gateway_processors | Will return Processor details a user has permissions for. Specify a "user" by <br>querying with that security key. | | account_updater | Will return Customer Vault data that has been updated using the <br>Account Updater service. | | test_mode_status | Will return whether the account has test mode active or inactive. | | profile | Return merchant profile (company, email, address, timezone, defined fields, <br>gateway, favicon, status). It will also return card_schemes with <br>'processor_details' set to 'true' | </details>
  - `mobile_device_license` string: Retrieves only transactions processed using the specified mobile device. * The device IDs for this parameter are available in the License Manager. * Use 'any_mobile' to retrieve all mobile transactions. * A combination of the values can be used and should be separated by commas. * Can not be used with 'mobile_device_nickname'. Example 1: `mobile_device_license=D91AC56A-4242-3131-2323-2AE4AA6DB6EB` <br>Example 2: `mobile_device_license=any_mobile`
  - `mobile_device_nickname` string: Retrieves only transactions processed using mobile devices with the specified nickname. * The nicknames for this parameter are available in the License Manager. * Can not be used with 'mobile_device_license'. Example (URL encoded): `mobile_device_nickname=Jim's%20iPhone`
  - `customer_vault_id` string: Set a specific Customer Vault record. Should only be used when `report_type=customer_vault`.
  - `date_search` 'created' | 'updated': Allows Customer Vault information to be returned based on the 'created' or 'updated' date. * If you would like to query the Customer Vault to view when customer information was created or updated, you must set the report_type variable with the customer_vault value. * If you omit the report_type variable, the system will ignore the date_search variable. Example: `report_type=customer_vault&date_search=created,updated&start_date=20170101000000&end_date=20201231232359` | Value | Description | |:---------|:------------------------------------------------------------------------| | created | Will return Customer Vault data created during a specified date range. | | updated | Will return Customer Vault data updated during a specified date range. |
  - `result_limit` integer: Determines the maximum number of results that may return for the current query.
  - `page_number` integer: Determines which "page" of results are returned. For example, `result_limit=100&page_number=0` will return the first 100 results. Using `page_number=1` will return the next 100 results. Default - `0`.
  - `result_order` 'standard' | 'reverse': Determines order of in which results are returned. Default - `standard`. <details> <summary>Result Orders</summary> | Result Order | Description | |:-----------------|:--------------------------------------------| | standard | Returns the results from oldest to newest. | | reverse | Returns the results from newest to oldest. |
  - `invoice_status` 'open' | 'paid' | 'closed' | 'past_due': Specify a comma separated list of what invoice statuses will return when using an "invoicing" report type.<br><br>Example: `invoice_status=open,closed,paid`
  - `processor_details` string: Can be use with `"report_type"="profile"`, this will include merchant `"card_schemes"` in the response
  - `additionalProperties` string: Up to 20 `merchant_defined_field_#` are allowed.

## Response `200`

ok

---

[API](https://skmtc.dev/nmi/apis/payments-api.md) - [All operations](https://skmtc.dev/nmi/apis/payments-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nmi/apis/payments-api/revisions/c03727f27e27?raw)
