Threads

Get threads

1GET https://api.markprompt.com/threads

Retrieves threads in the given time range.

Request body

KeyTypeDescription
fromstringThe start of the range, as an ISO 8601 string.
tostringThe end of the range, as an ISO 8601 string.
limitnumberThe maximum number of results to return. Default: 50.
pagenumberThe page index. Default: 0.
expandstringIf set to data.messages, expand the thread object to include associated messages.

Example request

1curl "https://api.markprompt.com/threads?from=2024-04-01T22%3A00%3A00&to=2024-04-15T22%3A00%3A00&limit=3&page=1" \
2  -X GET \
3  -H "Authorization: Bearer <TOKEN>" \
4  -H "Content-type: application/json" \
5  -H "Accept: application/json" \
6  -H "X-Markprompt-API-Version: 2024-03-23"

Response

The response is of the form:

1{
2  "object": "list",
3  "data": [
4    {
5      "id": "id-1",
6      "createdAt": "2023-08-07T22:36:37.728248+00:00",
7      "metadata": {
8        "sessionId": "sessions-id-1"
9      }
10    },
11    {
12      "id": "id-2",
13      "createdAt": "2023-08-07T22:40:04.527411+00:00",
14      "metadata": null
15    }
16  ]
17}

Expanded threads

When adding expand=data.messages to the request body, threads are returned together with associated messages.

1curl "https://api.markprompt.com/threads?from=2024-04-01T22%3A00%3A00&to=2024-04-02T22%3A00%3A00&limit=3&page=1&expand=data.messages" \
2  -X GET \
3  -H "Authorization: Bearer <TOKEN>" \
4  -H "Content-type: application/json" \
5  -H "Accept: application/json" \
6  -H "X-Markprompt-API-Version: 2024-03-23"

The response looks like this:

1{
2  "object": "list",
3  "data": [
4    {
5      "id": "id-1",
6      "createdAt": "2023-08-07T22:36:37.728248+00:00",
7      "metadata": {
8        "sessionId": "sessions-id-1"
9      },
10      "messages": [
11        {
12          "id": "message-id-1",
13          "createdAt": "2024-04-01T22:36:37.728248+00:00",
14          "role": "user",
15          "role": "what is markprompt in three words?",
16          "urgency": 1,
17          "sentiment": 0
18        },
19        {
20          "id": "message-id-2",
21          "createdAt": "2024-04-01T22:36:41.728248+00:00",
22          "response": "AI, support, API",
23          "csat": "4",
24          "systemPrompt": "You are kind AI who loves to help people!",
25          "config": {
26            // ...
27          },
28          "references": [
29            // ...
30          ]
31        }
32      ]
33    }
34    // ...
35  ]
36}

Thread messages

1GET https://api.markprompt.com/threads/{thread_id}/messages

Retrieves messages within a thread.

Example request

1curl "https://api.markprompt.com/threads/thread_123/messages" \
2  -X GET \
3  -H "Authorization: Bearer <TOKEN>" \
4  -H "Content-type: application/json" \
5  -H "Accept: application/json" \
6  -H "X-Markprompt-API-Version: 2024-03-23"

Response

The response is of the form:

1{
2  "object": "list",
3  "data": [
4    {
5      "id": "message-id-1",
6      "createdAt": "2024-04-01T22:36:37.728248+00:00",
7      "role": "user",
8      "role": "what is markprompt in three words?",
9      "urgency": 1,
10      "sentiment": 0
11    },
12    {
13      "id": "message-id-2",
14      "createdAt": "2024-04-01T22:36:41.728248+00:00",
15      "response": "AI, support, API",
16      "csat": "4",
17      "systemPrompt": "You are kind AI who loves to help people!",
18      "config": {
19        // ...
20      },
21      "references": [
22        // ...
23      ]
24    }
25  ]
26}

Update a thread

1POST https://api.markprompt.com/threads/{thread_id}

Updates a thread.

Request body

KeyTypeDescription
csat1 | 2 | 3 | 4 | 5 | 0A CSAT score. Set to 0 to clear value.
metadataobjectA metadata object.
strategymerge | overwriteThe update strategy. If set to `merge`, it will merge with the existing fields. If set to `overwrite`, it will replace the existing fields. Default: `overwrite`.

Example request

1curl "https://api.markprompt.com/threads/thread_123" \
2  -X POST \
3  -H "Authorization: Bearer <TOKEN>" \
4  -H "Content-type: application/json" \
5  -H "X-Markprompt-API-Version: 2024-03-23" \
6  -d '{
7      "metadata": { "category": "payments" },
8      "csat": 3,
9      "strategy": "merge"
10    }'