# Generate document preview

- Sandbox: `POST https://sandbox.payme.io/api/seller/api/documents/income/preview`
- Production: `POST https://live.payme.io/api/seller/api/documents/income/preview`

## Credentials

- Header `Authorization: Bearer <token>`

Generate a preview of an income document without saving it.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string | yes | Document type |
| `client` | object | yes |  |
| `client.name` | string | yes | Client/customer name |
| `client.email` | string | no | Client email address |
| `client.phone` | string | no | Client phone number |
| `client.socialId` | string | no | Client's social/business ID number (ת.ז. / ח.פ.) |
| `currency` | string | yes | Document currency (currently only ILS supported) |
| `docValueDate` | string | yes | Document value date |
| `dueDate` | string | no | Payment due date (required for invoice, deal, offer) |
| `title` | string | no | Document title (optional) |
| `docLang` | string | yes | Document language |
| `items` | array | yes | Document line items |
| `items[].name` | string | yes | Item name/description |
| `items[].quantity` | number | yes | Item quantity |
| `items[].itemNetPrice` | number | yes | Item net price (before VAT) |
| `items[].itemTotalPrice` | number | no | Item total price (calculated) |
| `items[].itemSumNetTotalPrice` | number | no | Item sum net total price (quantity * itemNetPrice) |
| `items[].itemCurrency` | string | yes | Item currency |
| `items[].isNoItemVat` | boolean | no | VAT exempt flag (true = no VAT for this item) |
| `bankDetails` | object | no | Bank account details for payment |
| `bankDetails.bankName` | string | no | Bank name |
| `bankDetails.branchNumber` | string | no | Branch number |
| `bankDetails.accountNumber` | string | no | Account number |
| `bankDetails.accountName` | string | no | Account holder name |
| `bankDetails.IBAN` | string | no | IBAN number |
| `subTotal` | number | no | Subtotal before discount |
| `discount` | number | no | Discount amount |
| `totalWithoutVatAmount` | number | no | Total amount without VAT |
| `vatAmount` | number | no | VAT amount |
| `totalAmount` | number | yes | Total amount including VAT |
| `totalPaid` | number | no | Total amount paid (required for receipts) |
| `originTaxDeduction` | number | no | Tax deduction at source (ניכוי מס במקור) |
| `comment` | string | no | Document comments/notes |
| `paymentCash` | object | no | Cash payment details |
| `paymentCash.date` | string | yes | Payment date |
| `paymentCash.amount` | number | yes | Payment amount |
| `paymentCreditCard` | object | no | Credit card payment details |
| `paymentCreditCard.date` | string | yes | Payment date |
| `paymentCreditCard.amount` | number | yes | Payment amount |
| `paymentCreditCard.last4Digits` | string | no | Last 4 digits of card |
| `paymentBankTransfer` | object | no | Bank transfer payment details |
| `paymentBankTransfer.date` | string | yes | Payment date |
| `paymentBankTransfer.amount` | number | yes | Payment amount |
| `paymentBankTransfer.bankNumber` | integer | no | Bank code |
| `paymentBankTransfer.branchNumber` | integer | no | Branch number |
| `paymentBankTransfer.accountNumber` | integer | no | Account number |
| `paymentCheque` | object | no | Cheque payment details |
| `paymentCheque.date` | string | yes | Cheque date |
| `paymentCheque.receivedDate` | string | yes | Date cheque was received |
| `paymentCheque.amount` | number | yes | Payment amount |
| `paymentCheque.chequeNumber` | string | yes | Cheque number |
| `paymentCheque.bankNumber` | integer | no | Bank code |
| `paymentCheque.branchNumber` | integer | no | Branch number |
| `paymentCheque.accountNumber` | integer | no | Account number |
| `paymentEWallet` | object | no | E-wallet payment details (PayPal, Bit, etc.) |
| `paymentEWallet.date` | string | yes | Payment date |
| `paymentEWallet.amount` | number | yes | Payment amount |
| `paymentEWallet.walletType` | string | yes | E-wallet type |
| `payment` | object | no | Payment link settings (for invoice/deal) |
| `payment.isEnabled` | boolean | no | Enable payment link |
| `payment.clientEmail` | string | no | Email to send payment link to |
| `payment.clientPhone` | string | no | Phone to send payment link to |
| `callbacks` | object | no | Callback URLs for async notifications |
| `callbacks.success` | array | no | URLs to call on success |
| `callbacks.error` | array | no | URLs to call on error |

### Request example

No example is documented; this template is generated from the fields — replace the placeholder values.

```json
{
  "type": "<type>",
  "client": {
    "name": "<name>"
  },
  "currency": "<currency>",
  "docValueDate": "<docValueDate>",
  "dueDate": "<dueDate>",
  "title": "<title>",
  "docLang": "<docLang>",
  "items": [],
  "bankDetails": {},
  "subTotal": 0,
  "discount": 0,
  "totalWithoutVatAmount": 0,
  "vatAmount": 0,
  "totalAmount": 0,
  "totalPaid": 0,
  "originTaxDeduction": 0,
  "comment": "<comment>",
  "paymentCash": {
    "date": "<date>",
    "amount": 0
  },
  "paymentCreditCard": {
    "date": "<date>",
    "amount": 0
  },
  "paymentBankTransfer": {
    "date": "<date>",
    "amount": 0
  },
  "paymentCheque": {
    "date": "<date>",
    "receivedDate": "<receivedDate>",
    "amount": 0,
    "chequeNumber": "<chequeNumber>"
  },
  "paymentEWallet": {
    "date": "<date>",
    "amount": 0,
    "walletType": "<walletType>"
  },
  "payment": {},
  "callbacks": {}
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/seller/api/documents/income/preview' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_TOKEN>' \
  --data-raw '{
  "type": "<type>",
  "client": {
    "name": "<name>"
  },
  "currency": "<currency>",
  "docValueDate": "<docValueDate>",
  "docLang": "<docLang>",
  "items": [],
  "totalAmount": 0
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/seller/api/documents/income/preview", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
  body: JSON.stringify({
    "type": "<type>",
    "client": {
      "name": "<name>"
    },
    "currency": "<currency>",
    "docValueDate": "<docValueDate>",
    "docLang": "<docLang>",
    "items": [],
    "totalAmount": 0
  }),
});

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

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/seller/api/documents/income/preview",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
    json={
        "type": "<type>",
        "client": {
            "name": "<name>",
        },
        "currency": "<currency>",
        "docValueDate": "<docValueDate>",
        "docLang": "<docLang>",
        "items": [],
        "totalAmount": 0,
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "type": "<type>",
  "client": {
    "name": "<name>"
  },
  "currency": "<currency>",
  "docValueDate": "<docValueDate>",
  "docLang": "<docLang>",
  "items": [],
  "totalAmount": 0
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/seller/api/documents/income/preview');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    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 — Preview generated successfully (success)

| Field | Type | Description |
| --- | --- | --- |
| `previewUrl` | string | URL to preview the document (temporary) |

### 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 |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 401,
  "message": "Unauthorized",
  "error": "Unauthorized"
}
```
