# Get Contract Related Files

- Sandbox: `GET https://sandbox.payme.io/api/payment-contracts/CONT{GUID}/invoices/`
- Production: `GET https://live.payme.io/api/payment-contracts/CONT{GUID}/invoices/`

## Credentials

- Header `PayMe-Merchant-Key` (optional): PayMe seller ID

Allows receiving all files that are stored connected to a specific contract.
We can use it to receive all files connected to a contract or just a specific file.
To filter by various file types, we will use the following URL to receive the relevant file type - /CONT{GUID}/invoices?=Invoice Receipt

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `PayMe-Merchant-Key` | header | string | no | PayMe seller ID |
| `GUID` | path | string | yes | Doc ID |

## Request body

Content type: `application/json`

No Body

## Code samples

### curl

```bash
curl -X GET 'https://sandbox.payme.io/api/payment-contracts/CONT<GUID>/invoices/' \
  -H 'Content-Type: application/json' \
  -H 'PayMe-Merchant-Key: <PayMe-Merchant-Key>' \
  --data-raw '{}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/payment-contracts/CONT<GUID>/invoices/", {
  method: "GET",
  headers: {
    "Content-Type": "application/json",
    "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
  },
  body: JSON.stringify({}),
});

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

### Python

```python
import requests

response = requests.get(
    "https://sandbox.payme.io/api/payment-contracts/CONT<GUID>/invoices/",
    headers={
        "PayMe-Merchant-Key": "<PayMe-Merchant-Key>",
    },
    json={},
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/payment-contracts/CONT<GUID>/invoices/');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'PayMe-Merchant-Key: <PayMe-Merchant-Key>',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

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

echo $response;
```

## Responses

### 200 — Will return the URL of the file. (success)

| Field | Type | Description |
| --- | --- | --- |
| `status_code` | number |  |
| `invoices` | array |  |
| `invoices[].name` | string |  |
| `invoices[].mime_type` | string |  |
| `invoices[].type` | string |  |
| `invoices[].url` | string | A URL that will redirect to the file adderess |
| `invoices[].id` | string | File ID |

```json
{
  "status_code": 0,
  "invoices": [
    {
      "name": "test3",
      "mime_type": "image/jpeg",
      "type": "Invoice Receipt",
      "url": "https://reparser2.paymeservice.com/external/files/3e8ce1bb-c6ff-4e05-94df-f24f30928180",
      "id": "INV16477-93808TWJ-IBTSRXKV-1HXJYFXV"
    }
  ]
}
```
