> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.staple.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.staple.ai/_mcp/server.

# Advanced Search Documents

POST https://api.staple.io/v2/search/documents
Content-Type: application/json

Search documents with advanced customizations and pre-configured formats.

Reference: https://docs.staple.ai/api-reference/v2/documents/advanced-search-documents

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: v2
  version: 1.0.0
paths:
  /v2/search/documents:
    post:
      operationId: advancedSearchDocuments
      summary: Advanced Search Documents
      description: >-
        Search documents with advanced customizations and pre-configured
        formats.
      tags:
        - documents
      parameters:
        - name: x-api-key
          in: header
          description: API key issued by Staple.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Documents_advancedSearchDocuments_Response_200
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                filter:
                  $ref: >-
                    #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilter
                pagination:
                  $ref: >-
                    #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaPagination
servers:
  - url: https://api.staple.io
    description: https://api.staple.io
components:
  schemas:
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterOthersFieldsItems:
      type: object
      properties:
        name:
          type: string
        value:
          type: string
      title: >-
        V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterOthersFieldsItems
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterOthers:
      type: object
      properties:
        docType:
          type: string
        fields:
          type: array
          items:
            $ref: >-
              #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterOthersFieldsItems
      title: V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterOthers
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterUploadedAt:
      type: object
      properties:
        from:
          type: string
        to:
          type: string
      title: >-
        V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterUploadedAt
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterCompletedAt:
      type: object
      properties:
        from:
          type: string
        to:
          type: string
      title: >-
        V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterCompletedAt
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterRejectedAt:
      type: object
      properties:
        from:
          type: string
        to:
          type: string
      title: >-
        V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterRejectedAt
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterExportedAt:
      type: object
      properties:
        from:
          type: string
        to:
          type: string
      title: >-
        V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterExportedAt
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilter:
      type: object
      properties:
        fileName:
          type: string
        queue:
          type: array
          items:
            type: integer
        tab:
          type: array
          items:
            type: string
        others:
          $ref: >-
            #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterOthers
        content:
          type: string
        uploadedBy:
          type: array
          items:
            type: integer
        completedBy:
          type: array
          items:
            type: integer
        rejectedBy:
          type: array
          items:
            type: integer
        exportedBy:
          type: array
          items:
            type: integer
        uploadedAt:
          $ref: >-
            #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterUploadedAt
        completedAt:
          $ref: >-
            #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterCompletedAt
        rejectedAt:
          $ref: >-
            #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterRejectedAt
        exportedAt:
          $ref: >-
            #/components/schemas/V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilterExportedAt
      title: V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaFilter
    V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaPagination:
      type: object
      properties:
        skip:
          type: integer
        take:
          type: integer
      title: V2SearchDocumentsPostRequestBodyContentApplicationJsonSchemaPagination
    Documents_advancedSearchDocuments_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Documents_advancedSearchDocuments_Response_200
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key issued by Staple.
    bearerAuth:
      type: http
      scheme: bearer
      description: JWT obtained from the login endpoint.

```

## Examples

### Advanced Search Documents



**Request**

```json
undefined
```

**Response**

```json
{
  "searchDocumentsByAdvancedFilter": {
    "data": [
      {
        "completeness": 83,
        "createdAt": 1722487590243,
        "fileName": "Vitec Inv. CD01245939 dd 15 Nov. 2018.pdf",
        "id": 30362,
        "isMatched": false,
        "matchedURL": "",
        "qid": 1,
        "queue": {
          "group": {
            "name": "development"
          },
          "name": "Multiple Invoices"
        },
        "reason": null,
        "status": "COMPLETED",
        "uid": 1,
        "uploadedAt": 1722487590243,
        "warningMessage": null
      },
      {
        "completeness": 83,
        "createdAt": 1722487605115,
        "fileName": "Vitec Inv. CD01245939 dd 15 Nov. 2018.pdf",
        "id": 30364,
        "isMatched": false,
        "matchedURL": "",
        "qid": 1,
        "queue": {
          "group": {
            "name": "development"
          },
          "name": "Multiple Invoices"
        },
        "reason": null,
        "status": "COMPLETED",
        "uid": 1,
        "uploadedAt": 1722487605115,
        "warningMessage": null
      },
      {
        "completeness": 83,
        "createdAt": 1722487624869,
        "fileName": "Vitec Inv. CD01245939 dd 15 Nov. 2018.pdf",
        "id": 30365,
        "isMatched": false,
        "matchedURL": "",
        "qid": 1,
        "queue": {
          "group": {
            "name": "development"
          },
          "name": "Multiple Invoices"
        },
        "reason": null,
        "status": "COMPLETED",
        "uid": 1,
        "uploadedAt": 1722487624869,
        "warningMessage": null
      },
      {
        "completeness": 67,
        "createdAt": 1722501440820,
        "fileName": "INV202407-03965-FP-001.pdf",
        "id": 30367,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "EXPORTED",
        "uid": 1,
        "uploadedAt": 1722501460327,
        "warningMessage": null
      },
      {
        "completeness": 58,
        "createdAt": 1722501460722,
        "fileName": "INV202407-03970-001.pdf",
        "id": 30368,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "EXPORTED",
        "uid": 1,
        "uploadedAt": 1722501476034,
        "warningMessage": null
      },
      {
        "completeness": 63,
        "createdAt": 1722501476317,
        "fileName": "INV202407-03972-001.pdf",
        "id": 30369,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722501490472,
        "warningMessage": null
      },
      {
        "completeness": 63,
        "createdAt": 1722501490722,
        "fileName": "INV202407-03976-001.pdf",
        "id": 30370,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722501505740,
        "warningMessage": null
      },
      {
        "completeness": 68,
        "createdAt": 1722501506025,
        "fileName": "INV202407-03987-001.pdf",
        "id": 30371,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722855443798,
        "warningMessage": null
      },
      {
        "completeness": 63,
        "createdAt": 1722501521623,
        "fileName": "INV202407-03988-001.pdf",
        "id": 30372,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722501536236,
        "warningMessage": null
      },
      {
        "completeness": 68,
        "createdAt": 1722501536620,
        "fileName": "INV202407-03996-001.pdf",
        "id": 30373,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722855727140,
        "warningMessage": null
      }
    ],
    "pageInfo": {
      "hasNextPage": true,
      "hasPreviousPage": false,
      "lastCursor": 30373
    },
    "total": 277
  }
}
```

**SDK Code**

```python Advanced Search Documents
import requests

url = "https://api.staple.io/v2/search/documents"

headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Advanced Search Documents
const url = 'https://api.staple.io/v2/search/documents';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: undefined
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Advanced Search Documents
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/search/documents"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Advanced Search Documents
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/search/documents")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'

response = http.request(request)
puts response.read_body
```

```java Advanced Search Documents
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/search/documents")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Advanced Search Documents
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/search/documents', [
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Advanced Search Documents
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/search/documents");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Advanced Search Documents
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/search/documents")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Documents_advancedSearchDocuments_example



**Request**

```json
{
  "filter": {
    "fileName": "invoice",
    "queue": [
      1,
      4
    ],
    "tab": [
      "RECEIVED",
      "COMPLETED"
    ],
    "others": {
      "docType": "INVOICE",
      "fields": [
        {
          "name": "InvoiceNumber",
          "value": "10"
        },
        {
          "name": "PONumber",
          "value": "90"
        }
      ]
    },
    "content": "invoice",
    "uploadedBy": [
      1,
      100
    ],
    "completedBy": [
      1
    ],
    "rejectedBy": [
      1
    ],
    "exportedBy": [
      1
    ],
    "uploadedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    },
    "completedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    },
    "rejectedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    },
    "exportedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    }
  },
  "pagination": {
    "skip": 0,
    "take": 100
  }
}
```

**Response**

```json
{
  "searchDocumentsByAdvancedFilter": {
    "data": [
      {
        "completeness": 83,
        "createdAt": 1722487590243,
        "fileName": "Vitec Inv. CD01245939 dd 15 Nov. 2018.pdf",
        "id": 30362,
        "isMatched": false,
        "matchedURL": "",
        "qid": 1,
        "queue": {
          "group": {
            "name": "development"
          },
          "name": "Multiple Invoices"
        },
        "reason": null,
        "status": "COMPLETED",
        "uid": 1,
        "uploadedAt": 1722487590243,
        "warningMessage": null
      },
      {
        "completeness": 83,
        "createdAt": 1722487605115,
        "fileName": "Vitec Inv. CD01245939 dd 15 Nov. 2018.pdf",
        "id": 30364,
        "isMatched": false,
        "matchedURL": "",
        "qid": 1,
        "queue": {
          "group": {
            "name": "development"
          },
          "name": "Multiple Invoices"
        },
        "reason": null,
        "status": "COMPLETED",
        "uid": 1,
        "uploadedAt": 1722487605115,
        "warningMessage": null
      },
      {
        "completeness": 83,
        "createdAt": 1722487624869,
        "fileName": "Vitec Inv. CD01245939 dd 15 Nov. 2018.pdf",
        "id": 30365,
        "isMatched": false,
        "matchedURL": "",
        "qid": 1,
        "queue": {
          "group": {
            "name": "development"
          },
          "name": "Multiple Invoices"
        },
        "reason": null,
        "status": "COMPLETED",
        "uid": 1,
        "uploadedAt": 1722487624869,
        "warningMessage": null
      },
      {
        "completeness": 67,
        "createdAt": 1722501440820,
        "fileName": "INV202407-03965-FP-001.pdf",
        "id": 30367,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "EXPORTED",
        "uid": 1,
        "uploadedAt": 1722501460327,
        "warningMessage": null
      },
      {
        "completeness": 58,
        "createdAt": 1722501460722,
        "fileName": "INV202407-03970-001.pdf",
        "id": 30368,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "EXPORTED",
        "uid": 1,
        "uploadedAt": 1722501476034,
        "warningMessage": null
      },
      {
        "completeness": 63,
        "createdAt": 1722501476317,
        "fileName": "INV202407-03972-001.pdf",
        "id": 30369,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722501490472,
        "warningMessage": null
      },
      {
        "completeness": 63,
        "createdAt": 1722501490722,
        "fileName": "INV202407-03976-001.pdf",
        "id": 30370,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722501505740,
        "warningMessage": null
      },
      {
        "completeness": 68,
        "createdAt": 1722501506025,
        "fileName": "INV202407-03987-001.pdf",
        "id": 30371,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722855443798,
        "warningMessage": null
      },
      {
        "completeness": 63,
        "createdAt": 1722501521623,
        "fileName": "INV202407-03988-001.pdf",
        "id": 30372,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722501536236,
        "warningMessage": null
      },
      {
        "completeness": 68,
        "createdAt": 1722501536620,
        "fileName": "INV202407-03996-001.pdf",
        "id": 30373,
        "isMatched": false,
        "matchedURL": "",
        "qid": 2842,
        "queue": {
          "group": {
            "name": "LLM Project X"
          },
          "name": "TAP"
        },
        "reason": null,
        "status": "RECEIVED",
        "uid": 1,
        "uploadedAt": 1722855727140,
        "warningMessage": null
      }
    ],
    "pageInfo": {
      "hasNextPage": true,
      "hasPreviousPage": false,
      "lastCursor": 30373
    },
    "total": 277
  }
}
```

**SDK Code**

```python Documents_advancedSearchDocuments_example
import requests

url = "https://api.staple.io/v2/search/documents"

payload = {
    "filter": {
        "fileName": "invoice",
        "queue": [1, 4],
        "tab": ["RECEIVED", "COMPLETED"],
        "others": {
            "docType": "INVOICE",
            "fields": [
                {
                    "name": "InvoiceNumber",
                    "value": "10"
                },
                {
                    "name": "PONumber",
                    "value": "90"
                }
            ]
        },
        "content": "invoice",
        "uploadedBy": [1, 100],
        "completedBy": [1],
        "rejectedBy": [1],
        "exportedBy": [1],
        "uploadedAt": {
            "from": "01/04/2023",
            "to": "20/04/2023"
        },
        "completedAt": {
            "from": "01/04/2023",
            "to": "20/04/2023"
        },
        "rejectedAt": {
            "from": "01/04/2023",
            "to": "20/04/2023"
        },
        "exportedAt": {
            "from": "01/04/2023",
            "to": "20/04/2023"
        }
    },
    "pagination": {
        "skip": 0,
        "take": 100
    }
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Documents_advancedSearchDocuments_example
const url = 'https://api.staple.io/v2/search/documents';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"filter":{"fileName":"invoice","queue":[1,4],"tab":["RECEIVED","COMPLETED"],"others":{"docType":"INVOICE","fields":[{"name":"InvoiceNumber","value":"10"},{"name":"PONumber","value":"90"}]},"content":"invoice","uploadedBy":[1,100],"completedBy":[1],"rejectedBy":[1],"exportedBy":[1],"uploadedAt":{"from":"01/04/2023","to":"20/04/2023"},"completedAt":{"from":"01/04/2023","to":"20/04/2023"},"rejectedAt":{"from":"01/04/2023","to":"20/04/2023"},"exportedAt":{"from":"01/04/2023","to":"20/04/2023"}},"pagination":{"skip":0,"take":100}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Documents_advancedSearchDocuments_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/search/documents"

	payload := strings.NewReader("{\n  \"filter\": {\n    \"fileName\": \"invoice\",\n    \"queue\": [\n      1,\n      4\n    ],\n    \"tab\": [\n      \"RECEIVED\",\n      \"COMPLETED\"\n    ],\n    \"others\": {\n      \"docType\": \"INVOICE\",\n      \"fields\": [\n        {\n          \"name\": \"InvoiceNumber\",\n          \"value\": \"10\"\n        },\n        {\n          \"name\": \"PONumber\",\n          \"value\": \"90\"\n        }\n      ]\n    },\n    \"content\": \"invoice\",\n    \"uploadedBy\": [\n      1,\n      100\n    ],\n    \"completedBy\": [\n      1\n    ],\n    \"rejectedBy\": [\n      1\n    ],\n    \"exportedBy\": [\n      1\n    ],\n    \"uploadedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"completedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"rejectedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"exportedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    }\n  },\n  \"pagination\": {\n    \"skip\": 0,\n    \"take\": 100\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Documents_advancedSearchDocuments_example
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/search/documents")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"filter\": {\n    \"fileName\": \"invoice\",\n    \"queue\": [\n      1,\n      4\n    ],\n    \"tab\": [\n      \"RECEIVED\",\n      \"COMPLETED\"\n    ],\n    \"others\": {\n      \"docType\": \"INVOICE\",\n      \"fields\": [\n        {\n          \"name\": \"InvoiceNumber\",\n          \"value\": \"10\"\n        },\n        {\n          \"name\": \"PONumber\",\n          \"value\": \"90\"\n        }\n      ]\n    },\n    \"content\": \"invoice\",\n    \"uploadedBy\": [\n      1,\n      100\n    ],\n    \"completedBy\": [\n      1\n    ],\n    \"rejectedBy\": [\n      1\n    ],\n    \"exportedBy\": [\n      1\n    ],\n    \"uploadedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"completedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"rejectedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"exportedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    }\n  },\n  \"pagination\": {\n    \"skip\": 0,\n    \"take\": 100\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Documents_advancedSearchDocuments_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/search/documents")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"filter\": {\n    \"fileName\": \"invoice\",\n    \"queue\": [\n      1,\n      4\n    ],\n    \"tab\": [\n      \"RECEIVED\",\n      \"COMPLETED\"\n    ],\n    \"others\": {\n      \"docType\": \"INVOICE\",\n      \"fields\": [\n        {\n          \"name\": \"InvoiceNumber\",\n          \"value\": \"10\"\n        },\n        {\n          \"name\": \"PONumber\",\n          \"value\": \"90\"\n        }\n      ]\n    },\n    \"content\": \"invoice\",\n    \"uploadedBy\": [\n      1,\n      100\n    ],\n    \"completedBy\": [\n      1\n    ],\n    \"rejectedBy\": [\n      1\n    ],\n    \"exportedBy\": [\n      1\n    ],\n    \"uploadedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"completedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"rejectedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"exportedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    }\n  },\n  \"pagination\": {\n    \"skip\": 0,\n    \"take\": 100\n  }\n}")
  .asString();
```

```php Documents_advancedSearchDocuments_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/search/documents', [
  'body' => '{
  "filter": {
    "fileName": "invoice",
    "queue": [
      1,
      4
    ],
    "tab": [
      "RECEIVED",
      "COMPLETED"
    ],
    "others": {
      "docType": "INVOICE",
      "fields": [
        {
          "name": "InvoiceNumber",
          "value": "10"
        },
        {
          "name": "PONumber",
          "value": "90"
        }
      ]
    },
    "content": "invoice",
    "uploadedBy": [
      1,
      100
    ],
    "completedBy": [
      1
    ],
    "rejectedBy": [
      1
    ],
    "exportedBy": [
      1
    ],
    "uploadedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    },
    "completedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    },
    "rejectedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    },
    "exportedAt": {
      "from": "01/04/2023",
      "to": "20/04/2023"
    }
  },
  "pagination": {
    "skip": 0,
    "take": 100
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Documents_advancedSearchDocuments_example
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/search/documents");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"filter\": {\n    \"fileName\": \"invoice\",\n    \"queue\": [\n      1,\n      4\n    ],\n    \"tab\": [\n      \"RECEIVED\",\n      \"COMPLETED\"\n    ],\n    \"others\": {\n      \"docType\": \"INVOICE\",\n      \"fields\": [\n        {\n          \"name\": \"InvoiceNumber\",\n          \"value\": \"10\"\n        },\n        {\n          \"name\": \"PONumber\",\n          \"value\": \"90\"\n        }\n      ]\n    },\n    \"content\": \"invoice\",\n    \"uploadedBy\": [\n      1,\n      100\n    ],\n    \"completedBy\": [\n      1\n    ],\n    \"rejectedBy\": [\n      1\n    ],\n    \"exportedBy\": [\n      1\n    ],\n    \"uploadedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"completedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"rejectedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    },\n    \"exportedAt\": {\n      \"from\": \"01/04/2023\",\n      \"to\": \"20/04/2023\"\n    }\n  },\n  \"pagination\": {\n    \"skip\": 0,\n    \"take\": 100\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Documents_advancedSearchDocuments_example
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "filter": [
    "fileName": "invoice",
    "queue": [1, 4],
    "tab": ["RECEIVED", "COMPLETED"],
    "others": [
      "docType": "INVOICE",
      "fields": [
        [
          "name": "InvoiceNumber",
          "value": "10"
        ],
        [
          "name": "PONumber",
          "value": "90"
        ]
      ]
    ],
    "content": "invoice",
    "uploadedBy": [1, 100],
    "completedBy": [1],
    "rejectedBy": [1],
    "exportedBy": [1],
    "uploadedAt": [
      "from": "01/04/2023",
      "to": "20/04/2023"
    ],
    "completedAt": [
      "from": "01/04/2023",
      "to": "20/04/2023"
    ],
    "rejectedAt": [
      "from": "01/04/2023",
      "to": "20/04/2023"
    ],
    "exportedAt": [
      "from": "01/04/2023",
      "to": "20/04/2023"
    ]
  ],
  "pagination": [
    "skip": 0,
    "take": 100
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/search/documents")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```