List all Zammad API endpoints?

Using self-hosted Zammad version 6.4.1-1733490875.10c55c49

Is it possible to list all available Zammad API endpoints? Preferably with a curl call or via the rails console.

Any hint would be appreciated.

Background:
I’m looking for the endpoint to get a Knowledge Base Category title translation or in other words the title of a category within the Knowledge Base.

For example:
/api/v1/knowledge_bases/[KB_ID]/categories/[CATEG_ID]

gives back

“translation_ids”: [NUMBER],
“answers_ids”: [NUMBER],

etcetera, but no title of the category.

I suppose I have to access “assets” “KnowledgeBaseCategoryTranslation” with the translation_id but I cannot find the corresponding API endpoint to do that.

Haven’t tested this properly but from testing other undocumented API stuff this might work, check the network call for the full API GET Header in your browser

This example is from opening a KB article while logged in to Zammad
image

So perhaps… navigate a bit here and there, maybe you see some correlations to categories/lists to use :slight_smile:

The init call contains the category translations

I might do something similar one day too… Luckily it is postponed for now!

Edit:
Or even worse… scrape… selenium perhaps. :skull:

Zammad: Feel free to hide my reply with a warning text if necessary.

1 Like

Thank you for taking the time to answer and post these great tips and examples. I saw a similar tip in another post but didn’t quite understand it. With your examples, I now understand where to look in the browser’s network output.

I’ve now got my source KB export working, including most of the category titles. As expected, I need to access object {KnowledgeBaseCategoryTranslation} with the translation_id of the category_id. I get that object with the API endpoint: /api/v1/knowledge_bases/[KB_ID]/answers/[ANSWER_ID]

My missing translated category titles are a result of my script’s logic: if a category doesn’t have a direct answer but a subcategory, the answer_ids array is empty and therefore skips my logic to get the translation in the answer. Since this isn’t a big problem in my specific case for five categories, I manually add the translated category titles to my export file.

If you ever need to do something similar, drop me a line and I can give you more insights into my script. That should save you time.

See below an overview of the needed API endpoint calls.

1. /api/v1/knowledge_bases/[KB_ID]

to get
- category_ids[]
- answer_ids[]

2. Loop /categories/ with category_ids[]  i.e. 479
/api/v1/knowledge_bases/[KB_ID]/categories/[CATEGORY_ID]

to get

{
  "id": 479,
  "parent_id": 476,
  "translation_ids": [
    321
  ],
  "answer_ids": [
    2706,
    ...
  ],
  "child_ids": [
    479
  ],

- translation_ids[]  
- answer_ids[]

	
3. Loop /answers/ with answer_ids[]  i.e. 2706
/api/v1/knowledge_bases/[KB_ID]/answers/[ANSWER_ID]

to get

- {
  "id": 2706,
  "assets": {
    "KnowledgeBaseAnswer": {
      "2706": {
        "id": 2706,
        "category_id": 479,
        "position": 3,
	...
        "translation_ids": [
          2705  // Use to get translated answer content, see 4.
        ],
        "attachments": [],
        "tags": []
      }
    },


-  "KnowledgeBaseCategory"[
      "translation_ids": [
          321
       ],
    ]

-  "KnowledgeBaseCategoryTranslation": {
      "321": {
        "id": 321,
        "title": "CURRENT-CATEGORY-TITLE",	// Category 479
        ...
      }

      "318": {
        "id": 318,  // Category 476 (parent_id of category 479)
        "title": "PARENT-CATEGORY-TITLE",
        ...
      }

      "317": {
        "id": 317,  // Category 475 (parent_id of category 476)
        "title": "PARENT-CATEGORY-TITLE",)
        ...
      }
   ]

 4. Get translated answer body content
/api/v1/knowledge_bases/[KB_ID]/answers/2706?include_contents=2705

- in

    "KnowledgeBaseAnswerTranslationContent": {
      "2705": {
        "id": 2705,
        "body": "<div>translated body of answer 2706 with translation_id 2705</div>",
        "attachments": []
      }
    }

Finally, an answer to my original question about all possible API endpoints. This command can give some hints (as mentioned in another article):

zammad run rails routes
3 Likes

Highly appreciated, thanks for sharing and a big thanks for making it so descriptive! This info will come in handy for later projects, when/if i find the time for it :smiley:

Didn’t know that rail command existed actually, but in the end it is often easier to just check network tab and go to a related part of the website app and see the routes there, that has helped me a lot, the same applies for most websites nowadays :slight_smile: