Query zammad from cli and return data

Hello everybody,

How do I create a query from the command line (CLI) that returns, the ticket-number, ticket creation date and the last message in the ticket?

filter:
close_at:[2022-09-01 TO 2022-09-30] tags:followup

needed info:

  • ticket number
  • creation date
  • last message in ticket

Then I want to be able to add a tag to an ticket from the CLI.

Can someone provide some example commands for this?

Kind regards,

Jelle

That’s definitely not a one liner but more of a loop actually.
Due to my limited time I can only give you parts - Zammad uses ruby on rails so most things actually are very much the same as in every ruby project.

You’re looking for these models:

Ticket and Ticket::Article.
You can construct your query / clause by using Ticket.where(<condition>) and e.g. use .each to loop through that. Without articles you could also use .pluck(:number, created_at) to get the ticket number and ticket creation date in UTC.

Tag usage on CLI is a pain in the butt so sorry, not going to cover it.
Personally I think that you may be much faster with using Zammads API because you don’t require the loop to actually get the articles.

https://docs.zammad.org/en/latest/api/intro.html

1 Like

Thank you for your reply.

So I might be able to use curl command with the rest api to pull out some information… Looks like a lot of work.

If someone could give an few examples of curl commands they used with say a search query filter as the one above, then that would be appreciated.

Sorry but I’m lost. The documentation does contain the example payloads?
https://docs.zammad.org/en/latest/api/ticket/index.html

Together with
https://docs.zammad.org/en/latest/api/intro.html#authentication

and

https://docs.zammad.org/en/latest/api/intro.html#content-type

you should be able to construct such an curl command.
Maybe I’m missing something or I’m failing to understand what exactly you’re expecting / missing as information.

If you need to fiddle, tools like Postman might be a much bigger help than initial curl commands. It even allows you to export to e.g. curl commands.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.