# Update expense

- Sandbox: `PATCH https://sandbox.payme.io/api/public/expenses/{expenseId}`
- Production: `PATCH https://live.payme.io/api/public/expenses/{expenseId}`

## Credentials

- Header `Authorization: Bearer <token>`

Partially update an existing expense document. Only expenses with `pending` status can be updated.

The partner can only update expenses within their own scope, and the expense must belong to the provided `sellerId`.

**Immutable fields** (rejected if provided): `id`, `uid`, `partnerId`, `createdAt`, `updatedAt`, `updatedBy`, `seller`, `supplierSnapshot`, `vatReportSnapshot`, `isAbleToAutoApprove`, `status`.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `expenseId` | path | string | yes | Expense UUID to update |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sellerId` | string | no | Seller UUID the expense belongs to |
| `valueDate` | string | no | Expense value date (ISO 8601 UTC) |
| `totalAmount` | number | no | Total expense amount |
| `vatAmount` | number | no | VAT amount (must be ≤ totalAmount) |
| `currency` | string | no | Currency code |
| `captureMethod` | string | no | How the expense was captured (e.g., 'manual') |
| `docType` | string | no | Document type |
| `docRegulationId` | string | no | Document regulation ID |
| `docLocatorNumber` | string | no | Document locator number |
| `classification` | integer | no | Classification ID (must be valid for seller/partner context) |
| `deductibleIncomeTaxPercent` | integer | no | Deductible income tax percentage (0–100) |
| `deductibleVatPercent` | integer | no | Deductible VAT percentage (0–100) |
| `assetVatRefundPercent` | integer | no | Asset VAT refund percentage (0–100) |
| `comment` | string | no | Optional partner note |
| `supplierName` | string | no | Supplier name |
| `supplierVatId` | string | no | Supplier VAT ID |
| `vatAllocationNumber` | string | no | VAT allocation number (nullable) |
| `isExcludeFromPCN` | boolean | no | Whether to exclude from PCN report |

### Request example

```json
{
  "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
  "valueDate": "2025-10-28T00:00:00.000Z",
  "totalAmount": 15000,
  "vatAmount": 2288,
  "currency": "ILS",
  "captureMethod": "manual",
  "docType": "invrec",
  "docRegulationId": "5132277",
  "docLocatorNumber": "85712",
  "classification": 6,
  "deductibleIncomeTaxPercent": 100,
  "deductibleVatPercent": 100,
  "assetVatRefundPercent": 0,
  "comment": "Optional partner note",
  "supplierName": "Supplier Ltd",
  "supplierVatId": "123456789",
  "vatAllocationNumber": null,
  "isExcludeFromPCN": false
}
```

## Code samples

### curl

```bash
curl -X PATCH 'https://sandbox.payme.io/api/public/expenses/<expenseId>' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_TOKEN>' \
  --data-raw '{
  "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
  "valueDate": "2025-10-28T00:00:00.000Z",
  "totalAmount": 15000,
  "vatAmount": 2288,
  "currency": "ILS",
  "captureMethod": "manual",
  "docType": "invrec",
  "docRegulationId": "5132277",
  "docLocatorNumber": "85712",
  "classification": 6,
  "deductibleIncomeTaxPercent": 100,
  "deductibleVatPercent": 100,
  "assetVatRefundPercent": 0,
  "comment": "Optional partner note",
  "supplierName": "Supplier Ltd",
  "supplierVatId": "123456789",
  "vatAllocationNumber": null,
  "isExcludeFromPCN": false
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/public/expenses/<expenseId>", {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
  body: JSON.stringify({
    "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
    "valueDate": "2025-10-28T00:00:00.000Z",
    "totalAmount": 15000,
    "vatAmount": 2288,
    "currency": "ILS",
    "captureMethod": "manual",
    "docType": "invrec",
    "docRegulationId": "5132277",
    "docLocatorNumber": "85712",
    "classification": 6,
    "deductibleIncomeTaxPercent": 100,
    "deductibleVatPercent": 100,
    "assetVatRefundPercent": 0,
    "comment": "Optional partner note",
    "supplierName": "Supplier Ltd",
    "supplierVatId": "123456789",
    "vatAllocationNumber": null,
    "isExcludeFromPCN": false
  }),
});

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

### Python

```python
import requests

response = requests.patch(
    "https://sandbox.payme.io/api/public/expenses/<expenseId>",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
    json={
        "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
        "valueDate": "2025-10-28T00:00:00.000Z",
        "totalAmount": 15000,
        "vatAmount": 2288,
        "currency": "ILS",
        "captureMethod": "manual",
        "docType": "invrec",
        "docRegulationId": "5132277",
        "docLocatorNumber": "85712",
        "classification": 6,
        "deductibleIncomeTaxPercent": 100,
        "deductibleVatPercent": 100,
        "assetVatRefundPercent": 0,
        "comment": "Optional partner note",
        "supplierName": "Supplier Ltd",
        "supplierVatId": "123456789",
        "vatAllocationNumber": None,
        "isExcludeFromPCN": False,
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
  "valueDate": "2025-10-28T00:00:00.000Z",
  "totalAmount": 15000,
  "vatAmount": 2288,
  "currency": "ILS",
  "captureMethod": "manual",
  "docType": "invrec",
  "docRegulationId": "5132277",
  "docLocatorNumber": "85712",
  "classification": 6,
  "deductibleIncomeTaxPercent": 100,
  "deductibleVatPercent": 100,
  "assetVatRefundPercent": 0,
  "comment": "Optional partner note",
  "supplierName": "Supplier Ltd",
  "supplierVatId": "123456789",
  "vatAllocationNumber": null,
  "isExcludeFromPCN": false
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/public/expenses/<expenseId>');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer <YOUR_TOKEN>',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

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

echo $response;
```

## Responses

### 200 — Expense updated successfully (success)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | 0 for success |
| `payload` | object |  |
| `payload.expenseId` | string | Expense UUID |
| `payload.sellerId` | string | Seller UUID |
| `payload.valueDate` | string | Expense value date |
| `payload.totalAmount` | number | Total expense amount |
| `payload.vatAmount` | number | VAT amount |
| `payload.currency` | string | Currency code |
| `payload.docType` | string | Document type |
| `payload.docRegulationId` | string | Document regulation ID |
| `payload.docLocatorNumber` | string | Document locator number |
| `payload.classification` | integer | Classification ID |
| `payload.capturedDate` | string | Timestamp when expense was captured |
| `payload.updatedAt` | string | Last update timestamp |

```json
{
  "statusCode": 0,
  "payload": {
    "expenseId": "edc855f7-cb7c-4d82-8c26-baf5c296d391",
    "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
    "valueDate": "2025-10-28T00:00:00.000Z",
    "totalAmount": 15000,
    "vatAmount": 2288,
    "currency": "ILS",
    "docType": "invrec",
    "docRegulationId": "5132277",
    "docLocatorNumber": "85712",
    "classification": 6,
    "capturedDate": "2025-10-28T09:13:37.423Z",
    "updatedAt": "2025-10-28T09:16:33.795Z"
  }
}
```

### 400 — Validation error (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | 1 for error |
| `payload` | object |  |
| `payload.message` | string | Error message |
| `payload.additionalInfo` | object | Field-level validation details |

```json
{
  "statusCode": 1,
  "payload": {
    "message": "Invalid request",
    "additionalInfo": {
      "valueDate": "Must be a valid ISO datetime",
      "totalAmount": "Must be >= 0"
    }
  }
}
```

### 401 — Unauthorized (error)

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

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

### 403 — Partner is not authorized to update this expense (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | 1 for error |
| `payload` | object |  |
| `payload.message` | string | Error message |
| `payload.additionalInfo` | object | Field-level validation details |

```json
{
  "statusCode": 1,
  "payload": {
    "message": "Not allowed"
  }
}
```

### 404 — Expense or seller not found (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | 1 for error |
| `payload` | object |  |
| `payload.message` | string | Error message |
| `payload.additionalInfo` | object | Field-level validation details |

```json
{
  "statusCode": 1,
  "payload": {
    "message": "Expense not found"
  }
}
```

### 409 — Update conflict (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | 1 for error |
| `payload` | object |  |
| `payload.message` | string | Error message |
| `payload.additionalInfo` | object | Field-level validation details |

```json
{
  "statusCode": 1,
  "payload": {
    "message": "Update conflict"
  }
}
```

### 429 — Rate limit exceeded (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | 1 for error |
| `payload` | object |  |
| `payload.message` | string | Error message |
| `payload.additionalInfo` | object | Field-level validation details |

```json
{
  "statusCode": 1,
  "payload": {
    "message": "Rate limit exceeded"
  }
}
```
