---
title: Purchase Invoices
slug: devdocs/purchase-invoices
docTags: 
createdAt: 2026-10-22T08:35:59.125Z
---

Purchase invoices are the invoices you receive from suppliers and enter in Expressoft. You can read them, and you can create new ones.

## Read purchase invoices

**Query**

```graphql
query GetPurchaseInvoices($organization: Guid, $dateBegin: DateTime, $dateEnd: DateTime, $first: Int, $after: String) {
  documents {
    purchaseInvoices(organization: $organization, dateBegin: $dateBegin, dateEnd: $dateEnd, first: $first, after: $after) {
      totalCount
      pageInfo {
        hasNextPage
        endCursor
      }
      items {
        key
        documentType
        status
        number
        date
        dueDate
        createdOn
        vatCollect
        discount
        isEUPurchase
        isNonEUPurchase
        company { key name fiscalCode }
        currency { key name rate }
        products {
          warehousePurchaseId
          quantity
          amount
          vatAmount
          vatRate
          salePrice
          salePriceVatRate
          product { key name code }
          warehouse { key name }
        }
      }
    }
  }
}
```

**Variables**

```json
{
  "organization": "<organization key>",
  "dateBegin": "2026-10-01T00:00:00",
  "dateEnd": "2026-10-31T23:59:59",
  "first": 30,
  "after": null
}
```

**cURL**

```bash
curl --location 'https://sandbox.expressoft.eu/connect/api/interopgql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{"query": "query GetPurchaseInvoices($organization: Guid, $dateBegin: DateTime, $dateEnd: DateTime, $first: Int, $after: String) { documents { purchaseInvoices(organization: $organization, dateBegin: $dateBegin, dateEnd: $dateEnd, first: $first, after: $after) { totalCount pageInfo { hasNextPage endCursor } items { key documentType status number date dueDate createdOn vatCollect discount isEUPurchase isNonEUPurchase company { key name fiscalCode } currency { key name rate } products { warehousePurchaseId quantity amount vatAmount vatRate salePrice salePriceVatRate product { key name code } warehouse { key name } } } } } }", "variables": {"organization": "<organization key>", "dateBegin": "2026-10-01T00:00:00", "dateEnd": "2026-10-31T23:59:59", "first": 30, "after": null}}'
```

**Response**

```json
{
  "data": {
    "documents": {
      "purchaseInvoices": {
        "totalCount": 1,
        "pageInfo": {
          "hasNextPage": false,
          "endCursor": "MQ=="
        },
        "items": [
          {
            "key": 1001,
            "documentType": "NIR",
            "status": "Finalized",
            "number": "FA-1001",
            "date": "2026-10-05T00:00:00",
            "dueDate": "2026-11-05T00:00:00",
            "createdOn": "2026-10-05T10:15:00",
            "vatCollect": false,
            "discount": 0.0,
            "isEUPurchase": false,
            "isNonEUPurchase": false,
            "company": {
              "key": "00000000-0000-0000-0000-000000000002",
              "name": "Example Supplier SRL",
              "fiscalCode": "87654321"
            },
            "currency": {
              "key": 1,
              "name": "RON",
              "rate": 1.0
            },
            "products": [
              {
                "warehousePurchaseId": 5001,
                "quantity": 10.0,
                "amount": 100.0,
                "vatAmount": 21.0,
                "vatRate": 21.0,
                "salePrice": null,
                "salePriceVatRate": null,
                "product": {
                  "key": "00000000-0000-0000-0000-000000000003",
                  "name": "Flour 1 kg",
                  "code": "P001"
                },
                "warehouse": {
                  "key": "00000000-0000-0000-0000-000000000004",
                  "name": "Main warehouse"
                }
              }
            ]
          }
        ]
      }
    }
  }
}
```

`key` is a number. Filter one invoice with `key: "<key>"`. `status` is `Draft`, `Finalized`, `Processed`. `documentType` is one of `NIR`, `NPR`, `FacturaFiscala`, `BorderouDeAchizitie`, `FacturaRetur`, `BonDeConsum`, `AvizDeExpeditie`, `Z`, `ReglareInventar`, `Productie`, `Reparare`, `BonFiscal`, `CarnetAgricol`, `AvizRetur`.

`crossDocuments` returns the related purchase invoices. `accountingNotes` returns the accounting entries of the invoice: see **Accounting Notes and Accounts**.

## Create a purchase invoice

`documents.purchaseInvoiceCreate` is the only write operation of the API. It adds a purchase invoice in Expressoft.

**Query**

```graphql
mutation CreatePurchaseInvoice($payload: PurchaseInvoiceCreateInputType!) {
  documents {
    purchaseInvoiceCreate(payload: $payload) {
      result {
        key
        number
        date
        status
        documentType
        company { key name }
        products {
          quantity
          amount
          vatAmount
        }
      }
      errorCode
      errorMessage
      errorData
    }
  }
}
```

**Variables**

```json
{
  "payload": {
    "organizationKey": "<organization key>",
    "documentNumber": "FA-1001",
    "documentDate": "2026-10-05T00:00:00",
    "documentType": "FacturaFiscala",
    "companyKey": "<company key>",
    "paymentAmount": 121,
    "vatAmount": 21,
    "dueDate": "2026-11-05T00:00:00",
    "products": [
      {
        "productKey": "<product key>",
        "quantity": 10,
        "price": 10,
        "amount": 100,
        "vatRate": 21,
        "vatAmount": 21,
        "warehouseKey": "<warehouse key>"
      }
    ]
  }
}
```

**cURL**

```bash
curl --location 'https://sandbox.expressoft.eu/connect/api/interopgql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{"query": "mutation CreatePurchaseInvoice($payload: PurchaseInvoiceCreateInputType!) { documents { purchaseInvoiceCreate(payload: $payload) { result { key number date status documentType company { key name } products { quantity amount vatAmount } } errorCode errorMessage errorData } } }", "variables": {"payload": {"organizationKey": "<organization key>", "documentNumber": "FA-1001", "documentDate": "2026-10-05T00:00:00", "documentType": "FacturaFiscala", "companyKey": "<company key>", "paymentAmount": 121, "vatAmount": 21, "dueDate": "2026-11-05T00:00:00", "products": [{"productKey": "<product key>", "quantity": 10, "price": 10, "amount": 100, "vatRate": 21, "vatAmount": 21, "warehouseKey": "<warehouse key>"}]}}}'
```

**Response**

```json
{
  "data": {
    "documents": {
      "purchaseInvoiceCreate": {
        "result": {
          "key": 1002,
          "number": "FA-1001",
          "date": "2026-10-05T00:00:00",
          "status": "Draft",
          "documentType": "FacturaFiscala",
          "company": {
            "key": "00000000-0000-0000-0000-000000000002",
            "name": "Example Supplier SRL"
          },
          "products": [
            {
              "quantity": 10.0,
              "amount": 100.0,
              "vatAmount": 21.0
            }
          ]
        },
        "errorCode": null,
        "errorMessage": null,
        "errorData": null
      }
    }
  }
}
```

| **Field**              | **Type**                             | **Required** |
| ---------------------- | ------------------------------------ | ------------ |
| `organizationKey`      | `Guid!`                              | yes          |
| `documentNumber`       | `String!`                            | yes          |
| `documentDate`         | `DateTime!`                          | yes          |
| `documentType`         | `DocumentType!`                      | yes          |
| `companyKey`           | `Guid!`                              | yes          |
| `discountAmount`       | `Decimal`                            | no           |
| `discountRate`         | `Decimal`                            | no           |
| `discountVatAmount`    | `Decimal`                            | no           |
| `paymentAmount`        | `Decimal!`                           | yes          |
| `vatAmount`            | `Decimal!`                           | yes          |
| `dueDate`              | `DateTime`                           | no           |
| `vatCollect`           | `Boolean`                            | no           |
| `vatOnReceipt`         | `Boolean`                            | no           |
| `currencyKey`          | `Guid`                               | no           |
| `currencyExchangeRate` | `Decimal`                            | no           |
| `currencyAmount`       | `Decimal`                            | no           |
| `currencyVat`          | `Decimal`                            | no           |
| `products`             | `[PurchaseInvoiceProductInputType]!` | yes          |

Each item of `products` is a `PurchaseInvoiceProductInputType`:

| **Field**           | **Type**   | **Required** |
| ------------------- | ---------- | ------------ |
| `productKey`        | `Guid!`    | yes          |
| `quantity`          | `Decimal!` | yes          |
| `price`             | `Decimal!` | yes          |
| `amount`            | `Decimal!` | yes          |
| `discountAmount`    | `Decimal`  | no           |
| `vatRate`           | `Decimal!` | yes          |
| `vatAmount`         | `Decimal!` | yes          |
| `discountVatAmount` | `Decimal`  | no           |
| `warehouseKey`      | `Guid!`    | yes          |
| `lotId`             | `Int`      | no           |
| `externalLot`       | `String`   | no           |

:::BlockQuote
💡 **TIP**
Get the keys from the other pages: `organizationKey` and `warehouseKey` from **Organizations and Reference Data**, `companyKey` from **Companies**, `productKey` from **Products**.
:::

## Error codes

When the invoice isn't created, `errorCode` is a number. The codes start at 0.

| **errorCode** | **Name**                   | **Likely cause**                                                 |
| ------------- | -------------------------- | ---------------------------------------------------------------- |
| 0             | `DocumentTypeNotSupported` | `documentType` isn't supported for a purchase invoice.           |
| 1             | `InvalidOrganization`      | `organizationKey` doesn't identify an organization.              |
| 2             | `InvalidWarehouse`         | A `warehouseKey` of a product line doesn't identify a warehouse. |
| 3             | `InvalidCompany`           | `companyKey` doesn't identify a company.                         |
| 4             | `InvalidProduct`           | A `productKey` doesn't identify a product.                       |
| 5             | `InvalidCurrency`          | `currencyKey` doesn't identify a currency.                       |
| 6             | `InvalidVATRate`           | A `vatRate` isn't valid.                                         |
| 7             | `EmptyDocument`            | The invoice has no product lines.                                |

