curl --request POST \
    --url https://api.buster.so/api/v1/chats \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <USER_JWT>' \
    --data '{
        "prompt": "What were my sales from the last 3 months",
        "project_id": "5f6b3b7b-5b0b-4b0b-8b0b-5b0b3b7b5b0b",
        "chat_id": "5f6b3b7b-5b0b-4b0b-8b0b-5b0b3b7b5b0b"
    }'
{
    "chat_id": "121192a0-0757-4ac3-842d-7c9643963257",
    "chat_title": "Total Sales in the Last 3 Months",
    "chat_description": "How much revenue did we generate in the last 3 months?",
    "data_source_id": "c9654cdf-c6d6-4ee1-a48d-676859dbde0a",
    "prompt": "What were my sales from the last 3 months",
    "messages": [
        {
            "id": "0e82cee1-a837-4b73-b152-7d54b1a75dd2",
            "chat_id": "121192a0-0757-4ac3-842d-7c9643963257",
            "role": "user",
            "message": "What were my sales from the last 3 months",
            "code": "SELECT \n    o.order_date, \n    SUM(od.quantity * od.unit_price * (1 - od.discount)) AS total_sales\nFROM \n    public.order_details AS od\nJOIN \n    public.orders AS o ON od.order_id = o.order_id\nWHERE \n    o.order_date BETWEEN (CURRENT_DATE - INTERVAL '3 months') AND CURRENT_DATE\n    AND o.deleted_at IS NULL\n    AND od.deleted_at IS NULL\nGROUP BY \n    o.order_date\nORDER BY \n    o.order_date DESC;",
            "created_at": "2024-01-08T16:26:19.855521Z"
        },
        {
            "id": "0dd5de8f-2417-44b3-a76e-709cbf9bac4f",
            "chat_id": "121192a0-0757-4ac3-842d-7c9643963257",
            "role": "assistant",
            "message": "Here are the total sales for the past 3 months.",
            "code": null,
            "created_at": "2024-01-08T16:26:39.604161Z"
        },
        {
            "id": "7edb35b8-338d-4b20-8684-1760824a0326",
            "chat_id": "121192a0-0757-4ac3-842d-7c9643963257",
            "role": "assistant",
            "message": "I calculated the total sales for each day over the past 3 months, excluding any deleted orders or order details.",
            "code": null,
            "created_at": "2024-01-08T16:26:39.604180Z"
        },
        {
            "id": "3515e812-61ae-4a6d-bd3c-338631fd4694",
            "chat_id": "121192a0-0757-4ac3-842d-7c9643963257",
            "role": "assistant",
            "message": "Don't hesitate to refine these results by using the chat below.",
            "code": null,
            "created_at": "2024-01-08T16:26:39.604208Z"
        }
    ],
    "sql": "SELECT \n    o.order_date, \n    SUM(od.quantity * od.unit_price * (1 - od.discount)) AS total_sales\nFROM \n    public.order_details AS od\nJOIN \n    public.orders AS o ON od.order_id = o.order_id\nWHERE \n    o.order_date BETWEEN (CURRENT_DATE - INTERVAL '3 months') AND CURRENT_DATE\n    AND o.deleted_at IS NULL\n    AND od.deleted_at IS NULL\nGROUP BY \n    o.order_date\nORDER BY \n    o.order_date DESC;",
    "data": [
        {
            "total_sales": 2778.655504074607,
            "order_date": "2024-01-08"
        },
        {
            "order_date": "2024-01-07",
            "total_sales": 7632.474994139373
        },
        {
            "order_date": "2024-01-06",
            "total_sales": 2027.0799754095078
        }... Truncated
    ],
    "message_id": "0e82cee1-a837-4b73-b152-7d54b1a75dd2",
    "chart_recommendations": [{
        "score": 1,
        "chart_type": "LINE_CHART",
        "encode": {
            "x": "order_date",
            "y": "total_sales"
        }
    },
    {
        "score": 0.8,
        "chart_type": "BAR_CHART",
        "encode": {
            "x": "order_date",
            "y": "total_sales"
        }
    },
    {
        "score": 0.6,
        "chart_type": "PIE_CHART",
        "encode": {
            "x": "order_date",
            "y": "total_sales"
        }
    }],
    "time_frame": "3 months",
    "column_types": {
        "total_sales": "numeric",
        "order_date": "date"
    }
}

You will pass in the user JWT access token as the bearer token if chatting as an end user.

Body Parameters

prompt
string
required

This is the question/request that the user is sending to Buster.

project_id
string
required

This is the project that the user is chatting with.

chat_id
string

If you are continuing to chat with Buster, this is the chat_id that you received from the previous chat request.