Swift client
Install, configure, and use Insion from Swift concurrency code.
The Swift SDK exposes the Insion API through ApiClient. Every operation is an async throws method, so it fits naturally inside an existing Task, an async function, or a SwiftUI workflow. The generated package exports the client, request models, response models, and error types from the Api module.
Requirements and installation
The generated package supports Swift 5.7 or later, iOS 15+, macOS 12+, tvOS 15+, and watchOS 8+. Add the published package to the top-level dependencies in Package.swift:
dependencies: [
.package(url: "https://github.com/insion/insion-swift", from: "0.1.0")
]Add Api to the target that calls Insion:
.target(
name: "MyApp",
dependencies: [.product(name: "Api", package: "insion-swift")]
)First request
Create a client with a bearer token, construct a typed request, and await the result. clientId is your stable record identifier; the returned id is Insion's identifier for later retrieval and pagination.
import Api
func moderatePost() async throws {
let client = ApiClient(token: "<token>")
let result = try await client.moderateARecord(request: .init(
clientId: "post-123",
clientUrl: "https://example.com/posts/123",
name: "Welcome post",
entity: "post",
content: .string("Hello from Swift")
))
print(result.id)
print(result.status.rawValue)
print(result.categoryIds)
}Choose the right operation
moderateARecord is the synchronous path: it creates or updates a record and returns a moderation result immediately. ingestARecord is the asynchronous ingestion path; retain its returned record ID and consume moderation events through your webhook integration. ingestAUser updates a user without a record. The list and retrieve methods let you inspect stored records and users, while createAnAppeal is for an eligible suspended user.
All calls accept an optional RequestOptions value. Use it for a one-off timeout, retry policy, token override, or additional HTTP data without changing the client used by other requests. See Configuration before sharing a client across an application.
Content and metadata
Content is a Swift enum. Use .string(...) for text-only moderation, or .contentExternalUrls(...) when supplying text alongside image or external-page URLs:
let content = Content.contentExternalUrls(.init(
text: "Review this listing",
imageUrls: ["https://cdn.example.com/image.png"],
externalUrls: ["https://example.com/listing/123"]
))Metadata is [String: JSONValue]. Keys are limited to 40 characters and cannot contain [ or ]; values must be serializable and no longer than 500 characters, with at most 50 keys. The SDK preserves additional, unrecognised properties on its models in additionalProperties.
Next Steps
Start with Configuration for client-wide and per-request behavior, and Errors and responses for Swift error handling. Each operation has its own page with the exact Swift signature, typed request construction, response fields, and practical lifecycle guidance.