InsionInsion
Swift

Moderate a record

Create or update a record and receive its moderation result immediately.

Use moderateARecord when your caller needs the moderation decision in the same request. It creates or updates the record identified by your clientId and returns a ModerateResponse rather than queuing work for later webhook delivery.

func moderate(client: ApiClient) async throws {
    let result = try await client.moderateARecord(request: .init(
        clientId: "comment-42",
        clientUrl: "https://example.com/comments/42",
        name: "Comment 42",
        entity: "comment",
        content: .string("This is the submitted comment."),
        user: .init(clientId: "member-9", email: "member@example.com")
    ))

    if result.status.rawValue == "Flagged" {
        // Use result.categoryIds and result.message in your workflow.
    }
}

Signature

func moderateARecord(
    request: Requests.ModerateRequest,
    requestOptions: RequestOptions? = nil
) async throws -> ModerateResponse

Request

FieldRequiredDescription
clientIdYesYour stable unique record identifier. Reusing it updates the same logical record.
nameYesRecord title or name.
entityYesRecord kind, such as post, comment, or message.
contentYes.string(...) text or .contentExternalUrls(...) with text and URLs.
clientUrlNoURL of the original content.
metadataNoCustom [String: JSONValue] data subject to metadata limits.
userNoUserInput to associate a user with the record.
passthroughNoWhen true, moderate without persisting the record name/content or user email/name/username.

For richer content, construct ContentExternalUrls(text:imageUrls:externalUrls:); text is required even when URLs are supplied. Use Configuration to set a request-specific timeout or headers.

Result

ModerateResponse includes id (Insion record ID), status, moderation (Insion moderation ID), optional user, a human-readable message, and categoryIds for matched rules. flagged is retained for compatibility and is deprecated; prefer the typed status field.

Persist the returned id if you need to retrieve the record later. Treat clientId and the returned Insion ID as different identifiers: deletion is by clientId, while retrieval uses the Insion record ID.

On this page