Before you start
- You need Swift 5.9+ installed on your machine.
- You need a Rewrite API key with the required permissions.
Set up REWRITE_API_KEY environment variable
Set up your Rewrite API key in your environment variables.
.env
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Learn how to use the Swift SDK to send SMS with the API.
dependencies: [
.package(url: "https://github.com/rewritetoday/swift-sdk", from: "1.0.0")
]
REWRITE_API_KEY=rw...
import Foundation
import RewriteSDK
@main
struct Main {
static func main() async throws {
let rewrite = Rewrite(apiKey: ProcessInfo.processInfo.environment["REWRITE_API_KEY"] ?? "")
let message = try await rewrite.messages.send(
to: "+1234567890",
content: "Your OTP code is 478201"
)
print(message)
}
}