# Search ad hoc documents.

Operation ID: `searchAdHocDocuments`

Group: Accounting › Ad Hoc Documents

[Open in the interactive reference](https://lensing.ai/api-docs/lensing/v1/endpoints/searchAdHocDocuments)

`POST /accounting/ad-hoc-documents/search`

Read-only: A read that takes its filters in the body. Changes nothing, and ignores Idempotency-Key.

Searches ad hoc documents. Each match is the full record, including its lines and every uuid reference a create needs. Use it for the queries a URL cannot carry: a customer or entity name, a document number, free text in the title or description, and the counterparty identifiers GET accounting/ad-hoc-documents deliberately keeps out of its filters.

The body has exactly two members, both optional: `filters`, holding every predicate, and `page`. An empty body is a valid first page of everything. Predicates are ANDed. Paging matches the list route's vocabulary, at this mechanism's own limits — default 50, capped at 200 — and the cursor is opaque and forward-only.

This resource replaces POST tax-documents/manual-taxable-documents/search, which is served in v1 only. Every request carries an `Api-Version` header; without it the request is rejected with 400, and a route that exists in another version answers 404.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | string · v1 | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version `v1`. |

## Request body

Required, `application/json`: searchAdHocDocumentsInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `filters` | object | no | Predicates to apply. A document must match every one you send, and omitting the whole object matches all documents. Example: `{"type":["outgoingInvoice"],"customerName":"northwind","paymentStatus":["unpaid","partiallyPaid"]}`. |
| `filters.id` | string | no | Exact match on a document's id (a UUID). This is how a single known document is fetched without its lines being the point. |
| `filters.taxDocumentNumber` | string | no | Exact match on the system-generated ad hoc document number. In the body because a document number must not travel in a URL. |
| `filters.documentNumber` | string | no | Exact match on the source document number — the counterparty's own number, or one carried over from an external system. In the body on the same grounds as taxDocumentNumber. |
| `filters.type` | array<string> | no | Restrict to documents of any of these kinds. An empty array does not constrain. |
| `filters.paymentStatus` | array<string> | no | Restrict to documents in any of these settlement statuses. An empty array does not constrain. |
| `filters.currency` | array<string> | no | Restrict to documents in any of these currencies, as 3-letter ISO 4217 codes. An empty array does not constrain. |
| `filters.title` | string | no | Case-insensitive SUBSTRING match on the document title. In the body because free text must never travel in a URL. |
| `filters.description` | string | no | Case-insensitive SUBSTRING match on the free-text document description. In the body because free text must never travel in a URL. |
| `filters.paymentTerms` | string | no | Case-insensitive SUBSTRING match on the payment terms recorded on the document. In the body because free text must never travel in a URL. |
| `filters.accountId` | string | no | Restrict to documents posting their offsetting entry to this account, given as the account id (a UUID). An id that matches no account yields an empty page, not an error. |
| `filters.postingPeriodId` | string | no | Restrict to documents that posted into this accounting period, given as the period id (a UUID). An id that matches no period yields an empty page, not an error. |
| `filters.customerId` | string | no | Restrict to documents issued to this customer, given as the customer id (a UUID). An id that matches no customer yields an empty page, not an error. |
| `filters.customerName` | string | no | Case-insensitive SUBSTRING match on the customer's name. In the body precisely because a counterparty name must never travel in a URL. |
| `filters.customerNumber` | string | no | Exact match on the customer's system-generated customer number. In the body on the same grounds as customerName. |
| `filters.vendorId` | string | no | Restrict to documents received from this vendor, given as the vendor id (a UUID). An id that matches no vendor yields an empty page, not an error. |
| `filters.employeeId` | string | no | Restrict to documents received from this employee, given as the employee id (a UUID). An id that matches no employee yields an empty page, not an error. |
| `filters.intercompanyEntityId` | string | no | Restrict to documents exchanged with this intercompany entity, given as the entity id (a UUID). An id that matches no entity yields an empty page, not an error. |
| `filters.entityId` | string | no | Restrict to documents belonging to this legal entity, given as the entity id (a UUID). An id that matches no entity yields an empty page, not an error. |
| `filters.entityName` | string | no | Case-insensitive SUBSTRING match on the legal entity's name. In the body because it names internal organisational structure. |
| `filters.invoiceDate` | object | no | Restrict to documents issued in this date window. Both bounds are calendar dates and are INCLUSIVE; omit either side to leave it open-ended. Format YYYY-MM-DD. |
| `filters.invoiceDate.start` | date | no | Earliest issue date to include. Inclusive. Omit for no lower bound. Format YYYY-MM-DD. |
| `filters.invoiceDate.end` | date | no | Latest issue date to include. Inclusive. Omit for no upper bound. Format YYYY-MM-DD. |
| `filters.serviceDate` | object | no | Restrict to documents whose service date falls in this window. Both bounds are INCLUSIVE; omit either side to leave it open-ended. Format YYYY-MM-DD. |
| `filters.serviceDate.start` | date | no | Earliest service date to include. Inclusive. Omit for no lower bound. Format YYYY-MM-DD. |
| `filters.serviceDate.end` | date | no | Latest service date to include. Inclusive. Omit for no upper bound. Format YYYY-MM-DD. |
| `filters.dueDate` | object | no | Restrict to documents falling due in this window. Both bounds are INCLUSIVE; omit either side to leave it open-ended. Format YYYY-MM-DD. |
| `filters.dueDate.start` | date | no | Earliest due date to include. Inclusive. Omit for no lower bound. Format YYYY-MM-DD. |
| `filters.dueDate.end` | date | no | Latest due date to include. Inclusive. Omit for no upper bound. Format YYYY-MM-DD. |
| `filters.lastModifiedDate` | object | no | Restrict to documents changed in this window — the incremental-sync filter. Both bounds are INCLUSIVE; omit either side to leave it open-ended. ISO 8601 UTC (YYYY-MM-DDTHH:mm:ss.sssZ). |
| `filters.lastModifiedDate.start` | date-time | no | Earliest change instant to include. Inclusive. Omit for no lower bound. ISO 8601 UTC (YYYY-MM-DDTHH:mm:ss.sssZ). |
| `filters.lastModifiedDate.end` | date-time | no | Latest change instant to include. Inclusive. Omit for no upper bound. ISO 8601 UTC (YYYY-MM-DDTHH:mm:ss.sssZ). |
| `filters.totalAmount` | object | no | Restrict by gross document total, in each document's own currency (use the currency filter to pin one). Both bounds are INCLUSIVE; omit either side to leave it open-ended. |
| `filters.totalAmount.min` | decimal | no | Smallest gross total to include. Inclusive. Omit for no lower bound. |
| `filters.totalAmount.max` | decimal | no | Largest gross total to include. Inclusive. Omit for no upper bound. |
| `filters.totalOpenAmount` | object | no | Restrict by remaining open balance, in each document's own currency. A voided or noPaymentNeeded document keeps an open balance, so to select the documents still outstanding filter paymentStatus on unpaid and partiallyPaid instead. Both bounds are INCLUSIVE; omit either side to leave it open-ended. |
| `filters.totalOpenAmount.min` | decimal | no | Smallest open balance to include. Inclusive. Omit for no lower bound. |
| `filters.totalOpenAmount.max` | decimal | no | Largest open balance to include. Inclusive. Omit for no upper bound. |
| `page` | object | no | Cursor and page size. Omit for the first page at the default size. Example: `{"size":25}`. |
| `page.cursor` | string | no | Opaque forward cursor from a previous response's pagination.nextCursor; omit for the first page. Do not construct manually. |
| `page.size` | number | no | Maximum number of documents to return. Defaults to 50, capped at 200; the server may return fewer, but never more. |

```json
{}
```

## Response

`200` Success

Under `data` (searchAdHocDocumentsOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | array<object> | yes | The matching ad hoc documents, newest first. Example: `[{"id":"3f2a9c14-7b6d-4e58-9a01-2c8f5d6e7a0b","type":"outgoingInvoice","taxDocumentNumber":"ADH-1042","documentNumber":"INV-2026-0188","title":"Consulting services, October","invoiceDate":"2026-10-31","currency":"EUR","paymentStatus":"unpaid","totalAmount":"1190.00","totalOpenAmount":"1190.00","accountId":"a41b6c70-2d85-4f19-8c03-5e7a9b1d2f46","postingPeriodId":"c82d4e90-1f63-4a27-b5d8-093e6c7a1b45","customerId":"7d1e8f20-3a4b-4c5d-9e60-1f2a3b4c5d6e","entityId":"1a9c4e70-38b5-4d26-9f01-7c2e5b8a6d43","lastModifiedDate":"2026-11-02T09:30:00.000Z","lines":[{"id":"9b0c1d2e-4f5a-4b6c-8d7e-0f1a2b3c4d5e","lineNumber":"1","taxableBasis":"1000.00","taxAmount":"190.00","totalAmount":"1190.00","accountId":"5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f"}]}]`. |
| `items[].id` | string | yes | Id of the ad hoc document (a UUID) — the public identifier used by this route. |
| `items[].type` | string | no | Kind of document. One of: `"outgoingInvoice"` (A customer-facing invoice. Its incoming payment can be matched to a bank deposit.), `"outgoingCredit"` (A credit issued to a customer, reducing what they owe.), `"incomingInvoice"` (An invoice received from a vendor, employee or intercompany entity.), `"incomingCredit"` (A credit received from a vendor, employee or intercompany entity.). |
| `items[].taxDocumentNumber` | string | no | System-generated ad hoc document number, unique per tenant and human-readable. Absent until one has been assigned. |
| `items[].documentNumber` | string | no | Document number as it appears on the source document — the counterparty's own number for an incoming document, or the number carried over from an external system. Distinct from taxDocumentNumber, which Everest assigns. |
| `items[].title` | string | no | Title of the document, as shown on the record. |
| `items[].description` | string | no | Free-text description of the document. |
| `items[].invoiceDate` | date | no | Date the document was issued. Format YYYY-MM-DD. |
| `items[].serviceDate` | date | no | Date the underlying service was provided. Drives the tax point where it differs from the invoice date. Format YYYY-MM-DD. |
| `items[].dueDate` | date | no | Date payment falls due. Absent when no due date has been set. Format YYYY-MM-DD. |
| `items[].currency` | string | no | Currency of this document as a 3-letter ISO 4217 code (e.g. USD, EUR, GBP). It governs every amount on the record, on the header and on every line alike. |
| `items[].paymentStatus` | string | no | Settlement status of the document, derived by the server from the document's allocations and the AR-ness of its posting account. One of: `"paid"` (Fully settled by payments.), `"partiallyPaid"` (Settled in part by payments; a balance remains.), `"unpaid"` (Receivable or payable in full, with nothing settled yet.), `"noPaymentNeeded"` (Posted to an account that carries no settlement, so no payment is expected.), `"voided"` (Voided. The journal entry it posted has been reversed and the document can no longer be settled.), `"applied"` (A credit fully applied against other documents.), `"unapplied"` (A credit with nothing applied yet.), `"partiallyApplied"` (A credit applied in part; a balance remains.), `"noApplicationNeeded"` (A credit posted to an account that carries no application, so none is expected.). |
| `items[].paymentTerms` | string | no | Payment terms recorded on the document, as free text (e.g. 'Net 30'). |
| `items[].totalTaxAmount` | decimal | no | Sum of the tax amounts of every line, in the document currency (see currency). |
| `items[].totalAmount` | decimal | no | Sum of the total amounts of every line — the gross document total, in the document currency (see currency). |
| `items[].totalAllocatedAmount` | decimal | no | Amount already allocated to this document by payments or credits, in the document currency (see currency). |
| `items[].totalOpenAmount` | decimal | no | Remaining unallocated balance on this document, in the document currency (see currency). A voided document keeps its open amount and a noPaymentNeeded one shows its full total here, so this alone does not tell whether a document is still open; use paymentStatus unpaid or partiallyPaid for that. |
| `items[].hasAttachment` | boolean | no | True when the document has at least one attachment. The attachments themselves are not published by this API; document delivery is a separate concern with its own permission. |
| `items[].accountId` | string | no | Id of the account the document posts its offsetting entry to (a UUID). Whether this account is a receivable account is what decides the document's paymentStatus. |
| `items[].postingPeriodId` | string | no | Id of the accounting period the document posted into (a UUID). Derived by the server from invoiceDate when the document is created, and read-only from then on. |
| `items[].customerId` | string | no | Id of the customer the document is issued to (a UUID). Set on customer-facing documents; absent on vendor, employee or intercompany ones. |
| `items[].customerName` | string | no | Display name of the customer. Personal and counterparty data — it is returned here but is not a filter on GET accounting/ad-hoc-documents, so it never travels in a URL. |
| `items[].customerNumber` | string | no | System-generated customer number of the customer, unique per tenant. |
| `items[].vendorId` | string | no | Id of the vendor the document is received from (a UUID). Set on vendor documents; absent otherwise. |
| `items[].employeeId` | string | no | Id of the employee the document is received from (a UUID). Set on employee documents; absent otherwise. |
| `items[].intercompanyEntityId` | string | no | Id of the intercompany entity the document is exchanged with (a UUID). Set on intercompany documents; absent otherwise. |
| `items[].entityId` | string | no | Id of the legal entity the document belongs to (a UUID). |
| `items[].entityName` | string | no | Name of the legal entity the document belongs to. |
| `items[].lastModifiedDate` | date-time | yes | Instant the document record last changed. Poll on this to sync incrementally rather than re-reading the whole collection. ISO 8601 UTC (YYYY-MM-DDTHH:mm:ss.sssZ). |
| `items[].lines` | array<object> | no | Lines of the document, each carrying one taxable position. Empty on a document with no lines. All line amounts are in the document currency (see currency). |
| `items[].lines[].id` | string | yes | Id of the document line (a UUID). |
| `items[].lines[].lineNumber` | string | no | System-generated line number within the document. Absent until one has been assigned. |
| `items[].lines[].description` | string | no | Free-text description of the line item. |
| `items[].lines[].taxableBasis` | decimal | no | Basis amount the tax is calculated on, in the document currency (see currency). |
| `items[].lines[].taxAmount` | decimal | no | Tax charged on the line, in the document currency (see currency). |
| `items[].lines[].totalAmount` | decimal | no | Line total, in the document currency (see currency): taxableBasis plus taxAmount, or taxableBasis alone on a reverse-charge line. Computed by the server. |
| `items[].lines[].accountId` | string | no | Id of the account this line books its revenue or cost to (a UUID). |
| `items[].lines[].taxConfigurationLineId` | string | no | Id of the tax configuration line that governs this line's tax (a UUID). Absent on a document whose entity has no tax configuration. |
| `items[].lines[].reportingTags` | array<object> | no | The reporting tags this line carries, in the same shape as a journal entry line's. Includes the customer, vendor or employee tag set from the document's counterparty. Empty when the line has none. |
| `items[].lines[].reportingTags[].dimensionCode` | string | yes | The reporting dimension this tag is for. Possible values: 'department', 'businessUnit', 'team', 'location', 'region', 'psaProject', 'employee', 'vendor', 'customer', 'product', 'valueCenter', 'custom'. |
| `items[].lines[].reportingTags[].modelId` | string | yes | The dimension record this tag points to (a UUID), on the model that dimensionCode names. |
| `items[].lines[].reportingTags[].customDimensionId` | string | no | The custom dimension this tag belongs to (a UUID). Present only for a custom-dimension tag. |
| `items[].lines[].reportingTags[].isActive` | boolean | yes | Whether the referenced dimension record is currently active. A document can carry tags that point at records since made inactive. |
| `pagination` | object | yes | Cursor and flag for fetching the next page. Example: `{"nextCursor":"eyJ2IjoxLCJrIjoiaWQiLCJwIjoxMDQyfQ","hasMore":true}`. |
| `pagination.nextCursor` | string | no | Pass back as page.cursor to fetch the next page. Absent on the last page. |
| `pagination.hasMore` | boolean | yes | Whether a further page exists. Always agrees with the presence of nextCursor. |

```json
{
  "data": {
    "items": [
      {
        "id": "3f2a9c14-7b6d-4e58-9a01-2c8f5d6e7a0b",
        "type": "outgoingInvoice",
        "taxDocumentNumber": "ADH-1042",
        "documentNumber": "INV-2026-0188",
        "title": "Consulting services, October",
        "invoiceDate": "2026-10-31",
        "currency": "EUR",
        "paymentStatus": "unpaid",
        "totalAmount": "1190.00",
        "totalOpenAmount": "1190.00",
        "accountId": "a41b6c70-2d85-4f19-8c03-5e7a9b1d2f46",
        "postingPeriodId": "c82d4e90-1f63-4a27-b5d8-093e6c7a1b45",
        "customerId": "7d1e8f20-3a4b-4c5d-9e60-1f2a3b4c5d6e",
        "entityId": "1a9c4e70-38b5-4d26-9f01-7c2e5b8a6d43",
        "lastModifiedDate": "2026-11-02T09:30:00.000Z",
        "lines": [
          {
            "id": "9b0c1d2e-4f5a-4b6c-8d7e-0f1a2b3c4d5e",
            "lineNumber": "1",
            "taxableBasis": "1000.00",
            "taxAmount": "190.00",
            "totalAmount": "1190.00",
            "accountId": "5c6d7e8f-9a0b-4c1d-8e2f-3a4b5c6d7e8f"
          }
        ]
      }
    ],
    "pagination": {
      "nextCursor": "eyJ2IjoxLCJrIjoiaWQiLCJwIjoxMDQyfQ",
      "hasMore": true
    }
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}
```

## Errors

| Code | Status |
| --- | --- |
| `INVALID_CURSOR` | 400 |

## Statuses

- `400` — Invalid request or business failure. Codes: INVALID_CURSOR
- `401` — The request carries no valid access token.
- `403` — Not authorized
- `404` — Not found
- `429` — Too many requests from this client address. The response has no body and no `Retry-After` header.
- `500` — Internal server error
