> For the complete documentation index, see [llms.txt](https://docs.invariant.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.invariant.io/content-insight/api.md).

# Management API

The Content Insight Management API can be used to add, update, delete and search documents within the Index Store

## REST Services for managing document indexes

## Insert Document

<mark style="color:orange;">`PUT`</mark> `https://api.invariant.io/v1/document/index`

This endpoint inserts a document and returns Document ID on successful insert.

#### Path Parameters

| Name | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ---- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id   | string | Unique ID of document to be uploaded                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| file | object | type = file; /path/to/file/to/be/uploaded                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| raw  | string | JSON metadata as name value pair,  e.g.`{"id": "RAW-C00003", "documenttitle": "This is first title C", "dln": "DD1", "tax_year": "2019", "cust_type": "TP_TYPE_1", "classified_cd": "CLASS_CD_1", "conf_code": "CONF_CD_1", "mimetype": "application/json", "form_type_cd": "FORM_TYPE_CD_1", "ica_id": "CAPTURE_1", "notice_id": "NOTICE_1", "scan_id": "SCAN_PAGE_1", "scan_date": "2017-02-19", "effective_date": "2017-02-20", "expiration_date": "2021-02-19", "last_updated_date": "2018-12-10", "candelete": "Y", "document_class": "DOC_CLASS_1" }` |

#### Query Parameters

| Name      | Type   | Description                               |
| --------- | ------ | ----------------------------------------- |
| mediaType | string | The results to be returned as XML or JSON |

#### Headers

| Name           | Type   | Description                                                         |
| -------------- | ------ | ------------------------------------------------------------------- |
| authentication | string | Authentication token to track down who wants to view the documents. |

{% tabs %}
{% tab title="200 Document successfully retrieved." %}

```javascript
{ 
    "result": "success", 
    "message": "index complete", 
    "filename": "mqdecode.pdf", 
    "_id": "6790"
}

```

{% endtab %}

{% tab title="503 Elasticsearch service not available" %}

```javascript
{
    "_id": null,
    "filename": "somefile.pdf",
    "result": "fail",
    "message": "Connection refused: no further information"
}
```

{% endtab %}
{% endtabs %}

## Update document

<mark style="color:green;">`POST`</mark> `https://api.invariant.io/v1/document/update`

This endpoint updates the document

#### Path Parameters

| Name | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ---- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id   | string | ID of the document to be updated                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| file | object | <p>type = file<br>/path/to/file/that/is/updated/</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| raw  | string | <p>JSON metadata as name value pair e.g.<br><code>{ "id": "RAW-C00004", "doctitle": "This is first title C Updated", "dln": "DD3", "tax\_year": "2033", "tp\_type": "TP\_TYPE\_3",  "conf\_code": "CONF\_CD\_3", "mimetype": "application/json", "form\_type": "FORM\_3", "ica\_id": "CAPTURE\_3",  "scan\_id": "SCAN\_PAGE\_3", "scan\_date": "2017-02-13", "effective\_date": "2017-02-23", "expiration\_date": "2021-02-13", "last\_updated\_date": "2018-12-13", "candelete": "N", "document\_class": "DOC\_CLASS\_3" }</code></p> |

#### Query Parameters

| Name      | Type   | Description                              |
| --------- | ------ | ---------------------------------------- |
| mediaType | string | The result to be returned as XML or JSON |

#### Headers

| Name           | Type   | Description                               |
| -------------- | ------ | ----------------------------------------- |
| authentication | string | Authentication token to update a document |

{% tabs %}
{% tab title="200 " %}

```
{
    "result": "success",
    "message": "updated",
    "filename": "UpdatedFile.pdf",
    "_id": "C-1000020"
}
```

{% endtab %}
{% endtabs %}

## Delete Document by ID

<mark style="color:red;">`DELETE`</mark> `https://api.invariant.io/v1/document/:id`

This endpoint deletes document

#### Path Parameters

| Name | Type   | Description                  |
| ---- | ------ | ---------------------------- |
| id   | string | ID of the document to delete |

#### Query Parameters

| Name      | Type   | Description                              |
| --------- | ------ | ---------------------------------------- |
| mediaType | string | The result to be returned as XML or JSON |

#### Headers

| Name           | Type   | Description                                 |
| -------------- | ------ | ------------------------------------------- |
| authentication | string | Authentication token to delete the document |

{% tabs %}
{% tab title="200 " %}

```
{
    "found": true,
    "result": "deleted",
    "_id": "C-1000037"
}
```

{% endtab %}
{% endtabs %}

## Search By ID

<mark style="color:blue;">`GET`</mark> `https://api.invariant.io/v1/search/:id`

This endpoint returns a document by ID.

#### Path Parameters

| Name | Type   | Description                   |
| ---- | ------ | ----------------------------- |
| id   | string | ID of the document to locate. |

#### Query Parameters

| Name      | Type   | Description                               |
| --------- | ------ | ----------------------------------------- |
| mediaType | string | The results to be returned as XML or JSON |

#### Headers

| Name           | Type   | Description                                                         |
| -------------- | ------ | ------------------------------------------------------------------- |
| authentication | string | Authentication token to track down who wants to view the documents. |

{% tabs %}
{% tab title="200 Document successfully retrieved." %}

```javascript
{
    "_id": "6790",
    "_version": "1",
    "found": "true",
    "_source": {
        "author": "Administrator",
        "title": "Microsoft PowerPoint - WSTE-WMQDataConversion1",
        "date": "1189704111000",
        "format": "application/pdf; version=1.3"
        "raw": {
            "docno": "dg78878",
            "filename": "mqdecode.pdf",
            "filesize": "413256",
            "indexing_date": "1518715553333",
            "checksum": "2d95a41b72440d86d89f4c18e5eff2c0"
        }
    }
}

```

{% endtab %}

{% tab title="404 Could not find a document matching this query." %}

```javascript
{
    "message": "Document not found."
}
```

{% endtab %}
{% endtabs %}

## Full text document search with metadata filters

<mark style="color:blue;">`GET`</mark> `https://api.invariant.io/v1/search/content`

#### Path Parameters

| Name            | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                           |
| --------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| dln             | string | <p>e.g. <strong>z89897878</strong><br>The following string types are supported as filter params - <strong>id, documenttitle, dln, tax\_year, tp\_type, classified\_cd, conf\_code, form\_type\_cd, document\_class</strong></p>                                                                                                                                                                                       |
| effective\_date | string | <p>e.g. 2010-06-30,2012-01-30 <br>The date format is yyyy-MM-DD. The first date is the start date and the second date after the comma is end date. The date are inclusive so the search would be (effective\_date >= 2010-06-30 and effective\_date <= 2012-01-30)<br>The following elements can be used in date range query - <strong>effective\_date, last\_update\_date, expiration\_date, scan\_date</strong></p> |
| search\_text    | string | Text to be searched in the content database                                                                                                                                                                                                                                                                                                                                                                           |

#### Query Parameters

| Name      | Type   | Description                              |
| --------- | ------ | ---------------------------------------- |
| mediaType | string | The result to be returned as XML or JSON |

#### Headers

| Name           | Type   | Description                                                             |
| -------------- | ------ | ----------------------------------------------------------------------- |
| authentication | string | The authentication token to track down who wants the view the documents |

{% tabs %}
{% tab title="200 " %}

```
{
    "_id": "6790",
    "_version": "1",
    "found": "true",
    "_source": {
        "author": "Administrator",
        "title": "Microsoft PowerPoint - WSTE-WMQDataConversion1",
        "date": "1189704111000",
        "format": "application/pdf; version=1.3"
        "raw": {
            "docno": "dg78878",
            "filename": "mqdecode.pdf",
            "filesize": "413256",
            "indexing_date": "1518715553333",
            "checksum": "2d95a41b72440d86d89f4c18e5eff2c0"
        }
    }
}
```

{% endtab %}

{% tab title="404 " %}

```
{
    "message": "Document not found."
}
```

{% endtab %}
{% endtabs %}
