Swift
List records
Query records with filters and cursor-based pagination.
listRecords returns records belonging to the authenticated organization. It accepts individual Swift parameters instead of a request object, so omit filters that do not apply.
let page = try await client.listRecords(
limit: 50,
clientId: "post-123",
entity: "post",
status: .flagged
)
for record in page.data {
print(record.id, record.clientId, record.moderationPending)
}Signature and filters
func listRecords(
limit: Int? = nil, startingAfter: String? = nil, endingBefore: String? = nil,
clientId: String? = nil, user: String? = nil, entity: String? = nil,
status: GetApiV1RecordsRequestStatus? = nil,
requestOptions: RequestOptions? = nil
) async throws -> ListRecordsResponse| Parameter | Description |
|---|---|
limit | Maximum items to return. |
startingAfter | Return items after this Insion record ID. Mutually exclusive with endingBefore. |
endingBefore | Return items before this Insion record ID. Mutually exclusive with startingAfter. |
clientId | Filter by your record identifier. |
user | Filter by an Insion user ID. |
entity | Filter by entity type. |
status | .compliant or .flagged; values are sent as Compliant and Flagged. |
Pagination and response
The response has data: [Record] and hasMore: Bool. Each record exposes its Insion id, your clientId, moderation state, timestamps, metadata, and associated user when present. To fetch forward pages, call again with startingAfter set to the last returned record's id while hasMore is true:
var cursor: String?
repeat {
let page = try await client.listRecords(limit: 100, startingAfter: cursor)
// Process page.data before requesting the next page.
cursor = page.data.last?.id
if !page.hasMore { break }
} while cursor != nilNever send both cursor parameters. Preserve the same filters across pages so the cursor traverses one consistent result set.