Aisista API Documentation

Integrate your business chatbot with any application.

Authentication

All API requests require an API key for authentication. You can generate and manage your API key from your business's 'Connect' page in the dashboard.

The API key must be included in the header of every request as follows:

api-key: YOUR_API_KEY

Base URL: https://Aisista.com/api/

GET Get Chat History

/api/?method=gethistory

This endpoint retrieves the conversation history for a specific user, identified by a unique `chat_id`.

Parameters

Parameter Type Description
method String Required. Must be 'gethistory'.
chat_id String | Integer Required. A unique identifier for your end-user (e.g., user ID from your system, session ID).

Example Request (cURL)

curl -X GET "https://Aisista.com/api/?method=gethistory&chat_id=USER12345" \
-H "api-key: YOUR_API_KEY"

Example Response

[
    {
        "user": "Hello, what are your opening hours?",
        "chatbot": "We are open from 9 AM to 5 PM on weekdays.",
        "to_follow": null,
        "time": "2024-08-15 10:30:00"
    },
    {
        "user": "Thanks!",
        "chatbot": "You're welcome! Is there anything else I can help with?",
        "to_follow": null,
        "time": "2024-08-15 10:30:15"
    }
]

POST Send New Message

/api/?method=newmessage

This endpoint sends a new message from a user to the chatbot and returns the AI-generated response.

Parameters

Parameter Type Description
method String Required. Must be 'newmessage'.
chat_id String | Integer Required. A unique identifier for your end-user. This ensures conversation continuity.
message String Required. The text of the user's message.
system_prompt String Optional. Additional, temporary instructions for the AI for this specific message. For example, you could pass user-specific data like 'The user's name is John Doe.'

Example Request (cURL)

curl -X POST "https://Aisista.com/api/" \
-H "api-key: YOUR_API_KEY" \
-d "method=newmessage" \
-d "chat_id=USER12345" \
-d "message=Do you ship to Canada?" \
-d "system_prompt=The user is currently viewing the 'Leather Watch' product page."

Example Response

{
    "ok": true,
    "response": "Yes, we ship to Canada! Shipping for the Leather Watch takes about 5-7 business days."
}

Error Handling

If a request fails, the API will return a JSON object with an `error` key containing a descriptive message.

Example Error Response

{
    "error": "Invalid API key"
}