Browse Docs

C# / .NET / Unity / Godot Alerts SDK

The API Alerts C# SDK sends alerts from your C# or .NET code through API Alerts. It targets netstandard2.0 and net10.0, so it drops into ASP.NET Core, Blazor, Azure Functions, console apps, Unity (2018+, Mono and IL2CPP), and Godot C# projects. Minimal setup, fire-and-forget by default with optional response handling, and zero infrastructure.

Building a game? Unity and Godot have engine-specific setup - jump to Game engines.

Installation

dotnet add package apialerts

That covers .NET, ASP.NET Core, Blazor, Azure Functions, and console apps. Unity and Godot need a couple of extra steps - see Game engines below.

Usage

Configure the singleton once at startup, then send from anywhere. For dependency injection, mocking, or multiple keys, use the instance client instead.

Fire and forget

using APIAlerts;

ApiAlerts.Configure("your-api-key");

// Never throws, safe to call anywhere
ApiAlerts.Send(new Event { Message = "Deploy complete" });

Wait for response

SendAsync never throws - check result.Success.

var result = await ApiAlerts.SendAsync(new Event
{
    Message  = "New user signed up",
    Channel  = "revenue",
    EventKey = "user.signup",
    Title    = "New Signup",
    Tags     = new[] { "growth", "organic" },
    Link     = "https://dashboard.example.com/users/123",
    Data     = new { plan = "pro", source = "organic" },
});

if (result.Success)
    Console.WriteLine($"Sent to {result.Workspace} ({result.Channel})");
else
    Console.Error.WriteLine($"Error: {result.Error}");

Dependency injection

Register IApiAlertsClient and inject it when you use DI, mock in tests, or need multiple keys:

using Microsoft.Extensions.DependencyInjection;

builder.Services.AddApiAlerts("your-api-key");
public class DeployNotifier(IApiAlertsClient alerts)
{
    public Task Notify() => alerts.SendAsync(new Event { Message = "Deploy complete" });
}

Or construct one directly, no container:

IApiAlertsClient alerts = new ApiAlertsClient("your-api-key");

AddApiAlerts routes SDK logs through the app’s ILoggerFactory. ApiAlerts is a thin facade over a default instance, so the singleton and instance client share the same behaviour.

Multiple workspaces

Pass apiKey to override the configured key for a single call:

var result = await ApiAlerts.SendAsync(
    new Event { Message = "Cross-workspace event" },
    apiKey: "other-api-key");

Event Fields

Only Message is required. All other fields are optional and omitted from the JSON payload when null.

FieldTypeRequiredDescription
MessagestringYesNotification text shown on the push lock screen.
ChannelstringNoWorkspace channel; defaults to the workspace default.
EventKeystringNoRouting key. Matched with Unix glob/fnmatch (ci.*, User *); dotted notation is a convention, not required. Sent as event.
TitlestringNoShort headline some destinations render separately.
Tagsstring[]NoCategorisation tags.
LinkstringNoURL attached to the notification.
DataobjectNoArbitrary metadata for non-push destination templating.

EventKey is named that way because event is a reserved keyword in C#; it serialises to event over the wire.

Game engines (Unity & Godot)

Get a push on your phone the moment something happens in your game or live-ops, without building your own backend:

  • a new high score lands on the leaderboard
  • a player submits feedback or a bug report
  • a server-side error threshold trips during a live event
  • an in-app purchase completes (or fails)
  • a Unity Cloud Build or Godot export finishes in CI
ApiAlerts.Send(new Event
{
    Message  = "New #1 on the leaderboard: 184,200",
    Channel  = "liveops",
    EventKey = "game.leaderboard.record",
    Tags     = new[] { "leaderboard" },
});

Unity

NuGet packages don’t import into Unity natively, and APIAlerts.dll needs assemblies Unity doesn’t ship (System.Text.Json and friends), so it won’t run on its own.

  • NuGetForUnity (recommended) - install it, search apialerts, click install. It resolves the whole dependency tree for you.
  • Manual DLL drop (advanced) - extract lib/netstandard2.0/APIAlerts.dll from the .nupkg into Assets/Plugins/, along with every DLL in its dependency tree (System.Text.Json, System.Net.Http.Json, the Microsoft.Extensions.* abstractions, and their transitive deps). Fiddly by hand, which is why NuGetForUnity is recommended.

Unity also has its own UnityEngine.Event, so new Event { } is ambiguous under using UnityEngine;. Fully-qualify the SDK type as APIAlerts.Event, or alias it with using AlertEvent = APIAlerts.Event;.

Godot (C#)

dotnet add package apialerts

Standard .NET tooling works here, so NuGet restores the dependencies for you - no manual DLL juggling like Unity. This requires the .NET edition of Godot (the Mono/.NET build), not the standard GDScript-only build. For the standard build, use the Godot GDScript SDK instead.

Resources