# Update an invoice

> Changes the amount, lines, description or expiry of an invoice before it is paid.

Source: https://docs.tappay.mn/reference/invoices/update/

Changes the amount, lines, description or expiry of an [invoice](https://docs.tappay.mn/glossary.md#invoice) before it is paid. Send either `amount` or `lines`, and your settings decide which fields you can edit.

`PATCH /api/v1/invoices/{id}` Since 2026-09-27

### Authentication

Secret key (Bearer)

### Headers

| Name | Type | Required | Values | Description |
| - | - | - | - | - |
| `TapPay-Version` | string | no | | |
| `TapPay-Timestamp` | string | no | | |
| `TapPay-Nonce` | string | no | | |
| `TapPay-Signature` | string | no | | |
| `Idempotency-Key` | string | yes | | |

### Path parameters

| Name | Type | Required | Values | Description |
| - | - | - | - | - |
| `id` | string (uuid) | yes | | |

### Query parameters

| Name | Type | Required | Values | Description |
| - | - | - | - | - |
| `terminalId` | string (uuid) | no | | |

### Request body

| Name | Type | Required | Values | Description |
| - | - | - | - | - |
| `amount` | number | no | | |
| `lines` | array\<object> | no | | |
| `lines[].name` | string | yes | | |
| `lines[].quantity` | string | yes | | |
| `lines[].unitPrice` | string | yes | | |
| `lines[].totalAmount` | string | yes | | |
| `lines[].classificationCode` | string | no | | |
| `lines[].measureUnit` | string | no | | |
| `lines[].taxProductCode` | string | no | | |
| `lines[].barCode` | string | no | | |
| `lines[].barCodeType` | string | no | `GS1`, `ISBN`, `UNDEFINED` | |
| `description` | string | no | | |
| `expiresAt` | string | no | | |

### Response 200

| Name | Type | Required | Values | Description |
| - | - | - | - | - |
| `success` | boolean | yes | `true` | |
| `data` | object | yes | | |
| `data.id` | string | yes | | |
| `data.orderId` | string | yes | | |
| `data.status` | string | yes | `OPEN`, `PARTIALLY_PAID`, `PAID`, `EXPIRED`, `CANCELLED` | |
| `data.amount` | number | yes | | |
| `data.amountPaid` | number | yes | | |
| `data.amountReserved` | number | yes | | |
| `data.partialMode` | string | yes | `NONE`, `AMOUNT`, `LINES` | |
| `data.merchantServiceId` | string \| null | yes | | |
| `data.currency` | string | yes | | |
| `data.description` | string \| null | yes | | |
| `data.allowedChannels` | array \| null | yes | | |
| `data.expiresAt` | string | yes | | |
| `data.paidAt` | string \| null | yes | | |
| `data.createdAt` | string | yes | | |
| `data.terminalId` | string | yes | | |
| `data.customer` | string \| null | yes | | |
| `data.intentIds` | array\<string> | yes | | |
| `data.lines` | array\<object> | yes | | |
| `data.lines[].seq` | integer | yes | | |
| `data.lines[].name` | string | yes | | |
| `data.lines[].quantity` | string | yes | | |
| `data.lines[].unitPrice` | string | yes | | |
| `data.lines[].totalAmount` | string | yes | | |
| `data.lines[].quantityPaid` | string | yes | | |
| `data.lines[].quantityReserved` | string | yes | | |
| `data.intents` | array\<object> | yes | | |
| `data.intents[].id` | string | yes | | |
| `data.intents[].amount` | number | yes | | |
| `data.intents[].status` | string | yes | `OPEN`, `PROCESSING`, `SUCCEEDED`, `EXPIRED`, `CANCELLED` | |
| `data.intents[].expiresAt` | string | yes | | |
| `data.intents[].serviceFee` | number \| null | yes | | |
| `data.intents[].total` | number | yes | | |
| `data.fulfillment` | object \| null | yes | | |
| `data.fulfillment.status` | string | yes | `PENDING`, `IN_PROGRESS`, `COMPLETED`, `FAILED`, `CANCELLED` | |
| `data.fulfillment.stage` | string \| null | yes | | |
| `data.fulfillment.message` | string \| null | yes | | |
| `data.fulfillment.updatedAt` | string (date-time) | yes | | |
| `data.ebarimtIssuer` | string \| null | yes | `MERCHANT`, `NONE`, `NODE`, `null` | |

### Errors

| Code | Status | Message |
| - | - | - |
| [`AUTH-001`](https://docs.tappay.mn/errors.md#AUTH-001) | 401 | The API key is missing, invalid or revoked. |
| [`EVT-206`](https://docs.tappay.mn/errors.md#EVT-206) | 401 | Production keys are not accepted in the sandbox. Use a sandbox key (sk_test\_/pk_test\_). |
| [`EVT-207`](https://docs.tappay.mn/errors.md#EVT-207) | 401 | Sandbox keys are not accepted in production. Use a production key (sk_live\_/pk_live\_). |
| [`AUTH-018`](https://docs.tappay.mn/errors.md#AUTH-018) | 403 | The request came from an IP address that is not on the key's allowlist. |
| [`AUTH-058`](https://docs.tappay.mn/errors.md#AUTH-058) | 403 | The API key does not have the scope this operation requires. |
| [`SIG-002`](https://docs.tappay.mn/errors.md#SIG-002) | 401 | The request timestamp is outside the allowed time window. |
| [`SIG-003`](https://docs.tappay.mn/errors.md#SIG-003) | 401 | The request signature is missing or does not match. |
| [`SIG-005`](https://docs.tappay.mn/errors.md#SIG-005) | 409 | This request nonce was already used. |
| [`VAL-014`](https://docs.tappay.mn/errors.md#VAL-014) | 400 | The TapPay-Version header is not a known API version. |
| [`BIZ-004`](https://docs.tappay.mn/errors.md#BIZ-004) | 403 | The terminal is not active. |
| [`BIZ-005`](https://docs.tappay.mn/errors.md#BIZ-005) | 403 | The merchant account is not in a state that allows this request. |
| [`VAL-002`](https://docs.tappay.mn/errors.md#VAL-002) | 400 | A required field or header is missing. |
| [`VAL-010`](https://docs.tappay.mn/errors.md#VAL-010) | 409 | This Idempotency-Key was already used with a different request body. |
| [`VAL-013`](https://docs.tappay.mn/errors.md#VAL-013) | 409 | A request with this Idempotency-Key is still being processed. |
| [`VAL-001`](https://docs.tappay.mn/errors.md#VAL-001) | 400 | The request failed validation. |
| [`PAY-001`](https://docs.tappay.mn/errors.md#PAY-001) | 404 | The invoice was not found. |
| [`PAY-002`](https://docs.tappay.mn/errors.md#PAY-002) | 409 | The invoice has already been paid. |
| [`PAY-003`](https://docs.tappay.mn/errors.md#PAY-003) | 410 | The invoice has expired. |
| [`PAY-004`](https://docs.tappay.mn/errors.md#PAY-004) | 410 | The invoice was cancelled. |
| [`PAY-018`](https://docs.tappay.mn/errors.md#PAY-018) | 422 | The invoice lines are invalid or their total does not match the amount. |
| [`PAY-037`](https://docs.tappay.mn/errors.md#PAY-037) | 422 | Editing this field is not allowed by your settings. |
| [`PAY-038`](https://docs.tappay.mn/errors.md#PAY-038) | 409 | A payment for this invoice is in progress, so it cannot be edited. |
| [`PAY-039`](https://docs.tappay.mn/errors.md#PAY-039) | 422 | Subscription invoices and payer-created intents cannot be edited. |
| [`PAY-040`](https://docs.tappay.mn/errors.md#PAY-040) | 422 | Send either amount or lines, not both; with lines, the amount is their total. |
| [`AFP-001`](https://docs.tappay.mn/errors.md#AFP-001) | 409 | The payment intent is locked by another operation. |
| [`ORD-011`](https://docs.tappay.mn/errors.md#ORD-011) | 409 | The fulfillment of an order invoice is managed by the order. |
| [`SET-007`](https://docs.tappay.mn/errors.md#SET-007) | 422 | The value violates a platform limit. |

Try it in the playground: https://docs.tappay.mn/reference/invoices/update/

```bash title="curl"
curl -sS -X PATCH "https://api.tappay.mn/api/v1/invoices/INVOICE_ID" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Content-Type: application/json" \
  -d '{"amount":1200,"description":"Order 1, large cup"}'
```

```js title="Node.js"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const invoice = await tappay.invoices.update({ id: 'INVOICE_ID', body: { amount: 1200, description: 'Order 1, large cup' } });
console.log(JSON.stringify(invoice));
```

```php title="PHP"
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$invoice = $tappay->invoices->update(['id' => 'INVOICE_ID', 'body' => ['amount' => 1200, 'description' => 'Order 1, large cup']]);
echo json_encode($invoice);
```

```python title="Python"
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
invoice = client.invoices.update({"id": "INVOICE_ID", "body": {"amount": 1200, "description": "Order 1, large cup"}})
print(json.dumps(invoice))
```

```json title="Response"
{
  "success": true,
  "data": {
    "id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9e01",
    "orderId": "order-1048",
    "status": "OPEN",
    "amount": 1200,
    "amountPaid": 0,
    "amountReserved": 1200,
    "partialMode": "NONE",
    "merchantServiceId": null,
    "currency": "MNT",
    "description": "Order 1, large cup",
    "allowedChannels": null,
    "expiresAt": "2026-10-03T08:45:00.000Z",
    "paidAt": null,
    "createdAt": "2026-10-03T08:15:00.000Z",
    "terminalId": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9e05",
    "customer": null,
    "intentIds": [
      "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9e03"
    ],
    "lines": [],
    "intents": [
      {
        "id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9e03",
        "amount": 1200,
        "serviceFee": null,
        "total": 1200,
        "status": "OPEN",
        "expiresAt": "2026-10-03T08:45:00.000Z"
      }
    ],
    "fulfillment": null,
    "ebarimtIssuer": "MERCHANT"
  }
}
```

TapPay sends `invoice.updated` after the change.
