1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
|
# Gotify
Shoutrrr integrates with Gotify to enable sending notifications from command-line tools, scripts, or applications.
Gotify is a self-hosted notification service that allows you to send push notifications to your devices. It provides a simple REST API for sending messages and supports various features like priorities, custom titles, and additional metadata through extras.
For more information about Gotify, visit the [official Gotify documentation](https://gotify.net/docs/).
## URL Format
--8<-- "docs/services/push/gotify/config.md"
## API Endpoint
Shoutrrr sends notifications to Gotify using the REST API endpoint `POST /message`.
The request includes the notification data as JSON in the request body and uses either URL query parameters or HTTP headers for authentication.
## Configuration Parameters
### Token Requirements
!!! Note
Tokens are generated within the Gotify web interface when creating applications.
The Gotify application token must be exactly 15 characters long and must start with the letter 'A'.
It can contain uppercase and lowercase letters, numbers, and the special characters '.', '-', and '_'.
!!! Warning "Token Validation"
Invalid tokens will result in notification delivery failures. Always verify your token format matches Gotify's requirements.
### Extras Field Support
The `extras` parameter allows you to include additional metadata in the notification payload sent to Gotify. This is passed as a JSON object and can be used for features like actions, images, or custom data that Gotify supports.
!!! Example "With extras for actions"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&extras=%7B%22action%22%3A%22view%22%2C%22url%22%3A%22https%3A%2F%2Fexample.com%22%7D
```
This sends a notification with an action button that opens `https://example.com` when clicked.
!!! Example "With extras for images"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&extras=%7B%22image%22%3A%22https%3A%2F%2Fexample.com%2Fimage.png%22%7D
```
This includes an image URL in the notification.
### Disable TLS
The `disabletls` parameter can be set to `yes` to disable TLS entirely, forcing the use of HTTP instead of HTTPS. This is useful for:
- Self-signed certificates in development environments
- Internal Gotify servers with custom CA certificates
- Testing with local Gotify instances
!!! danger "Security Risk"
Disabling TLS makes all communication unencrypted and vulnerable to interception. Only use this option in trusted, isolated networks.
### Skip TLS Certificate Verification
The `insecureskipverify` parameter can be set to `yes` to skip TLS certificate verification while still using HTTPS. This maintains encrypted communication but bypasses certificate validation. This is useful for:
- Self-signed certificates in development environments
- Internal Gotify servers with custom CA certificates
- Testing with certificates that don't match the hostname
!!! danger "Security Risk"
Skipping certificate verification makes connections vulnerable to man-in-the-middle attacks. Only use this option when you trust the network path to the server.
### Priority Levels
Gotify supports priority levels to control how notifications are displayed and handled:
- **-2**: Very low priority (may be hidden in some clients)
- **-1**: Low priority
- **0**: Normal priority (default)
- **1**: High priority
- **2 to 10**: Very high priority (may trigger special handling like persistent notifications)
Higher priority notifications typically appear more prominently and may bypass quiet hours or notification filters. The priority can be set to a value between -2 and 10, where -2 is the lowest priority and 10 is the highest. Negative values have special meanings in some clients.
### Custom Title
The `title` parameter allows you to set a custom title for your notification. If not specified, Shoutrrr uses the default title "Shoutrrr notification". Titles should be concise and descriptive to help users quickly identify the notification's purpose.
### Custom Date
The `date` parameter allows you to set a custom timestamp for the notification. Shoutrrr accepts multiple common date formats and automatically converts them to ISO 8601 format for the Gotify API. If not specified, Gotify will use the current server time when the notification is received.
#### Supported Input Formats
The date parameter accepts the following formats:
- **ISO 8601 with timezone** (RFC3339): `2023-12-25T10:00:00Z` or `2023-12-25T10:00:00+05:00`
- **ISO 8601 without timezone**: `2023-12-25T10:00:00` (assumes UTC)
- **Unix timestamp** (seconds since epoch): `1703498400`
- **Basic date-time**: `2023-12-25 10:00:00` (assumes UTC)
All formats are converted to ISO 8601 format before sending to Gotify.
#### Validation Behavior
If an invalid date format is provided, Shoutrrr will log a warning and skip setting the custom date, falling back to Gotify's default server timestamp. This ensures notifications are still delivered even with date parsing errors.
#### Use Cases
This parameter is useful for:
- Backdating notifications for historical events
- Ensuring consistent timestamps across multiple notifications
- Testing notification ordering in development
- Scheduling notifications with specific timestamps
!!! Example "ISO 8601 with timezone"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&date=2023-12-25T10:00:00Z
```
Sets the notification timestamp to Christmas morning 2023 UTC.
!!! Example "ISO 8601 without timezone"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&date=2023-12-25T10:00:00
```
Sets the notification timestamp to Christmas morning 2023, interpreted as UTC.
!!! Example "Unix timestamp"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&date=1703498400
```
Sets the notification timestamp to Christmas morning 2023 (Unix timestamp for 2023-12-25 10:00:00 UTC).
!!! Example "Basic date-time format"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&date=2023-12-25%2010:00:00
```
Sets the notification timestamp to Christmas morning 2023, interpreted as UTC.
### Use Header Authentication
By default, the Gotify token is sent as a query parameter in the URL (`?token=...`). The `useheader` parameter set to `yes` removes the token from the URL entirely and sends it in the `X-Gotify-Key` HTTP header instead, which provides better security since:
- Headers are less likely to be logged in server access logs
- Query parameters may appear in browser history or be exposed in URLs
- Headers are encrypted in HTTPS requests
!!! Example "Using header authentication"
```uri
gotify://gotify.example.com/message?useheader=yes
```
This sends the token in the `X-Gotify-Key` header, with no token appearing in the URL.
## Input Validation
Shoutrrr validates input parameters before sending notifications to Gotify to ensure data integrity and prevent common errors.
### Message Requirements
Messages must contain at least one character. Empty messages are not allowed.
!!! Failure "Validation Failure Example"
```bash
shoutrrr send --url "gotify://example.com/message?token=token" --message ""
```
**Error**: `message cannot be empty`
### Priority Ranges
Priority values must be integers between -2 and 10 inclusive. Values outside this range will be rejected.
!!! Failure "Validation Failure Example"
```bash
shoutrrr send --url "gotify://example.com/message?token=token&priority=15" --message "test"
```
**Error**: `priority must be between -2 and 10`
### Date Format Handling
Shoutrrr supports multiple date input formats, automatically converting them to ISO 8601 for the Gotify API. Invalid date formats are logged as warnings, and the notification uses Gotify's server timestamp instead.
!!! Failure "Validation Failure Example"
```bash
shoutrrr send --url "gotify://example.com/message?token=token&date=invalid-date" --message "test"
```
**Warning logged**: `invalid date format`
**Result**: Notification sent with server timestamp
Supported formats include:
- ISO 8601 with timezone: `2023-12-25T10:00:00Z`
- ISO 8601 without timezone: `2023-12-25T10:00:00`
- Unix timestamp: `1703498400`
- Basic date-time: `2023-12-25 10:00:00`
## Examples
!!! Example "Common usage"
```uri
gotify://gotify.example.com:443/message?token=AzyoeNS.D4iJLVa&title=Great+News&priority=1
```
!!! Example "With subpath"
```uri
gotify://example.com:443/path/to/gotify/message?token=AzyoeNS.D4iJLVa&title=Great+News&priority=1
```
!!! Example "With all parameters"
```uri
gotify://gotify.example.com/message?title=System+Alert&priority=5&disabletls=yes&useheader=yes&date=2023-12-25T10%3A00%3A00Z&extras=%7B%22action%22%3A%22view%22%2C%22url%22%3A%22https%3A%2F%2Fexample.com%2Falert%22%2C%22image%22%3A%22https%3A%2F%2Fexample.com%2Falert.png%22%7D
```
!!! Example "Minimal configuration"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa
```
!!! Example "With custom title and low priority"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&title=Info&priority=-1
```
!!! Example "With custom date"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&date=2023-12-25T10%3A00%3A00Z&title=Scheduled+Event
```
!!! Example "With Unix timestamp date"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&date=1703498400&title=Timestamp+Event
```
!!! Example "With basic date-time format"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&date=2023-12-25%2010%3A00%3A00&title=Simple+Date+Event
```
!!! Example "With TLS disabled for self-signed certificates"
```uri
gotify://gotify.example.com:8080/message?token=AzyoeNS.D4iJLVa&disabletls=yes
```
!!! Example "With TLS certificate verification skipped"
```uri
gotify://gotify.example.com/message?token=AzyoeNS.D4iJLVa&insecureskipverify=yes
```
## Security Considerations
### Authentication Security
- **Use header authentication** (`useheader=yes`) whenever possible to avoid exposing tokens in URLs
- Store URLs containing tokens securely and avoid sharing them in logs or version control
- Rotate tokens regularly through the Gotify web interface
### Network Security
- Always use HTTPS (default) for production deployments
- Only disable TLS (`disabletls=yes`) or skip certificate verification (`insecureskipverify=yes`) in trusted development environments
- Consider using Gotify behind a reverse proxy with additional authentication layers
### Token Management
- Tokens are application-specific in Gotify
- Each application can have its own token with specific permissions
- Delete unused applications and tokens immediately
## Troubleshooting
### Common Issues
#### Connection Failed
**Error**: `failed to send notification to Gotify`
**Possible causes:**
- Invalid or unreachable server URL
- Network connectivity issues
- Firewall blocking outbound connections
**Solutions:**
- Verify the Gotify server is running and accessible
- Check network connectivity and firewall rules
- Ensure the correct host and port are specified
#### Authentication Failed
**Error**: `invalid gotify token`
**Possible causes:**
- Incorrect token format (must be 15 chars starting with 'A')
- Token has been revoked or expired
- Wrong token for the application
**Solutions:**
- Verify token format: exactly 15 characters, starts with 'A'
- Regenerate token in Gotify web interface
- Ensure you're using the correct application token
#### TLS Certificate Issues
**Error**: TLS certificate verification failed
**Solutions:**
- For self-signed certificates, use `insecureskipverify=yes` to skip verification while maintaining HTTPS
- For development/testing with HTTP, use `disabletls=yes` to disable TLS entirely
- Install proper certificates on the Gotify server
- Verify the certificate is valid and not expired
#### Validation Errors
##### Empty Messages
**Error**: `message cannot be empty`
**Possible causes:**
- No message provided in the request
- Message parameter is an empty string
**Solutions:**
- Always include a non-empty message in your notification
- Check that your message parameter is properly set
##### Invalid Priorities
**Error**: `priority must be between -2 and 10`
**Possible causes:**
- Priority value is less than -2 or greater than 10
- Priority parameter contains non-numeric characters
**Solutions:**
- Use integer values between -2 and 10
- Verify the priority parameter is a valid number
##### Malformed Extras JSON
**Error**: `failed to unmarshal extras JSON` or `failed to parse extras JSON from URL query`
**Possible causes:**
- Invalid JSON syntax in the extras parameter
- Improper URL encoding of the JSON string
- Missing quotes or brackets in JSON structure
**Solutions:**
- Validate JSON syntax using a JSON validator
- Ensure proper URL encoding when passing JSON in URLs
- Test extras JSON separately before including in URLs
##### Invalid Date Formats
**Error**: `invalid date format` (logged as warning)
**Possible causes:**
- Date format not matching supported formats
- Invalid date values (e.g., February 30th)
- Incorrect timezone specifications
**Solutions:**
- Use one of the supported date formats listed above
- Verify date values are valid calendar dates
- Note that invalid dates still send notifications but use server timestamps
#### Error Handling Patterns
Shoutrrr employs several error handling strategies for malformed inputs:
- **Early Validation**: Parameters are validated before API requests to fail fast
- **Graceful Degradation**: Non-critical validation failures (like invalid dates) allow notifications to proceed with defaults
- **Detailed Error Messages**: Specific error messages help identify the exact validation issue
- **Fallback Behavior**: When possible, invalid inputs fall back to sensible defaults rather than failing completely
### Testing Your Configuration
You can test your Gotify configuration using the Shoutrrr CLI:
```bash
shoutrrr verify --url "gotify://your-server/message?token=token"
```
This validates the URL format and service configuration. To send a test notification, use:
```bash
shoutrrr send --url "gotify://your-server/message?token=token" --message "Test notification"
```
### Gotify Server Logs
Check the Gotify server logs for additional error details. Common log locations:
- Docker: `docker logs gotify_container`
- Systemd: `journalctl -u gotify`
- Binary: Check the log file specified in your Gotify configuration
### Getting Help
- Check the [Gotify documentation](https://gotify.net/docs/) for server setup and configuration
- Report issues on the [Shoutrrr GitHub repository](https://github.com/nicholas-fedor/shoutrrr)
|