# Store PDF

### Prerequisites

Requires a user auth token. See the [API Auth](/api/store-pdf.md) section for PDFs

### Storing data - API

For now Mindplug handles the storing of text data only. You can store data given the following parameters:&#x20;

1. Database name: `db`
2. A collection name: `collection`
3. A file to store: `file`
4. Optional `metadata` which is any arbitrary object for the content
5. Optional: `chunkSize`
   1. Defaults to 1024. Represents the amount of characters stored per embedding. If you give content size of 1300 characters, this will make 2 embeddings of 1k and 300 characters respectively.
6. A parameter for `type` of document.

Mindplug uses recursive chunking to chunk the string content. Thus the `chunkSize` will vary slightly across different embeddings.&#x20;

For any project or collection that does not already exist, it will be auto created for the user without any additional work.

{% code lineNumbers="true" %}

```javascript
import mindplugFile from "@/src/mindplugAPI"; // base instance

async function storePDF(data) {
    const form = new FormData();
    form.append('db', 'walmart');
    form.append('collection', 'Office Supplies');
    form.append('type', 'pdf');
    form.append('file', data.file);
    form.append('metadata', JSON.stringify(data.metadata)); // optional
    form.append('chunksize', data.chunkSize.toString()); // optional
    return mindplugFile.post('/data/store/file', form)
        .then(res => res.data).catch(err => err.response.data);
 }

const file = [stored file object];
storePDF({ file });

```

{% endcode %}

An upload id and a list of stored vector IDs are returned for later use.

### Sample Response

```json
{
    "data": {
        "success": true,
        "vectorIds": [
            "8ad610a8-9dc8-4e3c-bae4-0e10146fd43a"
        ],
        "uploadId": "ea209649-8f38-40e0-9b84-0cdb1809db6c"
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mindplug.io/api/store-pdf.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
