# List expenses

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

## Credentials

- Header `Authorization: Bearer <token>`

Retrieve expense records for a seller with optional date filtering and pagination.

**Seller identification:** Same rules as the upload endpoint — provide `sellerId` alone, or `socialId` + `email`.

**Date filtering:** `valueDateStart` and `valueDateEnd` filter on the expense value date (not creation date). Dates must be ISO format (`YYYY-MM-DD`) and `valueDateStart` must be ≤ `valueDateEnd`.

**Pagination:** Defaults to `page=0`, `limit=10`. Maximum `limit=500`.

Expenses not found are silently omitted. Order of returned items is not guaranteed.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `sellerId` | query | string | no | Seller UUID (use this OR socialId + email) |
| `socialId` | query | string | no | Seller social/business ID number (must be paired with email) |
| `email` | query | string | no | Seller email address (must be paired with socialId) |
| `valueDateStart` | query | string | no | Filter expenses from this value date (inclusive, YYYY-MM-DD) |
| `valueDateEnd` | query | string | no | Filter expenses up to this value date (inclusive, YYYY-MM-DD) |
| `page` | query | integer | no | Page number (zero-based) |
| `limit` | query | integer | no | Items per page |

## Code samples

### curl

```bash
curl -X GET 'https://sandbox.payme.io/api/public/expenses' \
  -H 'Authorization: Bearer <YOUR_TOKEN>'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/public/expenses", {
  method: "GET",
  headers: {
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
});

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

### Python

```python
import requests

response = requests.get(
    "https://sandbox.payme.io/api/public/expenses",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
)

print(response.text)
```

### PHP

```php
<?php

$ch = curl_init('https://sandbox.payme.io/api/public/expenses');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <YOUR_TOKEN>',
    ],
]);

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

echo $response;
```

## Responses

### 200 — Expenses retrieved successfully (success)

| Field | Type | Description |
| --- | --- | --- |
| `payload` | object |  |
| `payload.total` | integer | Total number of matching expenses |
| `payload.page` | integer | Current page number |
| `payload.limit` | integer | Items per page |
| `payload.items` | array |  |
| `payload.items[].id` | string | Expense record UUID |
| `payload.items[].capturedDate` | string | Timestamp when the expense was captured |
| `payload.items[].valueDate` | string | Expense value date |
| `payload.items[].sellerId` | string | Seller UUID |
| `payload.items[].totalAmount` | number | Total expense amount |
| `payload.items[].vatAmount` | number | VAT amount |
| `payload.items[].currency` | string | Currency code |
| `payload.items[].bookkeeperRevisionStatus` | string | Bookkeeper revision status |
| `payload.items[].docRegulationId` | string | Document regulation ID |
| `payload.items[].docType` | string | Document type |

```json
{
  "payload": {
    "total": 1,
    "page": 0,
    "limit": 10,
    "items": [
      {
        "id": "50c6b740-874a-4f54-9669-9a60024be4ed",
        "capturedDate": "2024-06-20T09:35:36.326Z",
        "valueDate": "2024-06-20T00:00:00.000Z",
        "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
        "totalAmount": 15200,
        "vatAmount": 2209,
        "currency": "ILS",
        "bookkeeperRevisionStatus": "approved-and-classified",
        "docRegulationId": "1262",
        "docType": "invrec"
      }
    ]
  }
}
```

### 400 — Bad Request (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 400,
  "message": [
    "Validation failed"
  ],
  "error": "Bad Request"
}
```

### 401 — Unauthorized (error)

| Field | Type | Description |
| --- | --- | --- |
| `error` | string |  |
| `error_description` | string |  |

```json
{
  "error": "unauthorized_client",
  "error_description": "Client authentication failed"
}
```

### 422 — Unprocessable Entity (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 422,
  "message": "Bad seller configuration. Please contact support!",
  "error": "Unprocessable Entity"
}
```
