API Bash Usage

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.

Sending a Notification

To send a notification, use the following curl command:

Copy
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.

Understanding Parameters

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.
API Response

Upon success, the API returns a JSON response. Example:

Copy
{ "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., 200 for success.
  • node: The server node that handled the request.
  • time: The time taken to process the request in milliseconds.
Error Handling

If the request fails, the API provides a detailed error response. Example:

Copy
{ "text": "Unauthorized", "code": "401", "node": "dp01", "time": "150ms" }

Common Errors:

  • 401 Unauthorized: Invalid client_key.
  • 400 Bad Request: Missing or invalid parameters.
  • 500 Internal Server Error: Temporary server issue. Retry later.
Best Practices

To ensure optimal usage of the API, follow these guidelines:

  • Keep your client_key confidential and secure.
  • Test the API using type=INFO before 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.
Did you find this page helpful?
These might also be helpful