> For the complete documentation index, see [llms.txt](https://docs.frontnow.com/advise/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frontnow.com/advise/2/data-provision/data-api.md).

# Data API

Frontnow Advisor's Data API allows you to add documents to the dataset, which can be used to train Frontnow Advisor's AI model. A document can contain a title, text, short description, preview URL, and corresponding website URL.

1. Authentication: To use the Data API, you need to authenticate with an API key. You can obtain an API key from the Frontnow Advisor dashboard.
2. API Endpoint: The API endpoint for adding documents is `https://api.frontnow.com/data/documents`.
3. Request Body: The request body for adding a document is a JSON object that contains the following fields:

## Add Document

<mark style="color:green;">`POST`</mark> `https://api.frontnow.com/data/documents.`

Adding Documents to the Dataset for Training the AI Model

#### Headers

| Name                                       | Type   | Description                              |
| ------------------------------------------ | ------ | ---------------------------------------- |
| API\_KEY<mark style="color:red;">\*</mark> | String | Frontnow API Key to access the REST API. |

#### Request Body

| Name                                    | Type   | Description                                              |
| --------------------------------------- | ------ | -------------------------------------------------------- |
| title<mark style="color:red;">\*</mark> | String | The title of the document.                               |
| metadata                                | JSON   | A JSON object containing metadata for the document.      |
| website\_url                            | String | The URL of the website that the document corresponds to. |
| preview\_url                            | String | A preview URL for the document.                          |
| description                             | String | A short description of the document.                     |
| text<mark style="color:red;">\*</mark>  | String | The unstructured text of the document.                   |

{% tabs %}
{% tab title="200: OK Successfully added document to dataset" %}

```javascript
{
    "id": "1234567890",
    "status": "success",
    "message": "Document added to the dataset"
}
```

{% endtab %}
{% endtabs %}

Here's an example request body:

```json
{
    "title": "How to Use Frontnow Advisor",
    "text": "Frontnow Advisor is a powerful tool for answering customer questions. To use it...",
    "description": "Learn how to use Frontnow Advisor",
    "preview_url": "https://example.com/preview",
    "website_url": "https://example.com",
    "metadata": {
        "author": "John Doe",
        "category": "Productivity"
    }
}
```

4. Response Body: The response body for adding a document is a JSON object that contains the following fields:

* `status`: The status of the request. Possible values are `success` and `failure`.
* `message`: A message indicating whether the request was successful or not.

5. Training the AI Model: Once the document has been added to the dataset, it can be used to train Frontnow Advisor's AI model. The more documents added to the dataset, the better the AI model will be at generating relevant and accurate answers to customer questions.

By using the Data API to add documents to the dataset for training the Frontnow Advisor's AI model, you can provide the best possible answers to customer questions that are tailored to your brand, products, or services. If you have any questions or need assistance, please don't hesitate to contact us.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.frontnow.com/advise/2/data-provision/data-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
