Article
Bash API
API Bash Usage
These might also be helpful
The United Notifications API provides a simple way to send notifications using Bash and curl. This guide walks you through the process of constructing requests, understanding parameters, and interpreting responses.
To send a notification, use the following curl command:
curl -s
--form-string "client_key=[your-client-key]"
--form-string "channel=[channel-token]"
--form-string "type=INFO"
--form-string "title=My First Notification"
--form-string "body=Notification Body"
https://api.united-notifications.com/
Replace [your-client-key] and [channel-token] with your actual values before executing the command.
Here is a breakdown of the parameters you can include in your request:
client_key: Your unique API key for authentication.channel: The token identifying the notification channel.type: Specifies the type or severity of the notification. Valid values are:CRIT: Critical notifications.INFO: Informational messages.SUCCESS: Success notifications.WARN: Warning alerts.
title: A brief title summarizing the notification.body: The main message or content of the notification.
Upon success, the API returns a JSON response. Example:
{
"text": "OK",
"code": "200",
"node": "dp01",
"time": "270ms"
}
Response Fields:
text: Indicates the status of the request, e.g.,OK.code: The HTTP status code, e.g.,200for success.node: The server node that handled the request.time: The time taken to process the request in milliseconds.
If the request fails, the API provides a detailed error response. Example:
{
"text": "Unauthorized",
"code": "401",
"node": "dp01",
"time": "150ms"
}
Common Errors:
401 Unauthorized: Invalidclient_key.400 Bad Request: Missing or invalid parameters.500 Internal Server Error: Temporary server issue. Retry later.
To ensure optimal usage of the API, follow these guidelines:
- Keep your
client_keyconfidential and secure. - Test the API using
type=INFObefore deploying critical notifications. - Validate all parameters locally to minimize errors.
- Implement robust error handling to manage potential failures gracefully.
- Monitor API response times to identify performance issues early.