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

FieldTypeRequiredDescription
api_keystringYesYour Mendable API key

Resetting the Conversation

To reset a conversation, you should create a new conversation id using the newConversation endpoint. This will reset the conversation and return a new conversation id. Also, make sure to not pass a history to the chat endpoint after resetting it that way the AI won't use previous messages to respond to the user.

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.
Previous
Managing Data