// inbox.vision typed SDK v0.1.0 — GENERATED from the OpenAPI spec. Do not edit by hand.
// Usage: const client = new InboxVision({ apiKey: "iv_..." }); await client.getConversations();

export interface InboxVisionOptions {
  /** Your `iv_` API key. */
  apiKey: string;
  /** API base URL. Defaults to https://inbox.vision */
  baseUrl?: string;
}

export interface Error { "statusCode"?: number; "name"?: string; "message"?: string }
export interface Conversation { "object"?: string; "id"?: string; "contact_id"?: string; "channel"?: "email" | "chat" | "api"; "inbox_address"?: string; "subject"?: string; "status"?: "open" | "pending" | "resolved" | "snoozed"; "priority"?: string; "assignee_id"?: string; "team_id"?: string; "sla_policy_id"?: string; "sla"?: { "breached"?: boolean; "next_due_at"?: string | null } | null; "snooze_until"?: number | null; "sentiment"?: "positive" | "neutral" | "negative" | null; "sentiment_at"?: string | null; "labels"?: string[]; "messages"?: Record<string, unknown>[] }
export interface ConversationRequest { "contact": string; "channel"?: "email" | "chat" | "api"; "inbox_address"?: string; "subject"?: string; "message"?: string; "identifiers"?: { "type": "email" | "phone" | "chat" | "social" | "external"; "value": string }[] }
export interface ReplyRequest { "content"?: string; "private"?: boolean; "agent_id"?: string; "canned_response_id"?: string; "canned_short_code"?: string; "mentions"?: string[]; "attachment_ids"?: string[] }
export interface Mention { "object"?: string; "id"?: string; "conversation_id"?: string; "message_id"?: string; "agent_id"?: string; "read"?: boolean; "created_at"?: string }
export interface CsatRequest { "rating": number; "feedback"?: string }
export interface CsatResponse { "object"?: string; "conversation_id"?: string; "rating"?: number | null; "feedback"?: string | null; "agent_id"?: string; "created_at"?: string; "requested_at"?: string | null; "survey_url"?: string | null }
export interface CsatSummary { "object"?: string; "total"?: number; "average"?: number; "satisfied"?: number; "satisfied_pct"?: number; "distribution"?: Record<string, unknown> }
export interface DurationStats { "count"?: number; "median_minutes"?: number | null; "avg_minutes"?: number | null; "p90_minutes"?: number | null }
export interface Report { "object"?: string; "window_days"?: number; "conversations"?: { "total"?: number; "open"?: number; "pending"?: number; "resolved"?: number; "snoozed"?: number }; "messages"?: { "total"?: number; "incoming"?: number; "outgoing"?: number }; "csat"?: CsatSummary; "sentiment"?: { "analyzed"?: number; "positive"?: number; "neutral"?: number; "negative"?: number }; "response_times"?: { "first_response"?: DurationStats; "resolution"?: DurationStats }; "contacts"?: number; "agents"?: { "agent_id"?: string; "email"?: string; "name"?: string; "assigned"?: number; "resolved"?: number }[] }
export interface WidgetInbox { "object"?: string; "id"?: string; "widget_token"?: string; "name"?: string; "welcome_message"?: string; "created_at"?: string }
export interface WidgetInboxRequest { "name": string; "welcome_message"?: string }
export interface WidgetContactRequest { "name"?: string; "email"?: string }
export interface WidgetSession { "object"?: string; "session_token"?: string; "conversation_id"?: string; "welcome_message"?: string }
export interface WidgetMessageRequest { "session_token": string; "content": string }
export interface MacroAction { "type": "add_label" | "change_status" | "change_priority" | "assign_agent" | "assign_team" | "add_private_note" | "send_reply" | "hand_to_human"; "label"?: string; "status"?: string; "priority"?: string | null; "agent_id"?: string; "team_id"?: string; "content"?: string; "canned_response_id"?: string; "canned_short_code"?: string; "reason"?: string }
export interface Macro { "object"?: string; "id"?: string; "name"?: string; "actions"?: MacroAction[]; "created_at"?: string; "updated_at"?: string }
export interface MacroRequest { "name": string; "actions": MacroAction[] }
export interface RuleCondition { "field": "status" | "priority" | "channel" | "subject" | "message"; "operator": "equals" | "not_equals" | "contains" | "is_empty" | "is_present"; "value"?: string }
export interface AutomationRule { "object"?: string; "id"?: string; "name"?: string; "event"?: "conversation_created" | "conversation_updated" | "message_created"; "conditions"?: { "match"?: "all" | "any"; "conditions"?: RuleCondition[] }; "actions"?: MacroAction[]; "enabled"?: boolean; "created_at"?: string; "updated_at"?: string }
export interface AutomationRuleRequest { "name": string; "event": "conversation_created" | "conversation_updated" | "message_created"; "conditions": { "match"?: "all" | "any"; "conditions": RuleCondition[] }; "actions": MacroAction[]; "enabled"?: boolean }
export interface HelpPortal { "object"?: string; "id"?: string; "portal_token"?: string; "name"?: string; "slug"?: string; "created_at"?: string }
export interface HelpPortalRequest { "name": string; "slug"?: string }
export interface HelpArticle { "object"?: string; "id"?: string; "portal_id"?: string; "title"?: string; "slug"?: string; "content"?: string; "status"?: "draft" | "published"; "category_id"?: string | null; "published_at"?: string | null }
export interface HelpArticleRequest { "portal_id": string; "title": string; "content": string; "slug"?: string; "status"?: "draft" | "published"; "author_id"?: string; "category_id"?: string }
export interface HelpCategory { "object"?: string; "id"?: string; "portal_id"?: string; "name"?: string; "slug"?: string; "description"?: string | null; "position"?: number; "created_at"?: string; "updated_at"?: string }
export interface HelpCategoryRequest { "portal_id": string; "name": string; "slug"?: string; "description"?: string; "position"?: number }
export interface SlaPolicy { "object"?: string; "id"?: string; "name"?: string; "first_response_minutes"?: number | null; "resolution_minutes"?: number | null; "business_hours_id"?: string | null; "created_at"?: string }
export interface SlaPolicyRequest { "name": string; "first_response_minutes"?: number | null; "resolution_minutes"?: number | null; "business_hours_id"?: string | null }
export interface BusinessHoursDay { "day": number; "open": boolean; "start": string; "end": string }
export interface BusinessHours { "object"?: string; "id"?: string; "name"?: string; "timezone"?: string; "days"?: BusinessHoursDay[]; "holidays"?: string[]; "created_at"?: string; "updated_at"?: string }
export interface BusinessHoursRequest { "name": string; "timezone": string; "days": BusinessHoursDay[]; "holidays"?: string[] }
export interface ReplySuggestion { "object"?: string; "conversation_id"?: string; "suggestion"?: string; "sources"?: { "id"?: string; "title"?: string; "slug"?: string }[]; "model"?: string; "grounded"?: boolean }
export interface ConversationSummary { "object"?: string; "conversation_id"?: string; "summary"?: string; "sentiment"?: "positive" | "neutral" | "negative"; "model"?: string; "message_count"?: number }
export interface CannedResponse { "object"?: string; "id"?: string; "short_code"?: string; "content"?: string; "created_at"?: string; "updated_at"?: string }
export interface CannedResponseRequest { "short_code": string; "content": string }
export interface ConversationPatch { "status"?: "open" | "pending" | "resolved" | "snoozed"; "assignee_id"?: string; "priority"?: "urgent" | "high" | "medium" | "low"; "snooze_until"?: unknown }
export interface Agent { "object"?: string; "id"?: string; "email"?: string; "name"?: string; "role"?: "admin" | "agent"; "status"?: "active" | "disabled" }
export interface AgentRequest { "email": string; "name"?: string; "role"?: "admin" | "agent" }
export interface Label { "object"?: string; "id"?: string; "name"?: string; "color"?: string }
export interface ConversationViewFilters { "q"?: string; "status"?: "open" | "pending" | "resolved" | "snoozed"; "label"?: string; "assignee"?: string; "priority"?: "urgent" | "high" | "medium" | "low"; "unread"?: "1"; "sentiment"?: "positive" | "neutral" | "negative" }
export interface ConversationViewRequest { "name": string; "filters"?: ConversationViewFilters }
export interface ConversationView { "object"?: string; "id"?: string; "name"?: string; "filters"?: ConversationViewFilters; "created_at"?: string }
export interface LabelRequest { "name": string; "color"?: string }
export interface ConversationLabels { "labels": string[] }
export interface ConversationTeam { "team_id": string }
export interface Team { "object"?: string; "id"?: string; "name"?: string; "auto_assign"?: boolean; "availability_aware"?: boolean; "assign_strategy"?: "round_robin" | "balanced"; "max_open_per_agent"?: number | null; "created_at"?: string; "members"?: Record<string, unknown>[] }
export interface TeamRequest { "name": string; "auto_assign"?: boolean; "availability_aware"?: boolean; "assign_strategy"?: "round_robin" | "balanced"; "max_open_per_agent"?: number | null }
export interface TeamMemberRequest { "agent_id": string }
export interface SignupRequest { "name": string; "email": string }
export interface Account { "id"?: string; "name"?: string; "email"?: string; "plan"?: string; "credits"?: number; "api_key"?: Record<string, unknown> }
export interface SendEmailRequest { "from": string; "to": unknown; "subject": string; "html"?: string; "text"?: string; "cc"?: unknown; "bcc"?: unknown; "reply_to"?: unknown; "headers"?: Record<string, unknown>; "tags"?: { "name"?: string; "value"?: string }[]; "attachments"?: { "filename"?: string; "content"?: string; "content_type"?: string }[]; "scheduled_at"?: string; "tracking"?: boolean; "template_id"?: string; "data"?: Record<string, unknown> }
export interface SendEmailResponse { "id"?: string }
export interface Email { "object"?: string; "id"?: string; "from"?: string; "to"?: string[]; "subject"?: string; "last_event"?: string; "created_at"?: string; "recipients"?: { "recipient"?: string; "kind"?: "to" | "cc" | "bcc"; "status"?: string }[] }
export interface AddDomainRequest { "name": string; "region"?: string }
export interface Domain { "object"?: string; "id"?: string; "name"?: string; "status"?: string; "records"?: Record<string, unknown>[] }
export interface CreateKeyRequest { "name": string; "permission"?: "full_access" | "sending_access" }
export interface CreateWebhookRequest { "url": string; "events"?: "email.sent" | "email.delivered" | "email.bounced" | "email.complained" | "email.opened" | "email.clicked" | "email.received" | "conversation.created" | "conversation.updated" | "message.created" | "conversation.replied" | "conversation.handoff" | "csat.received"[] }
export interface SuppressRequest { "email": string; "reason"?: "manual" | "bounce" | "complaint" | "unsubscribe" }
export interface Analytics { "sent"?: number; "delivered"?: number; "bounced"?: number; "complained"?: number; "opens"?: number; "clicks"?: number; "rates"?: Record<string, unknown> }
export interface Reputation { "domain"?: string; "processed"?: number; "delivered"?: number; "bounced"?: number; "complained"?: number; "delivery_rate"?: number; "bounce_rate"?: number; "complaint_rate"?: number; "bounce_status"?: "healthy" | "warning" | "critical"; "complaint_status"?: "healthy" | "warning" | "critical"; "status"?: "healthy" | "warning" | "critical"; "advice"?: string }
export interface Deliverability { "object"?: string; "window_days"?: number; "include_sandbox"?: boolean; "account"?: Reputation; "domains"?: Reputation[] }
export interface TemplateRequest { "name": string; "subject"?: string; "html"?: string; "text"?: string }
export interface Template { "object"?: string; "id"?: string; "name"?: string; "subject"?: string; "html"?: string; "text"?: string }
export interface ContactRequest { "email": string; "first_name"?: string; "last_name"?: string; "data"?: Record<string, unknown>; "status"?: "subscribed" | "unsubscribed" | "cleaned"; "audiences"?: string[] }
export interface Contact { "object"?: string; "id"?: string; "hash"?: string; "email"?: string; "status"?: string }
export interface Audience { "object"?: string; "id"?: string; "name"?: string; "member_count"?: number }
export interface CampaignRequest { "name": string; "audience_id": string; "from": string; "subject"?: string; "html"?: string; "text"?: string; "template_id"?: string; "segment_id"?: string }
export interface Campaign { "object"?: string; "id"?: string; "name"?: string; "audience_id"?: string; "segment_id"?: string; "from"?: string; "subject"?: string; "status"?: "draft" | "sending" | "sent" | "canceled"; "total_recipients"?: number; "sent_count"?: number }
export interface AutomationRequest { "name": string; "trigger_type"?: "audience_subscribed"; "audience_id": string; "template_id"?: string; "steps"?: { "template_id": string; "delay_seconds"?: number }[]; "from": string; "delay_seconds"?: number; "sandbox"?: boolean; "segment_id"?: string; "enabled"?: boolean }
export interface Automation { "object"?: string; "id"?: string; "name"?: string; "trigger_type"?: string; "audience_id"?: string; "template_id"?: string; "steps"?: { "template_id"?: string; "delay_seconds"?: number }[]; "from"?: string; "delay_seconds"?: number; "sandbox"?: boolean; "segment_id"?: string; "enabled"?: boolean }
export interface SegmentFilter { "status"?: "subscribed" | "unsubscribed" | "cleaned"; "created_after"?: string; "data"?: Record<string, unknown>; "label"?: string }
export interface SegmentRequest { "name": string; "filter": SegmentFilter }
export interface Segment { "object"?: string; "id"?: string; "name"?: string; "filter"?: SegmentFilter; "created_at"?: string }

export class InboxVision {
  private readonly apiKey: string;
  private readonly baseUrl: string;
  constructor(options: InboxVisionOptions) {
    this.apiKey = options.apiKey;
    this.baseUrl = (options.baseUrl ?? "https://inbox.vision").replace(/\/$/, "");
  }

  private async request<T>(method: string, path: string, opts: { query?: Record<string, string | number | boolean>; body?: unknown } = {}): Promise<T> {
    const url = new URL(this.baseUrl + path);
    if (opts.query) for (const [k, v] of Object.entries(opts.query)) if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
    const headers: Record<string, string> = { authorization: "Bearer " + this.apiKey };
    if (opts.body !== undefined) headers["content-type"] = "application/json";
    const res = await fetch(url.toString(), { method, headers, ...(opts.body !== undefined ? { body: JSON.stringify(opts.body) } : {}) });
    if (!res.ok) throw new Error("inbox.vision API " + res.status + ": " + (await res.text().catch(() => res.statusText)));
    return (await res.json()) as T;
  }

  /** Health check (GET /health) */
  getHealth(): Promise<unknown> {
    return this.request<unknown>("GET", "/health");
  }
  /** Create an account (self-serve signup) (POST /accounts) */
  postAccounts(body: SignupRequest): Promise<Account> {
    return this.request<Account>("POST", "/accounts", { body });
  }
  /** List recent emails (GET /emails) */
  getEmails(): Promise<unknown> {
    return this.request<unknown>("GET", "/emails");
  }
  /** Send an email (POST /emails) */
  postEmails(body: SendEmailRequest): Promise<SendEmailResponse> {
    return this.request<SendEmailResponse>("POST", "/emails", { body });
  }
  /** Send a batch of emails (max 100) (POST /emails/batch) */
  postEmailsBatch(body: SendEmailRequest[]): Promise<unknown> {
    return this.request<unknown>("POST", "/emails/batch", { body });
  }
  /** Retrieve an email (GET /emails/{id}) */
  getEmailsById(id: string): Promise<Email> {
    return this.request<Email>("GET", "/emails/" + encodeURIComponent(id));
  }
  /** Cancel a scheduled/queued email (POST /emails/{id}/cancel) */
  postEmailsByIdCancel(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/emails/" + encodeURIComponent(id) + "/cancel");
  }
  /** List domains (GET /domains) */
  getDomains(): Promise<unknown> {
    return this.request<unknown>("GET", "/domains");
  }
  /** Add a sending domain (returns DKIM/SPF/DMARC records) (POST /domains) */
  postDomains(body: AddDomainRequest): Promise<Domain> {
    return this.request<Domain>("POST", "/domains", { body });
  }
  /** Get a domain + its DNS records (GET /domains/{id}) */
  getDomainsById(id: string): Promise<Domain> {
    return this.request<Domain>("GET", "/domains/" + encodeURIComponent(id));
  }
  /** Delete a domain (DELETE /domains/{id}) */
  deleteDomainsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/domains/" + encodeURIComponent(id));
  }
  /** Verify DNS records over DoH (POST /domains/{id}/verify) */
  postDomainsByIdVerify(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/domains/" + encodeURIComponent(id) + "/verify");
  }
  /** List API keys (no secrets) (GET /api-keys) */
  getApiKeys(): Promise<unknown> {
    return this.request<unknown>("GET", "/api-keys");
  }
  /** Create a scoped API key (POST /api-keys) */
  postApiKeys(body: CreateKeyRequest): Promise<unknown> {
    return this.request<unknown>("POST", "/api-keys", { body });
  }
  /** Revoke an API key (POST /api-keys/{id}/revoke) */
  postApiKeysByIdRevoke(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/api-keys/" + encodeURIComponent(id) + "/revoke");
  }
  /** List webhook endpoints (GET /webhooks) */
  getWebhooks(): Promise<unknown> {
    return this.request<unknown>("GET", "/webhooks");
  }
  /** Create a webhook endpoint (Svix-signed) (POST /webhooks) */
  postWebhooks(body: CreateWebhookRequest): Promise<unknown> {
    return this.request<unknown>("POST", "/webhooks", { body });
  }
  /** Get endpoint + recent deliveries (GET /webhooks/{id}) */
  getWebhooksById(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/webhooks/" + encodeURIComponent(id));
  }
  /** Delete endpoint (DELETE /webhooks/{id}) */
  deleteWebhooksById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/webhooks/" + encodeURIComponent(id));
  }
  /** Rotate the signing secret (POST /webhooks/{id}/rotate-secret) */
  postWebhooksByIdRotateSecret(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/webhooks/" + encodeURIComponent(id) + "/rotate-secret");
  }
  /** Send a test event to the endpoint (POST /webhooks/{id}/test) */
  postWebhooksByIdTest(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/webhooks/" + encodeURIComponent(id) + "/test");
  }
  /** List suppressed addresses (GET /suppressions) */
  getSuppressions(): Promise<unknown> {
    return this.request<unknown>("GET", "/suppressions");
  }
  /** Suppress an address (POST /suppressions) */
  postSuppressions(body: SuppressRequest): Promise<unknown> {
    return this.request<unknown>("POST", "/suppressions", { body });
  }
  /** Remove a suppression (DELETE /suppressions/{email}) */
  deleteSuppressionsByEmail(email: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/suppressions/" + encodeURIComponent(email));
  }
  /** List templates (GET /templates) */
  getTemplates(): Promise<unknown> {
    return this.request<unknown>("GET", "/templates");
  }
  /** Create a template (POST /templates) */
  postTemplates(body: TemplateRequest): Promise<Template> {
    return this.request<Template>("POST", "/templates", { body });
  }
  /** Get a template (GET /templates/{id}) */
  getTemplatesById(id: string): Promise<Template> {
    return this.request<Template>("GET", "/templates/" + encodeURIComponent(id));
  }
  /** Update a template (PATCH /templates/{id}) */
  patchTemplatesById(id: string, body: TemplateRequest): Promise<Template> {
    return this.request<Template>("PATCH", "/templates/" + encodeURIComponent(id), { body });
  }
  /** Delete a template (DELETE /templates/{id}) */
  deleteTemplatesById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/templates/" + encodeURIComponent(id));
  }
  /** List or search contacts (GET /contacts) */
  getContacts(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/contacts", { query });
  }
  /** Create or update a contact (by email) (POST /contacts) */
  postContacts(body: ContactRequest): Promise<Contact> {
    return this.request<Contact>("POST", "/contacts", { body });
  }
  /** Bulk-import contacts from CSV (POST /contacts/import) */
  postContactsImport(body: { "csv": string }): Promise<unknown> {
    return this.request<unknown>("POST", "/contacts/import", { body });
  }
  /** Export the contact directory as a CSV download (email, first_name, last_name, status, created_at; up to 5000, newest first) (GET /contacts/export.csv) */
  getContactsExportCsv(): Promise<unknown> {
    return this.request<unknown>("GET", "/contacts/export.csv");
  }
  /** Get a contact (GET /contacts/{id}) */
  getContactsById(id: string): Promise<Contact> {
    return this.request<Contact>("GET", "/contacts/" + encodeURIComponent(id));
  }
  /** Update a contact (PATCH /contacts/{id}) */
  patchContactsById(id: string): Promise<Contact> {
    return this.request<Contact>("PATCH", "/contacts/" + encodeURIComponent(id));
  }
  /** Delete a contact (DELETE /contacts/{id}) */
  deleteContactsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/contacts/" + encodeURIComponent(id));
  }
  /** The contact's conversation history + activity summary (CRM) (GET /contacts/{id}/conversations) */
  getContactsByIdConversations(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/contacts/" + encodeURIComponent(id) + "/conversations");
  }
  /** Set a contact's labels (CRM segmentation — names auto-create) (POST /contacts/{id}/labels) */
  postContactsByIdLabels(id: string, body: { "labels": string[] }): Promise<{ "object"?: string; "id"?: string; "labels"?: string[] }> {
    return this.request<{ "object"?: string; "id"?: string; "labels"?: string[] }>("POST", "/contacts/" + encodeURIComponent(id) + "/labels", { body });
  }
  /** List the contact's internal notes (GET /contacts/{id}/notes) */
  getContactsByIdNotes(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/contacts/" + encodeURIComponent(id) + "/notes");
  }
  /** Add an internal note about the contact (POST /contacts/{id}/notes) */
  postContactsByIdNotes(id: string, body: { "content": string; "author_id"?: string }): Promise<unknown> {
    return this.request<unknown>("POST", "/contacts/" + encodeURIComponent(id) + "/notes", { body });
  }
  /** Delete a contact note (DELETE /contacts/{id}/notes/{noteId}) */
  deleteContactsByIdNotesByNoteId(id: string, noteId: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/contacts/" + encodeURIComponent(id) + "/notes/" + encodeURIComponent(noteId));
  }
  /** Merge another contact INTO this one (unified identity) — reassigns all its data, deletes the source, writes an audit (POST /contacts/{id}/merge) */
  postContactsByIdMerge(id: string, body: { "source_id": string }): Promise<unknown> {
    return this.request<unknown>("POST", "/contacts/" + encodeURIComponent(id) + "/merge", { body });
  }
  /** Audit trail of merges folded INTO this contact (GET /contacts/{id}/merges) */
  getContactsByIdMerges(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/contacts/" + encodeURIComponent(id) + "/merges");
  }
  /** Reverse a merge — re-create the source contact + move its records back (POST /contacts/{id}/unmerge) */
  postContactsByIdUnmerge(id: string, body: { "merge_id": string }): Promise<unknown> {
    return this.request<unknown>("POST", "/contacts/" + encodeURIComponent(id) + "/unmerge", { body });
  }
  /** Block a contact (abuse) — their inbound is silently dropped across every public path (live-chat widget / API channel / inbound email), never threaded or broadcast. Orthogonal to subscription status. Full access required. (POST /contacts/{id}/block) */
  postContactsByIdBlock(id: string): Promise<Contact> {
    return this.request<Contact>("POST", "/contacts/" + encodeURIComponent(id) + "/block");
  }
  /** Unblock a contact — their inbound threads into the shared inbox normally again. (POST /contacts/{id}/unblock) */
  postContactsByIdUnblock(id: string): Promise<Contact> {
    return this.request<Contact>("POST", "/contacts/" + encodeURIComponent(id) + "/unblock");
  }
  /** List audiences (with member counts) (GET /audiences) */
  getAudiences(): Promise<unknown> {
    return this.request<unknown>("GET", "/audiences");
  }
  /** Create an audience (POST /audiences) */
  postAudiences(body: { "name": string }): Promise<Audience> {
    return this.request<Audience>("POST", "/audiences", { body });
  }
  /** Get an audience (GET /audiences/{id}) */
  getAudiencesById(id: string): Promise<Audience> {
    return this.request<Audience>("GET", "/audiences/" + encodeURIComponent(id));
  }
  /** Delete an audience (DELETE /audiences/{id}) */
  deleteAudiencesById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/audiences/" + encodeURIComponent(id));
  }
  /** List members (GET /audiences/{id}/members) */
  getAudiencesByIdMembers(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/audiences/" + encodeURIComponent(id) + "/members");
  }
  /** Add a member (email or contact_id) (POST /audiences/{id}/members) */
  postAudiencesByIdMembers(id: string, body: { "email"?: string; "contact_id"?: string }): Promise<unknown> {
    return this.request<unknown>("POST", "/audiences/" + encodeURIComponent(id) + "/members", { body });
  }
  /** Remove a member (DELETE /audiences/{id}/members/{contactId}) */
  deleteAudiencesByIdMembersByContactId(id: string, contactId: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/audiences/" + encodeURIComponent(id) + "/members/" + encodeURIComponent(contactId));
  }
  /** List campaigns (GET /campaigns) */
  getCampaigns(): Promise<unknown> {
    return this.request<unknown>("GET", "/campaigns");
  }
  /** Create a campaign (draft) (POST /campaigns) */
  postCampaigns(body: CampaignRequest): Promise<Campaign> {
    return this.request<Campaign>("POST", "/campaigns", { body });
  }
  /** Get a campaign (GET /campaigns/{id}) */
  getCampaignsById(id: string): Promise<Campaign> {
    return this.request<Campaign>("GET", "/campaigns/" + encodeURIComponent(id));
  }
  /** Delete a campaign (DELETE /campaigns/{id}) */
  deleteCampaignsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/campaigns/" + encodeURIComponent(id));
  }
  /** Per-recipient delivery status (GET /campaigns/{id}/recipients) */
  getCampaignsByIdRecipients(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/campaigns/" + encodeURIComponent(id) + "/recipients");
  }
  /** Send a campaign to its audience (POST /campaigns/{id}/send) */
  postCampaignsByIdSend(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/campaigns/" + encodeURIComponent(id) + "/send");
  }
  /** Cancel a draft campaign (POST /campaigns/{id}/cancel) */
  postCampaignsByIdCancel(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/campaigns/" + encodeURIComponent(id) + "/cancel");
  }
  /** List automations (GET /automations) */
  getAutomations(): Promise<unknown> {
    return this.request<unknown>("GET", "/automations");
  }
  /** Create an automation (event-triggered sequence) (POST /automations) */
  postAutomations(body: AutomationRequest): Promise<Automation> {
    return this.request<Automation>("POST", "/automations", { body });
  }
  /** Get an automation (GET /automations/{id}) */
  getAutomationsById(id: string): Promise<Automation> {
    return this.request<Automation>("GET", "/automations/" + encodeURIComponent(id));
  }
  /** Delete an automation (DELETE /automations/{id}) */
  deleteAutomationsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/automations/" + encodeURIComponent(id));
  }
  /** List enrollments (contacts entered into the automation) (GET /automations/{id}/enrollments) */
  getAutomationsByIdEnrollments(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/automations/" + encodeURIComponent(id) + "/enrollments");
  }
  /** List segments (GET /segments) */
  getSegments(): Promise<unknown> {
    return this.request<unknown>("GET", "/segments");
  }
  /** Create a saved contact segment (filter) (POST /segments) */
  postSegments(body: SegmentRequest): Promise<Segment> {
    return this.request<Segment>("POST", "/segments", { body });
  }
  /** Get a segment (GET /segments/{id}) */
  getSegmentsById(id: string): Promise<Segment> {
    return this.request<Segment>("GET", "/segments/" + encodeURIComponent(id));
  }
  /** Delete a segment (DELETE /segments/{id}) */
  deleteSegmentsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/segments/" + encodeURIComponent(id));
  }
  /** Preview the contacts currently matching the segment (+ total count) (GET /segments/{id}/contacts) */
  getSegmentsByIdContacts(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/segments/" + encodeURIComponent(id) + "/contacts");
  }
  /** Deliverability metrics + rates (GET /analytics) */
  getAnalytics(query?: Record<string, string | number | boolean>): Promise<Analytics> {
    return this.request<Analytics>("GET", "/analytics", { query });
  }
  /** Daily event buckets (GET /analytics/timeseries) */
  getAnalyticsTimeseries(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/analytics/timeseries", { query });
  }
  /** Sender-reputation dashboard — bounce/complaint rates + SES-threshold status, per domain + account (GET /deliverability) */
  getDeliverability(query?: Record<string, string | number | boolean>): Promise<Deliverability> {
    return this.request<Deliverability>("GET", "/deliverability", { query });
  }
  /** List or search conversations (GET /conversations) */
  getConversations(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/conversations", { query });
  }
  /** Open a conversation with a contact (shared inbox) (POST /conversations) */
  postConversations(body: ConversationRequest): Promise<Conversation> {
    return this.request<Conversation>("POST", "/conversations", { body });
  }
  /** Bulk-apply triage actions to many conversations (POST /conversations/bulk) */
  postConversationsBulk(body: { "conversation_ids": string[]; "actions": MacroAction[] }): Promise<{ "object"?: string; "updated"?: number; "skipped"?: string[] }> {
    return this.request<{ "object"?: string; "updated"?: number; "skipped"?: string[] }>("POST", "/conversations/bulk", { body });
  }
  /** Inbox queue-depth counts (GET /conversations/counts) */
  getConversationsCounts(query?: Record<string, string | number | boolean>): Promise<{ "object"?: string; "total"?: number; "open"?: number; "pending"?: number; "resolved"?: number; "snoozed"?: number; "unassigned_open"?: number; "assignee_open"?: number | null; "unread"?: number | null }> {
    return this.request<{ "object"?: string; "total"?: number; "open"?: number; "pending"?: number; "resolved"?: number; "snoozed"?: number; "unassigned_open"?: number; "assignee_open"?: number | null; "unread"?: number | null }>("GET", "/conversations/counts", { query });
  }
  /** Get a conversation + its message thread (each message carries its inline `attachments[]` — id, filename, content_type, size_bytes, authed download_url) (GET /conversations/{id}) */
  getConversationsById(id: string): Promise<Conversation> {
    return this.request<Conversation>("GET", "/conversations/" + encodeURIComponent(id));
  }
  /** Update status / assignee / priority (PATCH /conversations/{id}) */
  patchConversationsById(id: string, body: ConversationPatch): Promise<Conversation> {
    return this.request<Conversation>("PATCH", "/conversations/" + encodeURIComponent(id), { body });
  }
  /** Reply to a conversation or add a private note (POST /conversations/{id}/messages) */
  postConversationsByIdMessages(id: string, body: ReplyRequest): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/messages", { body });
  }
  /** Mark a conversation read (read-on-open) (POST /conversations/{id}/read) */
  postConversationsByIdRead(id: string): Promise<{ "object"?: string; "conversation_id"?: string; "read"?: boolean }> {
    return this.request<{ "object"?: string; "conversation_id"?: string; "read"?: boolean }>("POST", "/conversations/" + encodeURIComponent(id) + "/read");
  }
  /** List pending scheduled ("send later") replies (GET /conversations/{id}/scheduled) */
  getConversationsByIdScheduled(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/conversations/" + encodeURIComponent(id) + "/scheduled");
  }
  /** Cancel a scheduled reply (DELETE /conversations/{id}/scheduled/{sid}) */
  deleteConversationsByIdScheduledBySid(id: string, sid: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/conversations/" + encodeURIComponent(id) + "/scheduled/" + encodeURIComponent(sid));
  }
  /** List all pending scheduled replies (the "Scheduled" folder) (GET /scheduled-replies) */
  getScheduledReplies(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/scheduled-replies", { query });
  }
  /** Set the conversation's labels (names auto-create) (POST /conversations/{id}/labels) */
  postConversationsByIdLabels(id: string, body: ConversationLabels): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/labels", { body });
  }
  /** Assign a conversation to a team (POST /conversations/{id}/team) */
  postConversationsByIdTeam(id: string, body: ConversationTeam): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/team", { body });
  }
  /** List agents (GET /agents) */
  getAgents(): Promise<unknown> {
    return this.request<unknown>("GET", "/agents");
  }
  /** Add an agent to the team (POST /agents) */
  postAgents(body: AgentRequest): Promise<Agent> {
    return this.request<Agent>("POST", "/agents", { body });
  }
  /** Get an agent (GET /agents/{id}) */
  getAgentsById(id: string): Promise<Agent> {
    return this.request<Agent>("GET", "/agents/" + encodeURIComponent(id));
  }
  /** Update agent name / role / status (PATCH /agents/{id}) */
  patchAgentsById(id: string): Promise<Agent> {
    return this.request<Agent>("PATCH", "/agents/" + encodeURIComponent(id));
  }
  /** Remove an agent (DELETE /agents/{id}) */
  deleteAgentsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/agents/" + encodeURIComponent(id));
  }
  /** Set/reset an agent's login password (full-access) (POST /agents/{id}/password) */
  postAgentsByIdPassword(id: string, body: { "password": string }): Promise<unknown> {
    return this.request<unknown>("POST", "/agents/" + encodeURIComponent(id) + "/password", { body });
  }
  /** PUBLIC — agent login (email + password[, workspace]) → a session token (POST /agent/login) */
  postAgentLogin(body: { "email": string; "password": string; "workspace"?: string }): Promise<unknown> {
    return this.request<unknown>("POST", "/agent/login", { body });
  }
  /** The logged-in agent (agent-session auth) (GET /agent/me) */
  getAgentMe(): Promise<Agent> {
    return this.request<Agent>("GET", "/agent/me");
  }
  /** Revoke the current agent session (POST /agent/logout) */
  postAgentLogout(): Promise<unknown> {
    return this.request<unknown>("POST", "/agent/logout");
  }
  /** List the tenant's OAuth apps (no secrets) (GET /oauth/apps) */
  getOauthApps(): Promise<unknown> {
    return this.request<unknown>("GET", "/oauth/apps");
  }
  /** Register a third-party OAuth app (tenant-admin) — client_secret returned once (POST /oauth/apps) */
  postOauthApps(body: { "name": string; "redirect_uris": string[]; "scopes": string[] }): Promise<unknown> {
    return this.request<unknown>("POST", "/oauth/apps", { body });
  }
  /** Get an OAuth app (no secret) (GET /oauth/apps/{id}) */
  getOauthAppsById(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/oauth/apps/" + encodeURIComponent(id));
  }
  /** Delete an OAuth app (tenant-admin) (DELETE /oauth/apps/{id}) */
  deleteOauthAppsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/oauth/apps/" + encodeURIComponent(id));
  }
  /** OAuth 2.0 authorize — resource-owner (agent session) consents → 302 with a single-use code (GET /oauth/authorize) */
  getOauthAuthorize(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/oauth/authorize", { query });
  }
  /** PUBLIC — OAuth 2.0 token exchange (authorization_code) → scoped access token (POST /oauth/token) */
  postOauthToken(): Promise<unknown> {
    return this.request<unknown>("POST", "/oauth/token");
  }
  /** The tenant's immutable security-audit trail (full-access) (GET /audit-log) */
  getAuditLog(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/audit-log", { query });
  }
  /** List labels (GET /labels) */
  getLabels(): Promise<unknown> {
    return this.request<unknown>("GET", "/labels");
  }
  /** Create a label (POST /labels) */
  postLabels(body: LabelRequest): Promise<Label> {
    return this.request<Label>("POST", "/labels", { body });
  }
  /** Update a label (rename and/or recolor) (PATCH /labels/{id}) */
  patchLabelsById(id: string, body: { "name"?: string; "color"?: string }): Promise<Label> {
    return this.request<Label>("PATCH", "/labels/" + encodeURIComponent(id), { body });
  }
  /** Delete a label (DELETE /labels/{id}) */
  deleteLabelsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/labels/" + encodeURIComponent(id));
  }
  /** List the agent's saved inbox views (GET /conversation-views) */
  getConversationViews(): Promise<unknown> {
    return this.request<unknown>("GET", "/conversation-views");
  }
  /** Save a named inbox view (per-agent filter set) (POST /conversation-views) */
  postConversationViews(body: ConversationViewRequest): Promise<ConversationView> {
    return this.request<ConversationView>("POST", "/conversation-views", { body });
  }
  /** Delete one of the agent's saved views (DELETE /conversation-views/{id}) */
  deleteConversationViewsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/conversation-views/" + encodeURIComponent(id));
  }
  /** List teams (GET /teams) */
  getTeams(): Promise<unknown> {
    return this.request<unknown>("GET", "/teams");
  }
  /** Create a team (groups agents for routing) (POST /teams) */
  postTeams(body: TeamRequest): Promise<Team> {
    return this.request<Team>("POST", "/teams", { body });
  }
  /** Get a team + its members (GET /teams/{id}) */
  getTeamsById(id: string): Promise<Team> {
    return this.request<Team>("GET", "/teams/" + encodeURIComponent(id));
  }
  /** Update a team's name / auto-assign (PATCH /teams/{id}) */
  patchTeamsById(id: string, body: TeamRequest): Promise<Team> {
    return this.request<Team>("PATCH", "/teams/" + encodeURIComponent(id), { body });
  }
  /** Delete a team (DELETE /teams/{id}) */
  deleteTeamsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/teams/" + encodeURIComponent(id));
  }
  /** Add an agent to the team (POST /teams/{id}/members) */
  postTeamsByIdMembers(id: string, body: TeamMemberRequest): Promise<unknown> {
    return this.request<unknown>("POST", "/teams/" + encodeURIComponent(id) + "/members", { body });
  }
  /** Remove an agent from the team (DELETE /teams/{id}/members/{agentId}) */
  deleteTeamsByIdMembersByAgentId(id: string, agentId: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/teams/" + encodeURIComponent(id) + "/members/" + encodeURIComponent(agentId));
  }
  /** List canned responses (?q= short-code prefix for autocomplete) (GET /canned-responses) */
  getCannedResponses(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/canned-responses", { query });
  }
  /** Create a canned response (saved reply snippet) (POST /canned-responses) */
  postCannedResponses(body: CannedResponseRequest): Promise<CannedResponse> {
    return this.request<CannedResponse>("POST", "/canned-responses", { body });
  }
  /** Get a canned response (GET /canned-responses/{id}) */
  getCannedResponsesById(id: string): Promise<CannedResponse> {
    return this.request<CannedResponse>("GET", "/canned-responses/" + encodeURIComponent(id));
  }
  /** Update a canned response (PATCH /canned-responses/{id}) */
  patchCannedResponsesById(id: string, body: CannedResponseRequest): Promise<CannedResponse> {
    return this.request<CannedResponse>("PATCH", "/canned-responses/" + encodeURIComponent(id), { body });
  }
  /** Delete a canned response (DELETE /canned-responses/{id}) */
  deleteCannedResponsesById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/canned-responses/" + encodeURIComponent(id));
  }
  /** List an agent's @mentions (newest first) (GET /mentions) */
  getMentions(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/mentions", { query });
  }
  /** Mark a mention read (POST /mentions/{id}/read) */
  postMentionsByIdRead(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/mentions/" + encodeURIComponent(id) + "/read");
  }
  /** Get the conversation's CSAT response (rating null if none) (GET /conversations/{id}/csat) */
  getConversationsByIdCsat(id: string): Promise<CsatResponse> {
    return this.request<CsatResponse>("GET", "/conversations/" + encodeURIComponent(id) + "/csat");
  }
  /** Record the conversation's CSAT rating (resolved only) (POST /conversations/{id}/csat) */
  postConversationsByIdCsat(id: string, body: CsatRequest): Promise<CsatResponse> {
    return this.request<CsatResponse>("POST", "/conversations/" + encodeURIComponent(id) + "/csat", { body });
  }
  /** Tenant satisfaction summary (average, distribution, satisfied %) (GET /csat) */
  getCsat(): Promise<CsatSummary> {
    return this.request<CsatSummary>("GET", "/csat");
  }
  /** Recent CSAT responses (newest first) (GET /csat/responses) */
  getCsatResponses(): Promise<unknown> {
    return this.request<unknown>("GET", "/csat/responses");
  }
  /** Team-lead overview: conversation volume, messages, CSAT, per-agent load (GET /reports/overview) */
  getReportsOverview(query?: Record<string, string | number | boolean>): Promise<Report> {
    return this.request<Report>("GET", "/reports/overview", { query });
  }
  /** Daily time-series for a metric (zero-filled) (GET /reports/timeseries) */
  getReportsTimeseries(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/reports/timeseries", { query });
  }
  /** Average CSAT rating per day (satisfaction trend) (GET /reports/csat-trend) */
  getReportsCsatTrend(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/reports/csat-trend", { query });
  }
  /** Average time-to-first-response per day (speed trend) (GET /reports/response-time-trend) */
  getReportsResponseTimeTrend(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/reports/response-time-trend", { query });
  }
  /** SLA compliance rollup (met/pending/missed/n-a per target) over conversations with a policy (GET /reports/sla) */
  getReportsSla(): Promise<unknown> {
    return this.request<unknown>("GET", "/reports/sla");
  }
  /** Download CSAT responses as CSV (GET /reports/csat.csv) */
  getReportsCsatCsv(): Promise<unknown> {
    return this.request<unknown>("GET", "/reports/csat.csv");
  }
  /** Download conversations as CSV (id, subject, status, priority, channel, contact_id, assignee_id, team_id, created_at, last_message_at, resolved_at + human-readable contact_email, assignee_name, team_name, labels, sentiment, first_response_at; up to 5000, newest first). (GET /reports/conversations.csv) */
  getReportsConversationsCsv(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/reports/conversations.csv", { query });
  }
  /** List the tenant's API channels (never the token, only its display prefix) (GET /channels) */
  getChannels(): Promise<unknown> {
    return this.request<unknown>("GET", "/channels");
  }
  /** Create an API channel — returns a scoped inbound token (shown ONCE) (POST /channels) */
  postChannels(body: { "name": string }): Promise<unknown> {
    return this.request<unknown>("POST", "/channels", { body });
  }
  /** Revoke an API channel — its token stops working immediately (DELETE /channels/{id}) */
  deleteChannelsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/channels/" + encodeURIComponent(id));
  }
  /** PUBLIC — push an inbound customer message into the shared inbox (POST /channels/inbound) */
  postChannelsInbound(body: { "identifier": string; "content": string; "email"?: string; "name"?: string; "subject"?: string }): Promise<unknown> {
    return this.request<unknown>("POST", "/channels/inbound", { body });
  }
  /** List widget inboxes (GET /widgets) */
  getWidgets(): Promise<unknown> {
    return this.request<unknown>("GET", "/widgets");
  }
  /** Create a website live-chat widget inbox (returns the public widget_token) (POST /widgets) */
  postWidgets(body: WidgetInboxRequest): Promise<WidgetInbox> {
    return this.request<WidgetInbox>("POST", "/widgets", { body });
  }
  /** Get a widget inbox (GET /widgets/{id}) */
  getWidgetsById(id: string): Promise<WidgetInbox> {
    return this.request<WidgetInbox>("GET", "/widgets/" + encodeURIComponent(id));
  }
  /** Update a widget inbox (name, welcome, proactive greeting) (PATCH /widgets/{id}) */
  patchWidgetsById(id: string, body: { "name"?: string; "welcome_message"?: string | null; "proactive_message"?: string | null; "proactive_trigger_seconds"?: number; "proactive_enabled"?: boolean }): Promise<WidgetInbox> {
    return this.request<WidgetInbox>("PATCH", "/widgets/" + encodeURIComponent(id), { body });
  }
  /** Delete a widget inbox (DELETE /widgets/{id}) */
  deleteWidgetsById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/widgets/" + encodeURIComponent(id));
  }
  /** PUBLIC — start a visitor session + conversation (POST /widget/{token}/contact) */
  postWidgetByTokenContact(token: string, body: WidgetContactRequest): Promise<WidgetSession> {
    return this.request<WidgetSession>("POST", "/widget/" + encodeURIComponent(token) + "/contact", { body });
  }
  /** PUBLIC — visitor reads the thread (private notes excluded) (GET /widget/{token}/messages) */
  getWidgetByTokenMessages(token: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/widget/" + encodeURIComponent(token) + "/messages", { query });
  }
  /** PUBLIC — visitor posts a message (POST /widget/{token}/messages) */
  postWidgetByTokenMessages(token: string, body: WidgetMessageRequest): Promise<unknown> {
    return this.request<unknown>("POST", "/widget/" + encodeURIComponent(token) + "/messages", { body });
  }
  /** PUBLIC — visitor acks they SAW the thread (read receipt) (POST /widget/{token}/read) */
  postWidgetByTokenRead(token: string, body: { "session_token": string }): Promise<{ "object"?: string; "conversation_id"?: string; "read"?: boolean }> {
    return this.request<{ "object"?: string; "conversation_id"?: string; "read"?: boolean }>("POST", "/widget/" + encodeURIComponent(token) + "/read", { body });
  }
  /** PUBLIC — list the session's attachments (visitor-safe, with session-scoped download URLs) (GET /widget/{token}/attachments) */
  getWidgetByTokenAttachments(token: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/widget/" + encodeURIComponent(token) + "/attachments", { query });
  }
  /** PUBLIC — visitor uploads a file (raw body) into their conversation (POST /widget/{token}/attachments) */
  postWidgetByTokenAttachments(token: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("POST", "/widget/" + encodeURIComponent(token) + "/attachments", { query });
  }
  /** PUBLIC — session-scoped download (404 if not on the session's conversation) (GET /widget/{token}/attachments/{attId}) */
  getWidgetByTokenAttachmentsByAttId(token: string, attId: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/widget/" + encodeURIComponent(token) + "/attachments/" + encodeURIComponent(attId), { query });
  }
  /** PUBLIC — standalone preview page embedding the live-chat widget (GET /widget/{token}/demo) */
  getWidgetByTokenDemo(token: string): Promise<unknown> {
    return this.request<unknown>("GET", "/widget/" + encodeURIComponent(token) + "/demo");
  }
  /** PUBLIC — widget config (name, welcome, proactive greeting) the embed script loads (GET /widget/{token}/config) */
  getWidgetByTokenConfig(token: string): Promise<unknown> {
    return this.request<unknown>("GET", "/widget/" + encodeURIComponent(token) + "/config");
  }
  /** PUBLIC — visitor WebSocket for live conversation events (session-scoped) (GET /widget/{token}/ws) */
  getWidgetByTokenWs(token: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/widget/" + encodeURIComponent(token) + "/ws", { query });
  }
  /** PUBLIC — the embeddable chat widget script (<script src=…/widget.js data-inbox-widget=TOKEN>) (GET /widget.js) */
  getWidgetJs(): Promise<unknown> {
    return this.request<unknown>("GET", "/widget.js");
  }
  /** List macros (GET /macros) */
  getMacros(): Promise<unknown> {
    return this.request<unknown>("GET", "/macros");
  }
  /** Create a macro (ordered action sequence) (POST /macros) */
  postMacros(body: MacroRequest): Promise<Macro> {
    return this.request<Macro>("POST", "/macros", { body });
  }
  /** Get a macro (GET /macros/{id}) */
  getMacrosById(id: string): Promise<Macro> {
    return this.request<Macro>("GET", "/macros/" + encodeURIComponent(id));
  }
  /** Update a macro's name / actions (PATCH /macros/{id}) */
  patchMacrosById(id: string, body: MacroRequest): Promise<Macro> {
    return this.request<Macro>("PATCH", "/macros/" + encodeURIComponent(id), { body });
  }
  /** Delete a macro (DELETE /macros/{id}) */
  deleteMacrosById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/macros/" + encodeURIComponent(id));
  }
  /** Run a macro against a conversation (applies its action sequence) (POST /conversations/{id}/run-macro) */
  postConversationsByIdRunMacro(id: string, body: { "macro_id": string }): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/run-macro", { body });
  }
  /** List automation rules (GET /automation-rules) */
  getAutomationRules(): Promise<unknown> {
    return this.request<unknown>("GET", "/automation-rules");
  }
  /** Create an automation rule (event + conditions + actions) (POST /automation-rules) */
  postAutomationRules(body: AutomationRuleRequest): Promise<AutomationRule> {
    return this.request<AutomationRule>("POST", "/automation-rules", { body });
  }
  /** Get an automation rule (GET /automation-rules/{id}) */
  getAutomationRulesById(id: string): Promise<AutomationRule> {
    return this.request<AutomationRule>("GET", "/automation-rules/" + encodeURIComponent(id));
  }
  /** Update a rule (name / enabled / conditions / actions) (PATCH /automation-rules/{id}) */
  patchAutomationRulesById(id: string, body: AutomationRuleRequest): Promise<AutomationRule> {
    return this.request<AutomationRule>("PATCH", "/automation-rules/" + encodeURIComponent(id), { body });
  }
  /** Delete an automation rule (DELETE /automation-rules/{id}) */
  deleteAutomationRulesById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/automation-rules/" + encodeURIComponent(id));
  }
  /** List help portals (GET /help/portals) */
  getHelpPortals(): Promise<unknown> {
    return this.request<unknown>("GET", "/help/portals");
  }
  /** Create a help portal (returns its public portal_token) (POST /help/portals) */
  postHelpPortals(body: HelpPortalRequest): Promise<HelpPortal> {
    return this.request<HelpPortal>("POST", "/help/portals", { body });
  }
  /** List a portal's articles (GET /help/articles) */
  getHelpArticles(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/help/articles", { query });
  }
  /** Create a knowledge-base article (draft or published) (POST /help/articles) */
  postHelpArticles(body: HelpArticleRequest): Promise<HelpArticle> {
    return this.request<HelpArticle>("POST", "/help/articles", { body });
  }
  /** Get an article (GET /help/articles/{id}) */
  getHelpArticlesById(id: string): Promise<HelpArticle> {
    return this.request<HelpArticle>("GET", "/help/articles/" + encodeURIComponent(id));
  }
  /** Update / publish an article (set/clear category via category_id) (PATCH /help/articles/{id}) */
  patchHelpArticlesById(id: string, body: { "title"?: string; "content"?: string; "status"?: "draft" | "published"; "category_id"?: string | null }): Promise<HelpArticle> {
    return this.request<HelpArticle>("PATCH", "/help/articles/" + encodeURIComponent(id), { body });
  }
  /** Delete an article (DELETE /help/articles/{id}) */
  deleteHelpArticlesById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/help/articles/" + encodeURIComponent(id));
  }
  /** Semantic KB search (Vectorize RAG) over this tenant's published articles (GET /help/kb-search) */
  getHelpKbSearch(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/help/kb-search", { query });
  }
  /** (Re)embed every published article into Vectorize (backfill) (POST /help/reindex) */
  postHelpReindex(): Promise<unknown> {
    return this.request<unknown>("POST", "/help/reindex");
  }
  /** Get the tenant's AI auto-resolve policy (default: disabled @ 75%) (GET /ai/policy) */
  getAiPolicy(): Promise<unknown> {
    return this.request<unknown>("GET", "/ai/policy");
  }
  /** Set the AI auto-resolve opt-in + confidence floor (full-access; §66 gate) (PUT /ai/policy) */
  putAiPolicy(body: { "autoresolve_enabled": boolean; "min_confidence_pct": number }): Promise<unknown> {
    return this.request<unknown>("PUT", "/ai/policy", { body });
  }
  /** List a portal's categories (GET /help/categories) */
  getHelpCategories(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/help/categories", { query });
  }
  /** Create a category to organize a portal's articles (POST /help/categories) */
  postHelpCategories(body: HelpCategoryRequest): Promise<HelpCategory> {
    return this.request<HelpCategory>("POST", "/help/categories", { body });
  }
  /** Update a category (name / description / position) (PATCH /help/categories/{id}) */
  patchHelpCategoriesById(id: string, body: { "name"?: string; "description"?: string | null; "position"?: number }): Promise<HelpCategory> {
    return this.request<HelpCategory>("PATCH", "/help/categories/" + encodeURIComponent(id), { body });
  }
  /** Delete a category (its articles are detached, not deleted) (DELETE /help/categories/{id}) */
  deleteHelpCategoriesById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/help/categories/" + encodeURIComponent(id));
  }
  /** PUBLIC — list, search, or filter published articles (GET /hc/{token}/articles) */
  getHcByTokenArticles(token: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/hc/" + encodeURIComponent(token) + "/articles", { query });
  }
  /** PUBLIC — list a portal's categories + published-article counts (GET /hc/{token}/categories) */
  getHcByTokenCategories(token: string): Promise<unknown> {
    return this.request<unknown>("GET", "/hc/" + encodeURIComponent(token) + "/categories");
  }
  /** PUBLIC — read one published article (GET /hc/{token}/articles/{slug}) */
  getHcByTokenArticlesBySlug(token: string, slug: string): Promise<unknown> {
    return this.request<unknown>("GET", "/hc/" + encodeURIComponent(token) + "/articles/" + encodeURIComponent(slug));
  }
  /** PUBLIC — vote whether a published article was helpful (was-this-helpful) (POST /hc/{token}/articles/{slug}/feedback) */
  postHcByTokenArticlesBySlugFeedback(token: string, slug: string, body: { "helpful": boolean }): Promise<{ "object"?: string; "recorded"?: boolean }> {
    return this.request<{ "object"?: string; "recorded"?: boolean }>("POST", "/hc/" + encodeURIComponent(token) + "/articles/" + encodeURIComponent(slug) + "/feedback", { body });
  }
  /** List SLA policies (GET /sla-policies) */
  getSlaPolicies(): Promise<unknown> {
    return this.request<unknown>("GET", "/sla-policies");
  }
  /** Create an SLA policy (first-response + resolution time targets) (POST /sla-policies) */
  postSlaPolicies(body: SlaPolicyRequest): Promise<SlaPolicy> {
    return this.request<SlaPolicy>("POST", "/sla-policies", { body });
  }
  /** Get an SLA policy (GET /sla-policies/{id}) */
  getSlaPoliciesById(id: string): Promise<SlaPolicy> {
    return this.request<SlaPolicy>("GET", "/sla-policies/" + encodeURIComponent(id));
  }
  /** Delete an SLA policy (DELETE /sla-policies/{id}) */
  deleteSlaPoliciesById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/sla-policies/" + encodeURIComponent(id));
  }
  /** List business-hours schedules (GET /business-hours) */
  getBusinessHours(): Promise<unknown> {
    return this.request<unknown>("GET", "/business-hours");
  }
  /** Create a business-hours schedule (weekly open/close in an IANA timezone) (POST /business-hours) */
  postBusinessHours(body: BusinessHoursRequest): Promise<BusinessHours> {
    return this.request<BusinessHours>("POST", "/business-hours", { body });
  }
  /** Next instant the tenant's default schedule OPENS (powers the composer's "Next business hours" send-later preset) (GET /business-hours/next-open) */
  getBusinessHoursNextOpen(query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/business-hours/next-open", { query });
  }
  /** Get a business-hours schedule (GET /business-hours/{id}) */
  getBusinessHoursById(id: string): Promise<BusinessHours> {
    return this.request<BusinessHours>("GET", "/business-hours/" + encodeURIComponent(id));
  }
  /** Update a business-hours schedule (PATCH /business-hours/{id}) */
  patchBusinessHoursById(id: string, body: { "name"?: string; "timezone"?: string; "days"?: BusinessHoursDay[]; "holidays"?: string[] }): Promise<BusinessHours> {
    return this.request<BusinessHours>("PATCH", "/business-hours/" + encodeURIComponent(id), { body });
  }
  /** Delete a business-hours schedule (detached from any SLA policy) (DELETE /business-hours/{id}) */
  deleteBusinessHoursById(id: string): Promise<unknown> {
    return this.request<unknown>("DELETE", "/business-hours/" + encodeURIComponent(id));
  }
  /** Is the schedule open at a given instant (default now)? (GET /business-hours/{id}/status) */
  getBusinessHoursByIdStatus(id: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("GET", "/business-hours/" + encodeURIComponent(id) + "/status", { query });
  }
  /** MCP server (Model Context Protocol, Streamable HTTP, JSON-RPC 2.0) — agent-native tools: list/get conversations, search help articles, suggest a reply, add a private note, reply to a customer, set status (resolve), and assign. Authenticate with a tenant API key as the bearer. (POST /mcp) */
  postMcp(body: { "jsonrpc": "2.0"; "id"?: string | null; "method": string; "params"?: Record<string, unknown> }): Promise<unknown> {
    return this.request<unknown>("POST", "/mcp", { body });
  }
  /** Current SLA status (first-response + resolution: met/pending/missed) (GET /conversations/{id}/sla) */
  getConversationsByIdSla(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/conversations/" + encodeURIComponent(id) + "/sla");
  }
  /** Apply an SLA policy to a conversation (POST /conversations/{id}/sla) */
  postConversationsByIdSla(id: string, body: { "sla_policy_id": string }): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/sla", { body });
  }
  /** AI-draft a reply grounded in the help center (draft only — never sends) (POST /conversations/{id}/suggest-reply) */
  postConversationsByIdSuggestReply(id: string): Promise<ReplySuggestion> {
    return this.request<ReplySuggestion>("POST", "/conversations/" + encodeURIComponent(id) + "/suggest-reply");
  }
  /** AI summary + customer sentiment of the conversation (read-only triage) (POST /conversations/{id}/summary) */
  postConversationsByIdSummary(id: string): Promise<ConversationSummary> {
    return this.request<ConversationSummary>("POST", "/conversations/" + encodeURIComponent(id) + "/summary");
  }
  /** AI rewrite-assist — transform the agent's OWN draft (formal/friendly/concise/expand/grammar/translate); draft only — never sends (POST /conversations/{id}/rewrite-draft) */
  postConversationsByIdRewriteDraft(id: string, body: { "draft": string; "mode": "formal" | "friendly" | "concise" | "expand" | "grammar" | "translate"; "target_lang"?: string }): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/rewrite-draft", { body });
  }
  /** AI resolution RECOMMENDATION — draft + confidence + auto_resolve|handoff per tenant policy (never sends) (POST /conversations/{id}/ai-resolve) */
  postConversationsByIdAiResolve(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/ai-resolve");
  }
  /** ACT on the AI resolution — append the reply + resolve, ONLY when auto_resolve is eligible (POST /conversations/{id}/ai-resolve/execute) */
  postConversationsByIdAiResolveExecute(id: string): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/ai-resolve/execute");
  }
  /** List the conversation's attachments (GET /conversations/{id}/attachments) */
  getConversationsByIdAttachments(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/conversations/" + encodeURIComponent(id) + "/attachments");
  }
  /** Upload a file attachment (raw body) → stored in R2. Default: threaded as its own message. `staged=1`: stored PENDING (no message) to bundle into a reply via ReplyRequest.attachment_ids. (POST /conversations/{id}/attachments) */
  postConversationsByIdAttachments(id: string, query?: Record<string, string | number | boolean>): Promise<unknown> {
    return this.request<unknown>("POST", "/conversations/" + encodeURIComponent(id) + "/attachments", { query });
  }
  /** Download an attachment (original content-type + filename) (GET /attachments/{id}) */
  getAttachmentsById(id: string): Promise<unknown> {
    return this.request<unknown>("GET", "/attachments/" + encodeURIComponent(id));
  }
  /** SendGrid v3 Mail Send compatibility (POST /v3/mail/send) */
  postV3MailSend(body: Record<string, unknown>): Promise<unknown> {
    return this.request<unknown>("POST", "/v3/mail/send", { body });
  }
}
