API
Conversation
New Conversation
The newConversation endpoint is part of the Mendable API, designed to create a new conversation and return the conversation ID.
POST /api.mendable.ai/v0/newConversation
Example Usage
Request
Here is an example request using cURL:
curl -X POST https://api.mendable.ai/v0/newConversation \
-H "Content-Type: application/json" \
-d '{
"api_key": "YOUR_API_KEY",
}'
or using Javascript:
const url = "https://api.mendable.ai/v0/newConversation";
const data = {
api_key: "YOUR_API_KEY",
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error("Error:", error));
Response
Here is an example response:
{
"conversation_id": 1234567890
}
The conversation_id is return as an integer. You can use this to start a chat.
Request Paremeters
| Field | Type | Required | Description |
|---|---|---|---|
| api_key | string | Yes | Your Mendable API key |
End Conversation (Optional)
The endConversation endpoint is part of the Mendable API, designed to end a conversation. This helps keep track of conversation time, useful for analytics.
POST /api.mendable.ai/v0/endConversation
Example Usage
Request
Here is an example request using cURL:
curl -X POST https://api.mendable.ai/v0/endConversation \
-H "Content-Type: application/json" \
-d '{
"api_key": "YOUR_API_KEY",
"conversation_id": 123,
}'
const url = "https://api.mendable.ai/v0/endConversation";
const data = {
"api_key": "YOUR_API_KEY",
"conversation_id": 123,
};
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error("Error:", error));
Response
Here is an example response:
Conversation has ended.