Swift client for the Rootly incident management platform, auto-generated from OpenAPI specifications using Apple's Swift OpenAPI Generator.
Add the dependency to your Package.swift:
dependencies: [
.package(url: "https://github.com/rootlyhq/rootly-swift.git", from: "1.0.0"),
]Then add Rootly to your target dependencies:
.target(
name: "YourTarget",
dependencies: [
.product(name: "Rootly", package: "rootly-swift"),
]
)- Navigate to Organization dropdown > Organization Settings > API Keys
- Generate a new API key
- Use the token in your client configuration
import Rootly
let client = makeClient(token: "YOUR_API_TOKEN")let response = try await client.listIncidents()
switch response {
case .ok(let ok):
let incidents = try ok.body.applicationVnd_apiJson
for incident in incidents.data ?? [] {
print(incident.attributes?.title ?? "Untitled")
}
default:
print("Request failed")
}let response = try await client.listIncidents(
query: .init(
filter_lbrack_status_rbrack_: "started",
filter_lbrack_severity_rbrack_: "sev0"
)
)let response = try await client.getIncident(
path: .init(id: .init(value1: "YOUR_INCIDENT_UUID"))
)
switch response {
case .ok(let ok):
let incident = try ok.body.applicationVnd_apiJson
print(incident.data?.attributes?.title ?? "")
default:
print("Not found")
}let response = try await client.createIncident(
body: .applicationVnd_apiJson(.init(
data: .init(
_type: .incidents,
attributes: .init(
title: "Database connection pool exhausted",
summary: "Primary database connection pool at 100% capacity",
kind: .normal,
severityId: "YOUR_SEVERITY_UUID"
)
)
))
)
switch response {
case .created(let created):
let incident = try created.body.applicationVnd_apiJson
print("Created: \(incident.data?.id ?? "")")
default:
print("Failed to create")
}let response = try await client.updateIncident(
path: .init(id: .init(value1: "YOUR_INCIDENT_UUID")),
body: .applicationVnd_apiJson(.init(
data: .init(
_type: .incidents,
attributes: .init(
status: "mitigated",
summary: "Connection pool scaled up, requests recovering"
)
)
))
)let response = try await client.listServices()
switch response {
case .ok(let ok):
let services = try ok.body.applicationVnd_apiJson
for service in services.data ?? [] {
print(service.attributes?.name ?? "")
}
default:
break
}let client = makeClient(
token: "YOUR_API_TOKEN",
serverURL: URL(string: "https://your-instance.rootly.com")!
)- Swift 6.0 or later
- Xcode 16+ or equivalent Swift toolchain
make fetch-spec # Download latest OpenAPI spec
make build # Build the package
make test # Run tests
make lint # Run SwiftLintThe SDK uses Apple's swift-openapi-generator as a build plugin. Code generation happens automatically at build time from Sources/Rootly/openapi.json. To update the spec:
make fetch-spec
make buildSee CONTRIBUTING.md for development guidelines.
MIT - Copyright 2026 Rootly Inc.