- Client Creation
- Checks API
- Downtimes API
- Metrics API
- Nodes API
- Recipients API
- Status Pages API
- Pulse Monitoring
- Exception Types
- Models
Creates a simple client with the specified API key.
var client = UpdownClientFactory.Create("your-api-key");Note: This creates a new HttpClient instance. For production use, consider using the Builder pattern or injecting your own HttpClient.
Returns a fluent builder for advanced configuration.
var client = UpdownClientFactory.CreateBuilder()
.WithApiKey("your-api-key")
.WithTimeout(TimeSpan.FromSeconds(30))
.WithUserAgent("MyApp/1.0")
.Build();Creates a client using your own HttpClient instance.
var httpClient = new HttpClient
{
BaseAddress = new Uri("https://updown.io")
};
httpClient.DefaultRequestHeaders.Add("X-API-KEY", "your-api-key");
var client = UpdownClientFactory.Create(httpClient);Gets all checks for your account.
Returns: Task<List<Check>>
var checks = await client.ChecksAsync();
foreach (var check in checks)
{
Console.WriteLine($"{check.Alias}: {check.Url} - {(check.Down == true ? "DOWN" : "UP")}");
}Gets a specific check by its token.
Parameters:
token- The check tokencancellationToken- Optional cancellation token
Returns: Task<Check>
Throws:
ArgumentException- When token is null or emptyUpdownNotFoundException- When check doesn't exist
var check = await client.CheckAsync("abc123");
Console.WriteLine($"Last checked: {check.LastCheckAt}");Creates a new check.
Parameters:
parameters- Check configuration parameterscancellationToken- Optional cancellation token
Returns: Task<Check>
Throws:
ArgumentNullException- When parameters is nullUpdownBadRequestException- When parameters are invalid
var parameters = new CheckParameters
{
Url = "https://example.com",
Alias = "My Website",
Period = 60, // Check every 60 seconds
Enabled = true
};
var check = await client.CheckCreateAsync(parameters);
Console.WriteLine($"Check created with token: {check.Token}");CheckUpdateAsync(string token, CheckParameters parameters, CancellationToken cancellationToken = default)
Updates an existing check.
Parameters:
token- The check tokenparameters- Updated check parameterscancellationToken- Optional cancellation token
Returns: Task<Check>
var updateParams = new CheckParameters
{
Period = 300, // Change to 5 minutes
Enabled = false // Disable the check
};
var updated = await client.CheckUpdateAsync("abc123", updateParams);Deletes a check.
Parameters:
token- The check tokencancellationToken- Optional cancellation token
Returns: Task<DeleteResponse>
var result = await client.CheckDeleteAsync("abc123");
if (result.Deleted)
{
Console.WriteLine("Check deleted successfully");
}Gets downtime history for a specific check.
Parameters:
token- The check tokenpage- Optional page number for paginationcancellationToken- Optional cancellation token
Returns: Task<List<Downtime>>
var downtimes = await client.DowntimesAsync("abc123");
foreach (var downtime in downtimes)
{
Console.WriteLine($"Down from {downtime.StartedAt} to {downtime.EndedAt}");
Console.WriteLine($"Duration: {downtime.Duration} seconds");
Console.WriteLine($"Error: {downtime.Error}");
}MetricsAsync(string token, string? from = null, string? to = null, string? group = null, CancellationToken cancellationToken = default)
Gets performance metrics for a check.
Parameters:
token- The check tokenfrom- Optional start time (ISO 8601 format or UNIX timestamp)to- Optional end time (ISO 8601 format or UNIX timestamp)group- Optional grouping interval ("time" or "host")cancellationToken- Optional cancellation token
Returns: Task<List<Metric>>
// Get metrics for the last 24 hours
var yesterday = DateTimeOffset.UtcNow.AddDays(-1).ToString("o");
var now = DateTimeOffset.UtcNow.ToString("o");
var metrics = await client.MetricsAsync("abc123", from: yesterday, to: now);
foreach (var metric in metrics)
{
Console.WriteLine($"Apdex: {metric.Apdex}");
Console.WriteLine($"Response time: {metric.Timings?.Total}ms");
Console.WriteLine($"Requests: {metric.Requests?.Samples}");
}Gets all monitoring nodes/locations.
Returns: Task<List<Node>>
var nodes = await client.NodesAsync();
foreach (var node in nodes)
{
Console.WriteLine($"{node.Name} - {node.City}, {node.Country}");
Console.WriteLine($"Location: {node.Latitude}, {node.Longitude}");
}Gets all IPv4 addresses used by monitoring nodes.
Returns: Task<NodeIpv4Addresses>
var addresses = await client.NodesIpv4Async();
// Use for firewall whitelisting
foreach (var ip in addresses.Ipv4 ?? Enumerable.Empty<string>())
{
Console.WriteLine($"Whitelist: {ip}");
}Gets all IPv6 addresses used by monitoring nodes.
Returns: Task<NodeIpv6Addresses>
var addresses = await client.NodesIpv6Async();
foreach (var ip in addresses.Ipv6 ?? Enumerable.Empty<string>())
{
Console.WriteLine($"Whitelist IPv6: {ip}");
}Gets all notification recipients.
Returns: Task<List<Recipient>>
var recipients = await client.RecipientsAsync();
foreach (var recipient in recipients)
{
Console.WriteLine($"{recipient.Name} ({recipient.Type}): {recipient.Value}");
}Creates a new notification recipient.
Parameters:
parameters- Recipient configurationcancellationToken- Optional cancellation token
Returns: Task<Recipient>
var parameters = new RecipientParameters
{
Type = "email",
Name = "John Doe",
Value = "john@example.com"
};
var recipient = await client.RecipientCreateAsync(parameters);Recipient Types:
email- Email addressslack- Slack webhook URLwebhook- Custom webhook URL
Deletes a recipient.
Parameters:
token- The recipient IDcancellationToken- Optional cancellation token
Returns: Task<DeleteResponse>
await client.RecipientDeleteAsync("recipient-id");Gets all status pages.
Returns: Task<List<StatusPage>>
var pages = await client.StatusPagesAsync();
foreach (var page in pages)
{
Console.WriteLine($"{page.Name}: {page.Url}");
}StatusPageCreateAsync(StatusPageParameters parameters, CancellationToken cancellationToken = default)
Creates a new status page.
Parameters:
parameters- Status page configurationcancellationToken- Optional cancellation token
Returns: Task<StatusPage>
var parameters = new StatusPageParameters
{
Name = "Service Status",
Description = "Current status of our services",
Visibility = "public",
Checks = new List<string> { "check-token-1", "check-token-2" }
};
var page = await client.StatusPageCreateAsync(parameters);StatusPageUpdateAsync(string token, StatusPageParameters parameters, CancellationToken cancellationToken = default)
Updates a status page.
Returns: Task<StatusPage>
var updateParams = new StatusPageParameters
{
Name = "Updated Status Page",
Visibility = "private",
AccessKey = "secret-key"
};
await client.StatusPageUpdateAsync("page-token", updateParams);Deletes a status page.
Returns: Task<DeleteResponse>
await client.StatusPageDeleteAsync("page-token");Pulse monitoring is used for cron job and background task monitoring. Your application sends heartbeats TO Updown.io.
Sends a heartbeat pulse using GET request.
Parameters:
pulseUrl- The complete pulse URL from Updown.iocancellationToken- Optional cancellation token
Returns: Task
// In your cron job or background task
public async Task RunScheduledTask()
{
var client = UpdownClientFactory.Create("your-api-key");
var pulseUrl = "https://pulse.updown.io/your-token/your-key";
try
{
// Do your work
await DoWork();
// Send success pulse
await client.SendPulseAsync(pulseUrl);
}
catch (Exception ex)
{
// Don't send pulse on failure - Updown.io will alert
_logger.LogError(ex, "Task failed");
}
}SendPulsePostAsync(string pulseUrl, HttpContent? content = null, CancellationToken cancellationToken = default)
Sends a heartbeat pulse using POST request with optional content.
Parameters:
pulseUrl- The complete pulse URL from Updown.iocontent- Optional HTTP content to sendcancellationToken- Optional cancellation token
Returns: Task
var content = new StringContent("Task completed successfully");
await client.SendPulsePostAsync(pulseUrl, content);Base exception for all Updown.io API errors.
Properties:
StatusCode- HTTP status codeResponseContent- Raw response bodyMessage- Error message
Thrown when a resource is not found (HTTP 404).
try
{
var check = await client.CheckAsync("nonexistent");
}
catch (UpdownNotFoundException ex)
{
Console.WriteLine($"Check not found: {ex.Message}");
}Thrown when authentication fails (HTTP 401 or 403).
catch (UpdownUnauthorizedException ex)
{
Console.WriteLine("Invalid API key or insufficient permissions");
}Thrown when the request is invalid (HTTP 400).
catch (UpdownBadRequestException ex)
{
Console.WriteLine($"Invalid request: {ex.ResponseContent}");
}Thrown when API rate limit is exceeded (HTTP 429).
Additional Properties:
RetryAfterSeconds- Seconds until rate limit resetsResetTime- DateTimeOffset when limit resets
catch (UpdownRateLimitException ex)
{
Console.WriteLine($"Rate limited. Retry after {ex.RetryAfterSeconds} seconds");
if (ex.ResetTime.HasValue)
{
await Task.Delay(TimeSpan.FromSeconds(ex.RetryAfterSeconds ?? 60));
// Retry...
}
}Represents an HTTP monitoring check.
Key Properties:
Token- Unique check identifierUrl- URL being monitoredAlias- Friendly nameDown- Whether check is currently downLastStatus- Last HTTP status codeUptime- Uptime percentagePeriod- Check interval in secondsEnabled- Whether check is activeLastCheckAt- Time of last checkNextCheckAt- Time of next scheduled check
Parameters for creating/updating checks.
Properties:
Url- URL to monitorAlias- Friendly namePeriod- Check interval (15, 30, 60, 120, 300, 600, 1800, 3600)ApdexT- Apdex threshold in seconds (0.125-8)Enabled- Enable/disable checkPublished- Publish on status pageStringMatch- String to find in responseCustomHeaders- Custom HTTP headersHttpVerb- HTTP method (GET, POST, etc.)HttpBody- Request bodyRecipients- List of recipient IDs to notify
Represents a downtime period.
Properties:
Error- Error messageStartedAt- When downtime startedEndedAt- When downtime ended (null if still down)Duration- Duration in seconds
Performance metrics for a time period.
Properties:
Time- Timestamp (UNIX epoch)Apdex- Apdex score (0-1)Requests- Request statisticsTimings- Response time breakdown
Monitoring node/location.
Properties:
Name- Node identifierCity- City nameCountry- Country nameCountryCode- ISO country codeLatitude- Geographic latitudeLongitude- Geographic longitudeIpAddress- IPv4 addressIpv6Address- IPv6 address
Notification recipient.
Properties:
Id- Unique identifierType- Recipient type (email, slack, webhook)Name- Display nameValue- Contact value (email, URL, etc.)
Public status page.
Properties:
Token- Unique identifierUrl- Public URLName- Page nameDescription- Page descriptionVisibility- public or privateAccessKey- Access key for private pagesChecks- List of check tokens to display
Updown.io enforces rate limits:
- Free plans: 60 requests/minute
- Paid plans: Higher limits
When rate limited:
- Catch
UpdownRateLimitException - Check
RetryAfterSecondsproperty - Wait before retrying
- Consider implementing exponential backoff
All requests require an API key:
- Get your API key from https://updown.io/settings/edit
- Pass to client creation
- Never commit API keys to source control
- Use environment variables or secure vaults
- Reuse HttpClient: Don't create a new client for each request
- Handle Exceptions: Wrap API calls in try-catch blocks
- Use Cancellation Tokens: Support request cancellation
- Log Appropriately: Don't log API keys or sensitive data
- Respect Rate Limits: Implement retry logic with backoff
- Use Async/Await: Don't block with
.Resultor.Wait() - Dispose Properly: If you create HttpClient, dispose it when done
See the README.md for comprehensive usage examples.