REST API - Articles/KB

Am trying to build a migration script to transition articles from Intercom to Tawk. But my god is the API fickle and the documentation is not reliable.

My current challenge – just getting it to return an article with a GET request.

I can do a GET to https://api.tawk.to/v1/knowledge-base.article.list and get data successfully, and can clearly see a single article with ID 67347862f37baa195e506bbd.

Then I request to https://api.tawk.to/v1/knowledge-base.article.get

I have the following payload:

{
  "propertyId": "66b9b8760cca4f8a7a74cf8d",
  "articleId": "67347862f37baa195e506bbd",
  "siteId": "funnelflux",
  "categoryId": "6732213ff37baa195e505a24",
  "fields": [
    "meta"
  ]
}

Here we need categoryId (odd) else it gives a validation error.

With only “meta” as a field, this works, but it returns information about the KB not a specific article:

E.g. response of:

{
    "ok": true,
    "data": {
        "category": {
            "id": "6732213ff37baa195e505a24",
            "meta": {
                "sites": [
                    "primary"
                ],
                "icon": {
                    "type": "predefined",
                    "content": "book"
                },
                "parent": null,
                "position": 0,
                "articlesCount": 1,
                "createdAt": "2024-11-11T15:22:39.571Z",
                "updatedAt": "2024-11-19T08:11:54.501Z"
            }
        }
    }
}

But if we try to add “content” to the fields list, alongside meta or on it’s own…

{
    "ok": false,
    "error": "server_error"
}

A 500 server error. Very frustrating as there’s no particular information and everything looks correct.

If you change a single letter in the fields you get a validation error:

{
    "ok": false,
    "error": "validation_error",
    "message": "fields[0]"
}

So clearly content is correct… but I only get 500 errors, so am a bit stuck.

Also lost my email with the username/pass for the Tawk REST API docs, really bizarre and inconvenient to password protect a basic API docs page.

Update: figured this out myself.

In the KB payload I was using my site ID (funnelflux) which works fine. You can also use primary, same result.

But in the get article body, it fails if you use the actual site ID… have to use “primary” then it works.

Odd but that seemed to be the problem.