> For the complete documentation index, see [llms.txt](https://uci.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://uci.sunbird.org/use/developer/api-documentation/history-apis.md).

# History APIs

## 1. Overview

UCI provides APIs to fetch the conversation history against a bot or a user.

## **2. APIs**

### **2.1. User History**

Use below API to fetch the history against a bot. \*\*\*\* This API uses below required parameters to fetch the user history.

* **userId**: Phone number of user
* **provider**: Conversation provider. **Eg**. gupshup
* **start & end date**: Conversations between start & end date.

```
curl --location --request GET 'http://INBOUND:PORT/xmsg/history?userId=75********&provider=gupshup&endDate=03-07-2022&startDate=01-07-2022'
```

**Limitation:** This API can provide maximum 1000 conversations.

### **2.2. Bot History**

Use below API to fetch the history against a user. This API uses below required parameters to fetch the user history.

* **botId**: Conversation id
* **provider**: Conversation provider. **Eg**. gupshup
* **start & end date**: Conversations between start & end date.

```
curl --location --request GET 'http://INBOUND:PORT/xmsg/history/dump?provider=gupshup&botId=d655cf03-1f6f-4510-acf6-d3f51b488a5e&endDate=19-07-2022&startDate=05-07-2022'
```

**Limitation:** This API can provide conversations for 15 days only.

### **2.3. Bot + User History**

Use below API to fetch the history against a user for a specific bot. This API uses below required parameters to fetch the history.

* **botId**: Conversation id
* **userId**: Phone number of user
* **provider**: Conversation provider. **Eg**. pwa
* **start & end date**: Conversations between start & end date.

```
curl --location 'http://INBOUND:PORT/xmsg/conversation-history?provider=pwa&endDate=22-06-2023&startDate=15-06-2023&userId=PhoneNo&botId=BOTID'
```

**Limitation:** This API can provide maximum 1000 conversations.

These APIs will give the response in below format.

```
{
    "timestamp": "2022-07-20T09:24:06Z",
    "status": 200,
    "error": null,
    "message": null,
    "path": "/xmsg/history",
    "result": {
        "total": 1,
        "records": [
            {
                "readTimestamp": "2022-08-16T12:37:17.884",
                "messageState": "READ",
                "sentTimestamp": "2022-08-16T12:37:10",
                "channel": "WhatsApp",
                "messageId": "4707198624577024267-422975385292909743",
                "sessionId": "e4f96af4-d714-4d41-bde6-d8cf6280b7d3",
                "ownerId": "b45g6af4-v714-2341-bd89-d8cf6280b76t",
                "fromId": "75********",
                "userId": "admin",
                "provider": "gupshup",
                "botUuid": "09a370f3-712c-4be6-b6aa-6c57957fb670",
                "payload": {
                    "text": "What is your name?"
                },
                "deliveryTimestamp": "2022-08-16T12:37:13.675",
                "ownerOrgId": "ORG_001",
                "id": "2a261c40-1d60-11ed-9003-6d8d3766cc00"
            }
        ]
    }
}
```

### **2.4. Flow Diagram**

Below is the flow diagram of how the history API works.

![Flow Diagram](https://1242145269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnC2042spZ2TIbqdRA37S%2Fuploads%2Fgit-blob-95f98254e6e52e554f27ec876fe9fe54741ce441%2Fconversation_history.png?alt=media)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://uci.sunbird.org/use/developer/api-documentation/history-apis.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
