Browse Docs

Go Alerts SDK

The API Alerts Go SDK sends alerts from your Go code through API Alerts. Drop it into HTTP servers, CLI tools, microservices, background workers, or any Go application that needs to notify you when something important happens. Minimal setup, fire-and-forget by default with optional response handling, and zero infrastructure.

Installation

go get github.com/apialerts/apialerts-go

Usage

package main

import apialerts "github.com/apialerts/apialerts-go"

func main() {
    apialerts.Configure("YOUR-API-KEY")

    // Simple notification
    apialerts.Send(apialerts.Event{
        Message: "Deployment successful",
    })

    // With routing (recommended for production)
    apialerts.Send(apialerts.Event{
        Event:   "ci.deploy.success",
        Message: "Deployment successful",
    })

    // With all options
    apialerts.Send(apialerts.Event{
        Event:   "user.signup",
        Message: "New user signed up",
        Channel: "developers",
        Title:   "New Signup",
        Tags:    []string{"signup", "organic"},
        Link:    "https://dashboard.example.com/users/123",
        Data:    map[string]any{"plan": "pro", "region": "us-east-1"},
    })
}

Event fields

FieldTypeRequiredDescription
MessagestringYesHuman-readable notification text. This is what appears on the push notification lock screen.
ChannelstringNoWorkspace channel the push notification fires on. Defaults to the workspace default channel when omitted.
EventstringNoWhat kind of thing happened. Optional but recommended. Routers match this value with Unix glob (fnmatch): dotted keys like ci.deploy.success match ci.*, and free-form keys like User Signup match User *. Dotted notation is just a tidy convention, not a requirement.
TitlestringNoShort headline some destinations render separately from the message body.
Tags[]stringNoCategorisation tags for filtering and search.
LinkstringNoURL associated with the event. Available as a deeplink for push notifications and as a call-to-action for routed destinations.
Datamap[string]anyNoArbitrary key-value metadata. Available to non-push destinations for templating (Slack message bodies, email templates, webhook payloads).

Optional fields are omitted from the request body when zero-valued - they’re never sent as null.

Wait for the response

Send is fire-and-forget and delivers in a background goroutine. In short-lived programs (CLI tools, CI scripts) that exit right after sending, use SendAsync so the process waits for delivery and you can inspect the result.

result, err := apialerts.SendAsync(event)
if err != nil {
    log.Println("Failed to send:", err)
    return
}
fmt.Printf("Sent to %s (%s)\n", result.Workspace, result.Channel)

Send to multiple workspaces

Use SendWithKey (or SendWithKeyAsync) to override the configured API key for a single call. Useful when one process needs to send to several workspaces.

apialerts.SendWithKey("other-workspace-api-key", event)

Resources