gotify API reference
Push notifications to a Gotify server (https://gotify.net), on top of the http client. Hold a value-semantic Config (server URL + application token) and call push; it POSTs the message form to URL/message with the X-Gotify-Key header, per Gotify's push-message contract. Needs the default jennifer binary (uses net via http). The URL and token belong to the caller - read them from the environment or a config file; never commit them.
Import with import "gotify.j" as gotify;. See the gotify guide for prose and examples.
Functions
gotify.push(cfg as Config, title as string, message as string, priority as int)
Send a notification to the Gotify server.
Parameters
cfg{Config}- the server URL + tokentitle{string}- the notification titlemessage{string}- the notification bodypriority{int}- the Gotify priority (higher is more urgent)
Returns {http.Response} - 2xx on success; a bad token surfaces as a 4xx value
gotify.pushExtras(cfg as Config, title as string, message as string, priority as int, extras as Extras)
Send a notification carrying extras (markdown rendering and/or a click URL). POSTs a JSON body (not the form) so the nested extras object reaches Gotify; the plain push stays form-encoded and unchanged.
Parameters
cfg{Config}- the server URL + tokentitle{string}- the notification titlemessage{string}- the notification bodypriority{int}- the Gotify priority (higher is more urgent)extras{Extras}- the extras to attach (a zero Extras adds none)
Returns {http.Response} - 2xx on success; a bad token surfaces as a 4xx value
gotify.pushMarkdown(cfg as Config, title as string, message as string, priority as int)
Send a notification whose body renders as markdown (sets the client::display content-type to text/markdown). Convenience over pushExtras with Extras{markdown: true}.
Parameters
cfg{Config}- the server URL + tokentitle{string}- the notification titlemessage{string}- the markdown notification bodypriority{int}- the Gotify priority (higher is more urgent)
Returns {http.Response} - 2xx on success; a bad token surfaces as a 4xx value
gotify.pushWith(cfg as Config, title as string, message as string, priority as int, clickUrl as string)
Send a notification that opens clickUrl when tapped (sets client::notification.click.url). Convenience over pushExtras with Extras{clickUrl: ...}.
Parameters
cfg{Config}- the server URL + tokentitle{string}- the notification titlemessage{string}- the notification bodypriority{int}- the Gotify priority (higher is more urgent)clickUrl{string}- the URL to open when the notification is tapped
Returns {http.Response} - 2xx on success; a bad token surfaces as a 4xx value
Structs
gotify.Config
A Gotify target: value-semantic, passed to each push (no module state).
| Field | Type | Description |
|---|---|---|
url | string | the server URL, no trailing slash |
token | string | the application token |
gotify.Extras
Optional Gotify message extras (value-semantic, passed to pushExtras). A zero Extras (markdown false, empty clickUrl) adds nothing, so a push with it matches the plain push. Only the requested keys reach the wire.
| Field | Type | Description |
|---|---|---|
markdown | bool | render the message body as markdown (sets the client::display content-type to text/markdown) |
clickUrl | string | URL to open when the notification is tapped (sets client::notification.click.url); "" for none |