InsionInsion
Go

Operations

Complete Go guide to records, users, pagination, and appeals

Overview

This guide covers the operations available through the Insion SDK, including moderating and ingesting records, managing users, retrieving stored resources, pagination, and appeals.

Examples use api := client.NewClient(...), ctx, and the root package aliased as insion. Trailing option.RequestOption values are optional.

Shared models

Record

FieldRequiredPurpose
ClientIDYesYour stable record identifier.
NameYesA human-readable record title.
EntityYesThe record kind, such as post or comment.
ContentYes&insion.Content{String: "text"}, or structured text and URLs.
ClientURLNoA link to the record in your application.
MetadataNoSerializable application context.
UserNoThe user associated with the record.
PassthroughModeration onlyModerate without retaining record or user content.

User

FieldRequiredPurpose
ClientIDYesYour stable identifier for the user.
ClientURLNoA link to the user in your application.
StripeAccountIDNoThe user's connected Stripe account ID.
EmailNoThe user's email address.
NameNoThe user's display name.
UsernameNoThe user's handle in your application.
ProtectedNoPrevent automated moderation actions from affecting them.
MetadataNoSerializable application context stored with the user.

Optional values

Value typeHelper
Integerinsion.Int
Stringinsion.String
Booleaninsion.Bool

Identifiers and pagination

Client IDs and Insion IDs

A client ID is supplied by your application, while an Insion ID is generated by Insion.

ValueSourceUsed for
ClientIDYour applicationIngesting, moderating, and deleting.
RecordIDReturned by InsionRetrieving a record.
UserIDReturned by InsionRetrieving users and creating appeals.
StartingAfter / EndingBeforeReturned by InsionMoving through list results.

Use only one cursor direction in a list request.

Ingest a record

queued, err := api.IngestARecord(ctx, &insion.RecordInput{
    ClientID: "post-123", Name: "A post", Entity: "post",
    Content: &insion.Content{String: "Hello"},
})

Use IngestARecord for asynchronous moderation. It returns a message, record ID, nullable moderation ID, and optional user ID.

The final moderation outcome arrives through webhooks.

Moderate a record

result, err := api.ModerateARecord(ctx, &insion.ModerateRequest{
    ClientID: "post-123", Name: "A post", Entity: "post",
    Content: &insion.Content{String: "Hello world"},
    Metadata: map[string]any{"source": "community"},
})

Use ModerateARecord when the caller needs a decision before continuing. It creates or updates the record and returns record ID, status, moderation ID, optional user ID, message, deprecated flagged value, and category IDs.

Setting Passthrough: insion.Bool(true) evaluates the content without retaining record or user content.

Delete a record

deleted, err := api.DeleteARecord(ctx, &insion.DeleteAPIV1IngestRequest{ClientID: "post-123"})

Use DeleteARecord when content no longer exists in your application. It expects your client ID and returns a success response.

List records

page, err := api.ListRecords(ctx, &insion.GetAPIV1RecordsRequest{Limit: insion.Int(100)})

Use ListRecords for review queues, audits, and filtered searches by client ID, Insion user ID, entity, or status. Use only one of StartingAfter or EndingBefore; pages contain Data and HasMore.

Retrieve a record

record, err := api.RetrieveARecord(ctx, &insion.GetAPIV1RecordsRecordIDRequest{RecordID: "rec_123"})

Use RetrieveARecord for one known Insion record ID. The record contains identifiers, URL, name/entity, protection/moderation state, metadata, timestamps, and user ID.

Ingest a user

created, err := api.IngestAUser(ctx, &insion.UserInput{ClientID: "user-42", Email: insion.String("person@example.com")})

Use IngestAUser to create or update a user independently of a record. It returns the Insion user ID used by later filters, retrieval, and appeals.

List users

users, err := api.ListUsers(ctx, &insion.GetAPIV1UsersRequest{Limit: insion.Int(50)})

Use ListUsers for review queues and filtered searches by client ID, email, action status, or Insion user ID; cursor rules match records.

Retrieve a user

user, err := api.RetrieveAUser(ctx, &insion.GetAPIV1UsersUserIDRequest{UserID: "usr_123"})

Use RetrieveAUser for one known Insion user ID. User data includes profile/protection fields, metadata, timestamps, action state, and appeal URL.

Create an appeal

appeal, err := api.CreateAnAppeal(ctx, &insion.PostAPIV1UsersUserIDCreateAppealRequest{
    UserID: "usr_123", Text: "Please review this decision.",
})

Use CreateAnAppeal after an eligible suspended user requests a review. The request uses an Insion user ID, and appeals must be enabled. The response includes appeal/action state, timestamps, and nullable appeal URL.

How is this guide?

On this page

Latest Release

View the Go SDK on pkg.go.devGo SDK versionGo SDK license