REST API not working

For months, I’ve been trying to use the REST API; however, the support hasn’t been able to assist me, and errors consistently occur. Thanks to another thread in this forum, I learned that I needed to create an empty field for the body to retrieve the propertyId. Unfortunately, that’s the only progress I’ve made. I attempted to fetch the list of chats or any other information using the REST API with Basic Auth, but it seems to be simply impossible.

I sent the following request:

curl --location ‘https://api.tawk.to/v1/ticket.list
-H “Content-Type: application/json”
-u XXXXX:
-d ‘{
“propertyId”: “YYYYYY”,
“size”: 0,
“startDate”: “2023-11-01T14:15:22Z”,
“endDate”: “2023-11-17T14:15:22Z”,
“messageCount”: 0,
“deleted”: false,
“status”: “closed”,
“tags”: [
“string”
],
“sort”: “co-new-old”,
“dateType”: “cso”
}’

I’ve tried various versions of this request, but the response remains the same:

{
“ok”: false,
“error”: “auth_error”,
“message”: “invalid_auth”
}

The only way I managed to retrieve the propertyId was with the following command:

curl --location ‘https://api.tawk.to/v1/property.list
–header ‘Content-Type: application/x-www-form-urlencoded’
–header ‘Authorization: Basic XXXXXXXX’
–data-urlencode ‘=’

What can I be doing, or what should I do, to retrieve the list of chats?

I have the same or similar problem to @Ruan. I posted the following back in September and I have been emailing Tawk staff for months but no advice so far.

I need to obtain Tawk messages but have run into a problem.

The following curl returns two of our earliest tickets, but that is all:

curl -X POST 'https://api.tawk.to/v1/ticket.list' \
-u <API_KEY>: \
-H "Content-Type: application/json" \
-d '{"propertyId": "<propertyId>"}'

When I try to send any more key-value pairs in the JSON body it just returns:
{"ok":true,"total":0,"data":[]}

Based on the documentation (https://docs.tawk.to/?shell#list-tickets-of-a-property), I had the following:

-d '{"propertyId": "<propertId>","size": 2,"startDate": "2023-01-01T00:00:00Z","endDate": "2023-05-31T23:59:59Z","deleted": false,"status": "open","sort": "co-new-old","dateType": "cso"}'

I have tried each key-value pair one at a time, and different variations of the date format, shorter date ranges, and different values for size, and I just get back: {"ok":true,"total":0,"data":[]}

I only get two early tickets returned if I only send propertyID without any other key value pairs.

Has anyone had more success at retrieving messages?

btw - https://api.tawk.to/v1/property.list returns two propertyId key-value pairs with different values. Evidently we have to use the first one.

I just started using REST API, but for me it works fine - returns all tickets. Maybe it was a bug back in November, which is fixed now.

curl -X POST ‘https://api.tawk.to/v1/ticket.list
–header ‘Content-Type: application/json’
–header ‘Authorization: Basic <API_KEY>:’
–data '{
“propertyId”: “<property_id>”
}

Thank you for your reply @eug, appreciated!

However, for me I continue to only be able to retrieve two of the oldest messages, and yet not the two most oldest messages - weird! I’ve refreshed my <API_KEY> and confirmed my <propertyId>.

I get the same result for Windows as Linux:

Windows DOS/CMD version:

curl -X POST "https://api.tawk.to/v1/ticket.list" ^
    -H "Content-Type: application/json" ^
    -H "Authorization: Basic <base64_encoded_API_key>" ^
    -d "{ \"propertyId\": \"<propertyId>\" }"

Linux version:

curl -X POST 'https://api.tawk.to/v1/ticket.list' \
    -H "Content-Type: application/json" \
    -H 'Authorization: Basic <base64_encoded_API_key>' \
    -d '{"propertyId": "<propertyId>"}'

Yes, this is strange indeed. Then only support can help, I guess.
I never met a case when request returns only part of the data.

Turns out the answer for me is to use the chat.list endpoint instead of ticket.list, as I need what I call messages (aka “chats”) not tickets. Works ok now, although our earliest messages/chats won’t return for some reason, but later and most recent ones do.

There is a limit of 50 chats per call. There is no API paging, but date ranges can be used.

Your insights are truly appreciated, thank you...!