Skip to content
QwryAI
Documentation
Pages

iOS SDK

Conversation & Pagination

Reference for Conversation, Conversation.Status and Page, the types used for conversation history

listConversations returns Conversation values, and both list methods wrap their results in a Page. This page lists every field.

Conversation

struct Conversation: Sendable, Equatable, Identifiable, Decodable

What listConversations returns.

Swift
public struct Conversation: Sendable, Equatable, Identifiable, Decodable {
    public enum Status: String, Sendable, Codable { case ongoing, ended, takenOver = "taken_over" }

    public let id: String
    public let title: String?
    public let createdAt: Date
    public let updatedAt: Date
    public let userId: String?
    public let status: Status
}
PropertyTypeDescription
idStringThe conversation ID. Pass it to listMessages or send.
titleString?A short summary QwryAI writes for the conversation. nil until there is one, so show something like "New conversation" instead.
createdAtDateWhen the conversation started.
updatedAtDateWhen it was last active. Lists come sorted on this, newest first.
userIdString?The signed-in user the conversation belongs to, or nil if it belongs to a device.
statusStatusSee Conversation.Status.

Conversation is Identifiable, so it works with ForEach and List as it is:

Swift
List(conversations) { conversation in
    NavigationLink {
        ChatScreen(client: client, conversationId: conversation.id)
    } label: {
        VStack(alignment: .leading) {
            Text(conversation.title ?? "New conversation")
            Text(conversation.updatedAt, style: .relative)
                .font(.caption)
                .foregroundStyle(.secondary)
        }
    }
}

Conversation.Status

Swift
public enum Status: String, Sendable, Codable {
    case ongoing                   // "ongoing"     open, answered by your agent
    case ended                     // "ended"       closed
    case takenOver = "taken_over"  // a person on your team took over
}

Only .ongoing conversations take new messages. Sending to any other fails with 403 CHAT_CONVERSATION_NOT_ONGOING. See Error Handling.

Swift
if conversation.status == .ongoing {
    showComposer()
} else {
    showReadOnlyBanner()
}

Message

Message is used for both answers and history. See ChatResponse for the full reference, along with MessagePart, Message.Role and Message.Feedback.

Page

struct Page<Item: Sendable & Decodable>: Sendable, Decodable

What listConversations() and listMessages(conversationId:) return.

Swift
public struct Page<Item: Sendable & Decodable>: Sendable, Decodable {
    public let items: [Item]
    public let cursor: String?
    public let hasMore: Bool
    public let total: Int
}
PropertyTypeDescription
items[Item]The items on this page.
cursorString?Where the next page starts. Pass it back as cursor. nil on the last page.
hasMoreBoolWhether there are more pages.
totalIntHow many items there are in all.

Next page

There's no helper on the page itself: pass cursor back to the same method. Keep the same limit so pages stay the same size.

Swift
var page = try await client.listConversations(limit: 20)
var all = page.items
while page.hasMore, let cursor = page.cursor {
    page = try await client.listConversations(cursor: cursor, limit: 20)
    all.append(contentsOf: page.items)
}

Explore the documentation