Create ticket using an API

Good day!

We are just starting to use LibreNMS and i know very little about APIs. Is there a way to use an API to create a ticket once an alert is triggered?

I know the API URL and options:

http://YourServerName:81/api.aspx?Action=AddTicket&Key=123456789&Subject=Example&Description=Example

but where do I put this in the alerts setup? Is there some code from LibreNMS that i can put wire in a subject and description?

thanks!

You could consider creating tickets from an email otherwise,

For API transport, it should support the same format in the URL as the alert templates use https://docs.librenms.org/Alerting/Transports/
https://docs.librenms.org/Alerting/Templates/

I imagine it could look something like

http://yourservername:81/api.aspx?Action=AddTicke&Key=123456789&Subject={{$alert->title}}&Description={{$alert->description}}

Thank you for getting back to me.

I am playing with LibreNMS to our tst ticket system. The test ticket system does not have email attached to it.

thanks for the Subject={{$alert->title}}&Description={{$alert->description}}, just one quick question, where does the title and description come from?

I am guessing the API does not like Subject={{$alert->;title}}, because the subject of the ticket is {{$alert->;title}}

Should the system put in the template title or is that not supported via the API?

Ahh the api transport is still using the old template syntax see here for work in progress to switch to current format https://github.com/librenms/librenms/pull/10070 , looks like it’s close to working so you might be better to wait.

If you need it right now, then it looks like you will need to go back in time and use old template syntax https://github.com/librenms/librenms/blob/7946f15b445c430eff2f4659a556a4c8c29267fd/doc/Alerting/Templates.md

Thank you for all your help!!!

switching it to Subject=%title worked.

however, Description=%description did not.

But at least we can now create a ticket and the ticket shows the device that is down and it time stamped from the API.

Great :slight_smile:

and that’s the description of device which might not be set. Not description of alert. You’ll have to go through the template doc to see what you want to get out of it