# Query Existing Documents

- Sandbox: `GET https://sandbox.payme.io/api/documents`
- Production: `GET https://live.payme.io/api/documents`

## Credentials

- Header `PayMe-Merchant-Key` (optional)

## Overview

In order to query for existing documents, you will need to use the following endpoint and parameters:
 
Environment | URL
---|---
`Sandbox`| `https://sandbox.payme.io/api/documents?page=0&limit=5&field=createdAt&sort=desc`
`Production` | `https://live.payme.io/api/documents?page=0&limit=5&field=createdAt&sort=desc`

##### Header
Parameter | Description 
---|---
`PayMe-Merchant-Key` | Seller's MPL `MPL15991-38967CJU-GSBK5E1G-XSZ1GZXU`

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `page` | query | number | no | How many pages should be included in the query |
| `limit` | query | number | no | How many documents per extraction |
| `field` | query | string | no | The dates the query is for |
| `sort` | query | string | no | The order of documents |
| `PayMe-Merchant-Key` | header | string | no |  |

## Code samples

### curl

```bash
curl -X GET 'https://sandbox.payme.io/api/documents' \
  -H 'PayMe-Merchant-Key: <PayMe-Merchant-Key>'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/documents", {
  method: "GET",
  headers: {
    "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
  },
});

console.log(await response.text());
```

### Python

```python
import requests

response = requests.get(
    "https://sandbox.payme.io/api/documents",
    headers={
        "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
    },
)

print(response.text)
```

### PHP

```php
<?php

$ch = curl_init('https://sandbox.payme.io/api/documents');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'PayMe-Merchant-Key: <PayMe-Merchant-Key>',
    ],
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Responses

No responses are documented for this endpoint.
