@linqapp/sdk 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/client.d.mts +1 -1
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +1 -1
  5. package/client.d.ts.map +1 -1
  6. package/client.js +1 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs +1 -1
  9. package/client.mjs.map +1 -1
  10. package/core/error.d.mts +13 -0
  11. package/core/error.d.mts.map +1 -1
  12. package/core/error.d.ts +13 -0
  13. package/core/error.d.ts.map +1 -1
  14. package/core/error.js +5 -1
  15. package/core/error.js.map +1 -1
  16. package/core/error.mjs +5 -1
  17. package/core/error.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/resources/chats/chats.d.mts +68 -24
  20. package/resources/chats/chats.d.mts.map +1 -1
  21. package/resources/chats/chats.d.ts +68 -24
  22. package/resources/chats/chats.d.ts.map +1 -1
  23. package/resources/chats/chats.js +6 -2
  24. package/resources/chats/chats.js.map +1 -1
  25. package/resources/chats/chats.mjs +6 -2
  26. package/resources/chats/chats.mjs.map +1 -1
  27. package/resources/chats/index.d.mts +1 -0
  28. package/resources/chats/index.d.mts.map +1 -1
  29. package/resources/chats/index.d.ts +1 -0
  30. package/resources/chats/index.d.ts.map +1 -1
  31. package/resources/chats/index.js +3 -1
  32. package/resources/chats/index.js.map +1 -1
  33. package/resources/chats/index.mjs +1 -0
  34. package/resources/chats/index.mjs.map +1 -1
  35. package/resources/chats/messages.d.mts +12 -5
  36. package/resources/chats/messages.d.mts.map +1 -1
  37. package/resources/chats/messages.d.ts +12 -5
  38. package/resources/chats/messages.d.ts.map +1 -1
  39. package/resources/chats/messages.js.map +1 -1
  40. package/resources/chats/messages.mjs.map +1 -1
  41. package/resources/chats/polls.d.mts +171 -0
  42. package/resources/chats/polls.d.mts.map +1 -0
  43. package/resources/chats/polls.d.ts +171 -0
  44. package/resources/chats/polls.d.ts.map +1 -0
  45. package/resources/chats/polls.js +95 -0
  46. package/resources/chats/polls.js.map +1 -0
  47. package/resources/chats/polls.mjs +91 -0
  48. package/resources/chats/polls.mjs.map +1 -0
  49. package/resources/index.d.mts +1 -1
  50. package/resources/index.d.mts.map +1 -1
  51. package/resources/index.d.ts +1 -1
  52. package/resources/index.d.ts.map +1 -1
  53. package/resources/index.js +1 -1
  54. package/resources/index.js.map +1 -1
  55. package/resources/index.mjs +1 -1
  56. package/resources/index.mjs.map +1 -1
  57. package/resources/messages/index.d.mts +3 -0
  58. package/resources/messages/index.d.mts.map +1 -0
  59. package/resources/messages/index.d.ts +3 -0
  60. package/resources/messages/index.d.ts.map +1 -0
  61. package/resources/messages/index.js +9 -0
  62. package/resources/messages/index.js.map +1 -0
  63. package/resources/messages/index.mjs +4 -0
  64. package/resources/messages/index.mjs.map +1 -0
  65. package/resources/messages/messages.d.mts +795 -0
  66. package/resources/messages/messages.d.mts.map +1 -0
  67. package/resources/messages/messages.d.ts +795 -0
  68. package/resources/messages/messages.d.ts.map +1 -0
  69. package/resources/messages/messages.js +298 -0
  70. package/resources/messages/messages.js.map +1 -0
  71. package/resources/messages/messages.mjs +293 -0
  72. package/resources/messages/messages.mjs.map +1 -0
  73. package/resources/messages/poll.d.mts +131 -0
  74. package/resources/messages/poll.d.mts.map +1 -0
  75. package/resources/messages/poll.d.ts +131 -0
  76. package/resources/messages/poll.d.ts.map +1 -0
  77. package/resources/messages/poll.js +119 -0
  78. package/resources/messages/poll.js.map +1 -0
  79. package/resources/messages/poll.mjs +115 -0
  80. package/resources/messages/poll.mjs.map +1 -0
  81. package/resources/messages.d.mts +1 -783
  82. package/resources/messages.d.mts.map +1 -1
  83. package/resources/messages.d.ts +1 -783
  84. package/resources/messages.d.ts.map +1 -1
  85. package/resources/messages.js +2 -286
  86. package/resources/messages.js.map +1 -1
  87. package/resources/messages.mjs +1 -284
  88. package/resources/messages.mjs.map +1 -1
  89. package/resources/webhook-events.d.mts +1 -1
  90. package/resources/webhook-events.d.mts.map +1 -1
  91. package/resources/webhook-events.d.ts +1 -1
  92. package/resources/webhook-events.d.ts.map +1 -1
  93. package/resources/webhooks.d.mts +40 -28
  94. package/resources/webhooks.d.mts.map +1 -1
  95. package/resources/webhooks.d.ts +40 -28
  96. package/resources/webhooks.d.ts.map +1 -1
  97. package/src/client.ts +15 -15
  98. package/src/core/error.ts +20 -1
  99. package/src/resources/chats/chats.ts +79 -24
  100. package/src/resources/chats/index.ts +1 -0
  101. package/src/resources/chats/messages.ts +14 -6
  102. package/src/resources/chats/polls.ts +196 -0
  103. package/src/resources/index.ts +1 -1
  104. package/src/resources/messages/index.ts +18 -0
  105. package/src/resources/messages/messages.ts +958 -0
  106. package/src/resources/messages/poll.ts +151 -0
  107. package/src/resources/messages.ts +1 -932
  108. package/src/resources/webhook-events.ts +9 -0
  109. package/src/resources/webhooks.ts +48 -27
  110. package/src/version.ts +1 -1
  111. package/version.d.mts +1 -1
  112. package/version.d.ts +1 -1
  113. package/version.js +1 -1
  114. package/version.mjs +1 -1
@@ -0,0 +1,958 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as Shared from '../shared';
5
+ import * as ChatsAPI from '../chats/chats';
6
+ import * as MessagesAPI from '../chats/messages';
7
+ import * as PollAPI from './poll';
8
+ import { Poll, PollAddOptionsParams, PollVoteParams } from './poll';
9
+ import { APIPromise } from '../../core/api-promise';
10
+ import {
11
+ ListMessagesPagination,
12
+ type ListMessagesPaginationParams,
13
+ PagePromise,
14
+ } from '../../core/pagination';
15
+ import { buildHeaders } from '../../internal/headers';
16
+ import { RequestOptions } from '../../internal/request-options';
17
+ import { path } from '../../internal/utils/path';
18
+
19
+ /**
20
+ * Messages are individual communications within a chat thread.
21
+ *
22
+ * Messages can include text, media attachments, rich link previews, special effects
23
+ * (like confetti or fireworks), and reactions. All messages are associated with a
24
+ * specific chat and sent from a phone number you own.
25
+ *
26
+ * Messages support delivery status tracking, read receipts, and editing capabilities.
27
+ *
28
+ * ## Rich Link Previews
29
+ *
30
+ * Send a URL as a `link` part to deliver it with a rich preview card showing the
31
+ * page's title, description, and image (when available). A `link` part must be the
32
+ * **only** part in the message — it cannot be combined with text or media parts.
33
+ * To send a URL without a preview card, include it in a `text` part instead.
34
+ *
35
+ * **Limitations:**
36
+ * - A `link` part cannot be combined with other parts in the same message.
37
+ * - Maximum URL length: 2,048 characters.
38
+ *
39
+ * ## Ephemeral Messages (Privacy Tier)
40
+ *
41
+ * For regulated or sensitive conversations, opt in to the **ephemeral messages** tier by contacting your Linq support contact. When enabled, every message on the covered phone numbers is automatically given a fixed **24-hour retention window** — after that window the platform permanently deletes the message from Linq storage. There is no per-message flag; ephemerality is applied automatically based on your configuration.
42
+ *
43
+ * You can request it at two scopes:
44
+ *
45
+ * | Scope | Effect |
46
+ * |---|---|
47
+ * | **Partner-wide** | Every outbound and inbound message on every phone number under your account is retained for 24 hours, then deleted. |
48
+ * | **Per phone number** | Only the specified phone numbers have their messages auto-deleted. The rest follow the standard message-retention policy. |
49
+ *
50
+ * **Behavioral differences vs the standard default:**
51
+ *
52
+ * | Aspect | Standard | Ephemeral |
53
+ * |---|---|---|
54
+ * | Retention | Retained per the standard message-retention policy | **Hard backstop: 24 hours** from when the message is created |
55
+ * | After expiry | Message stays retrievable | Message is permanently deleted — `GET /v3/messages/{messageId}` returns `404` and it no longer appears in `GET /v3/chats/{chatId}/messages` |
56
+ * | Content on expiry | N/A | Text, formatting, and attachment references are scrubbed; the message is gone, not blanked out |
57
+ * | Cross-partner isolation | Enforced | Enforced |
58
+ *
59
+ * **How the 24-hour window works:**
60
+ *
61
+ * - The window is fixed at **24 hours from message creation** (`created_at`) and cannot be configured per message.
62
+ * - It mirrors the ephemeral *attachments* 1-day backstop, so a message and any media it carries expire together.
63
+ * - Expiry is delivery-independent — the clock starts when the message is created, not when it is delivered or read.
64
+ *
65
+ * **What you observe:**
66
+ *
67
+ * - **No expiry timestamp is exposed.** API responses and webhook payloads do not include the deletion time. If you need it, compute `created_at + 24h` yourself.
68
+ * - **No deletion webhook is sent.** There is no `message.deleted` event — a message simply stops being retrievable once its window passes.
69
+ * - **Delivery is unaffected.** Ephemeral messages send, deliver, and fire the usual `message.sent` / `message.received` and status webhooks exactly like standard messages. Only retention changes.
70
+ *
71
+ * **When to choose ephemeral:**
72
+ *
73
+ * - You have a compliance requirement that the platform must not retain message content beyond a short window.
74
+ * - The conversation is high-sensitivity (PHI, financial, identity verification) and you do not want it sitting in storage long-term.
75
+ * - Your application is the system of record — you capture what you need from the delivery webhook in real time and do not rely on reading message history back from Linq later.
76
+ *
77
+ * **Important:** ephemeral applies in *both directions* — messages you send **and** messages received by the phone numbers in that scope. Because Linq can no longer return the message after 24 hours, persist anything you need to keep from the webhook payload at the time it is delivered.
78
+ */
79
+ export class Messages extends APIResource {
80
+ poll: PollAPI.Poll = new PollAPI.Poll(this._client);
81
+
82
+ /**
83
+ * Send a message to one or more recipients **without supplying a `from` number**.
84
+ * Linq resolves both the sending line and the target chat for you, then returns
85
+ * exactly which line was used, which chat the message landed in, whether a new
86
+ * chat was created, and every resulting message id.
87
+ *
88
+ * This fuses "create chat" and "send message" behind a single message-centric
89
+ * resource. Provide only the recipients (`to`) and the `message`; the platform
90
+ * decides the rest.
91
+ *
92
+ * ## How the from-number and chat are chosen
93
+ *
94
+ * - **Reuse** — if a chat with exactly these recipients already exists on a line
95
+ * that can still send, the message is sent into that chat on its existing line
96
+ * (`from_selection.reason = reused_active_chat`). The most-recently-active such
97
+ * chat wins; chats stranded on flagged lines (e.g. by an earlier failover) are
98
+ * skipped.
99
+ * - **New** — if no such chat exists, a new chat is created on the best available
100
+ * line (`from_selection.reason = new_best_number`).
101
+ * - **Failover** — if matching chats exist but none is on a line that can send, a
102
+ * **new** chat is created on a fresh best line and the flagged chat is abandoned
103
+ * (`from_selection.reason = failover_flagged`, `previous_chat_id` set). If you
104
+ * supply `continuation_message`, that text is sent as the single message INSTEAD
105
+ * of `message` (useful as a fresh-number-appropriate opener). Exactly one
106
+ * message is sent either way.
107
+ *
108
+ * Recipients (`to`) are an order-independent set: a single handle is a direct
109
+ * chat, multiple handles a group chat.
110
+ *
111
+ * ## Excluding lines
112
+ *
113
+ * `exclude_from` keeps specific lines out of **this** send's line pick. It only
114
+ * affects picking a line for a new chat — an existing chat is always reused on its
115
+ * own line, preferring a chat on a non-excluded line when the recipients have more
116
+ * than one. An exclusion never abandons a live chat or moves it to a new number,
117
+ * so if the only chat these recipients have is on an excluded line, that chat is
118
+ * still used. `from` tells you the line that was actually used.
119
+ *
120
+ * ## Differences from POST /v3/chats
121
+ *
122
+ * - The first message **may contain a link** (including for a newly created chat).
123
+ * Note: sending a link as the very first message on a freshly selected line can
124
+ * elevate that line's flagging risk — it is allowed, not recommended.
125
+ * - Voice memos are **not** supported here. To send an iMessage voice-memo bubble,
126
+ * use `POST /v3/chats/{chatId}/voicememo` with a known chat id.
127
+ *
128
+ * ## Service preference, effects, decorations
129
+ *
130
+ * Set `message.preferred_service` (`iMessage` | `RCS` | `SMS`), `message.effect`,
131
+ * and per-part `text_decorations` exactly as on the other send endpoints.
132
+ *
133
+ * Always responds `202 Accepted` — chat creation is incidental to the send.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * const message = await client.messages.create({
138
+ * message: {
139
+ * parts: [
140
+ * {
141
+ * type: 'text',
142
+ * value:
143
+ * 'Hi! Thanks for reaching out — how can we help?',
144
+ * },
145
+ * ],
146
+ * },
147
+ * to: ['+14155559876'],
148
+ * });
149
+ * ```
150
+ */
151
+ create(params: MessageCreateParams, options?: RequestOptions): APIPromise<MessageCreateResponse> {
152
+ const { 'Idempotency-Key': idempotencyKey, ...body } = params;
153
+ return this._client.post('/v3/messages', {
154
+ body,
155
+ ...options,
156
+ headers: buildHeaders([
157
+ { ...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined) },
158
+ options?.headers,
159
+ ]),
160
+ });
161
+ }
162
+
163
+ /**
164
+ * Retrieve a specific message by its ID. This endpoint returns the full message
165
+ * details including text, attachments, reactions, and metadata.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * const message = await client.messages.retrieve(
170
+ * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
171
+ * );
172
+ * ```
173
+ */
174
+ retrieve(messageID: string, options?: RequestOptions): APIPromise<Message> {
175
+ return this._client.get(path`/v3/messages/${messageID}`, options);
176
+ }
177
+
178
+ /**
179
+ * Edit the text content of a specific part of a previously sent message.
180
+ *
181
+ * **Note:** A message can be edited up to 5 times, and only within 15 minutes of
182
+ * when it was originally sent.
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * const message = await client.messages.update(
187
+ * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
188
+ * { text: 'This is the edited message content' },
189
+ * );
190
+ * ```
191
+ */
192
+ update(messageID: string, body: MessageUpdateParams, options?: RequestOptions): APIPromise<Message> {
193
+ return this._client.patch(path`/v3/messages/${messageID}`, { body, ...options });
194
+ }
195
+
196
+ /**
197
+ * Deletes a message from the Linq API only. This does NOT unsend or remove the
198
+ * message from the actual chat — recipients will still see the message. Re-sending
199
+ * with a deleted message's idempotency key returns 404 — a deleted message is
200
+ * never resent.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * await client.messages.delete(
205
+ * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
206
+ * );
207
+ * ```
208
+ */
209
+ delete(messageID: string, options?: RequestOptions): APIPromise<void> {
210
+ return this._client.delete(path`/v3/messages/${messageID}`, {
211
+ ...options,
212
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
213
+ });
214
+ }
215
+
216
+ /**
217
+ * Add or remove emoji reactions to messages. Reactions let users express their
218
+ * response to a message without sending a new message.
219
+ *
220
+ * **Supported Reactions:**
221
+ *
222
+ * - love ❤️
223
+ * - like 👍
224
+ * - dislike 👎
225
+ * - laugh 😂
226
+ * - emphasize ‼️
227
+ * - question ❓
228
+ * - custom - any emoji (use `custom_emoji` field to specify)
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * const response = await client.messages.addReaction(
233
+ * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
234
+ * { operation: 'add', type: 'love' },
235
+ * );
236
+ * ```
237
+ */
238
+ addReaction(
239
+ messageID: string,
240
+ body: MessageAddReactionParams,
241
+ options?: RequestOptions,
242
+ ): APIPromise<MessageAddReactionResponse> {
243
+ return this._client.post(path`/v3/messages/${messageID}/reactions`, { body, ...options });
244
+ }
245
+
246
+ /**
247
+ * Retrieve all messages in a conversation thread. Given any message ID in the
248
+ * thread, returns the originator message and all replies in chronological order.
249
+ *
250
+ * If the message is not part of a thread, returns just that single message.
251
+ *
252
+ * Supports pagination and configurable ordering.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * // Automatically fetches more pages as needed.
257
+ * for await (const message of client.messages.listMessagesThread(
258
+ * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
259
+ * )) {
260
+ * // ...
261
+ * }
262
+ * ```
263
+ */
264
+ listMessagesThread(
265
+ messageID: string,
266
+ query: MessageListMessagesThreadParams | null | undefined = {},
267
+ options?: RequestOptions,
268
+ ): PagePromise<MessagesListMessagesPagination, Message> {
269
+ return this._client.getAPIList(path`/v3/messages/${messageID}/thread`, ListMessagesPagination<Message>, {
270
+ query,
271
+ ...options,
272
+ });
273
+ }
274
+
275
+ /**
276
+ * Replaces a previously delivered `imessage_app` card on the recipient's screen
277
+ * with new content, instead of posting a new bubble (like a game move redrawing
278
+ * the board).
279
+ *
280
+ * The update is delivered as a **new message** with its own id and delivery
281
+ * lifecycle (`message.sent` / `message.delivered` / `message.failed` webhooks fire
282
+ * for the new id). To update the card again, reference the message id returned by
283
+ * this call.
284
+ *
285
+ * Constraints:
286
+ *
287
+ * - The referenced message must be an `imessage_app` card sent by you (`400`
288
+ * otherwise — inbound cards cannot be updated).
289
+ * - The referenced card must already be delivered (`409` otherwise — retry after
290
+ * the `message.delivered` webhook for it).
291
+ * - The app identity (`team_id`, `bundle_id`, name) is inherited from the original
292
+ * card and cannot change; only `url`, `fallback_text`, and `layout` are
293
+ * replaced.
294
+ * - iMessage-only, like all app cards.
295
+ * - Concurrent updates against the same card are not serialized server-side; the
296
+ * last one delivered wins on the recipient's screen. Serialize updates by always
297
+ * referencing the message id returned by the previous call.
298
+ *
299
+ * @example
300
+ * ```ts
301
+ * const response = await client.messages.updateAppCard(
302
+ * '69a37c7d-af4f-4b5e-af42-e28e98ce873a',
303
+ * {
304
+ * layout: { caption: 'Score: 2 – 1' },
305
+ * fallback_text: 'Score update',
306
+ * url: 'https://app.example.com/card?game=7f3a&move=2',
307
+ * },
308
+ * );
309
+ * ```
310
+ */
311
+ updateAppCard(
312
+ messageID: string,
313
+ body: MessageUpdateAppCardParams,
314
+ options?: RequestOptions,
315
+ ): APIPromise<MessageUpdateAppCardResponse> {
316
+ return this._client.post(path`/v3/messages/${messageID}/update`, { body, ...options });
317
+ }
318
+ }
319
+
320
+ export type MessagesListMessagesPagination = ListMessagesPagination<Message>;
321
+
322
+ export interface Message {
323
+ /**
324
+ * Unique identifier for the message
325
+ */
326
+ id: string;
327
+
328
+ /**
329
+ * ID of the chat this message belongs to
330
+ */
331
+ chat_id: string;
332
+
333
+ /**
334
+ * When the message was created
335
+ */
336
+ created_at: string;
337
+
338
+ /**
339
+ * Current delivery status of a message
340
+ */
341
+ delivery_status: 'pending' | 'queued' | 'sent' | 'delivered' | 'received' | 'read' | 'failed';
342
+
343
+ /**
344
+ * @deprecated DEPRECATED: Use `delivery_status` instead (true when
345
+ * `delivery_status` is `delivered` or `read`). Whether the message has been
346
+ * delivered.
347
+ */
348
+ is_delivered: boolean;
349
+
350
+ /**
351
+ * Whether this message was sent by the authenticated user
352
+ */
353
+ is_from_me: boolean;
354
+
355
+ /**
356
+ * @deprecated DEPRECATED: Use `delivery_status == "read"` instead. Whether the
357
+ * message has been read.
358
+ */
359
+ is_read: boolean;
360
+
361
+ /**
362
+ * When the message was last updated
363
+ */
364
+ updated_at: string;
365
+
366
+ /**
367
+ * When the message was delivered
368
+ */
369
+ delivered_at?: string | null;
370
+
371
+ /**
372
+ * iMessage effect applied to a message (screen or bubble effect)
373
+ */
374
+ effect?: MessageEffect | null;
375
+
376
+ /**
377
+ * @deprecated DEPRECATED: Use from_handle instead. Phone number of the message
378
+ * sender.
379
+ */
380
+ from?: string | null;
381
+
382
+ /**
383
+ * The sender of this message as a full handle object
384
+ */
385
+ from_handle?: Shared.ChatHandle | null;
386
+
387
+ /**
388
+ * Message parts in order (text, media, and link)
389
+ */
390
+ parts?: Array<
391
+ | Shared.TextPartResponse
392
+ | Shared.MediaPartResponse
393
+ | Shared.LinkPartResponse
394
+ | Message.IMessageAppPartResponse
395
+ > | null;
396
+
397
+ /**
398
+ * Messaging service type
399
+ */
400
+ preferred_service?: Shared.ServiceType | null;
401
+
402
+ /**
403
+ * When the message was read
404
+ */
405
+ read_at?: string | null;
406
+
407
+ /**
408
+ * Present only when this message was recovered by reconciliation rather than
409
+ * delivered live, and set to the time of that recovery. The field is omitted
410
+ * entirely for normally-delivered messages, which is the overwhelming majority.
411
+ * When present, expect `sent_at` to be substantially earlier — the message is
412
+ * genuine but was ingested late, so it may not have appeared in earlier reads of
413
+ * this conversation.
414
+ */
415
+ reconciled_at?: string;
416
+
417
+ /**
418
+ * Indicates this message is a threaded reply to another message
419
+ */
420
+ reply_to?: ReplyTo | null;
421
+
422
+ /**
423
+ * When the message was sent
424
+ */
425
+ sent_at?: string | null;
426
+
427
+ /**
428
+ * Messaging service type
429
+ */
430
+ service?: Shared.ServiceType | null;
431
+ }
432
+
433
+ export namespace Message {
434
+ /**
435
+ * An iMessage app card part.
436
+ */
437
+ export interface IMessageAppPartResponse {
438
+ /**
439
+ * Identifies the iMessage app (Messages app extension) that backs the card.
440
+ */
441
+ app: IMessageAppPartResponse.App;
442
+
443
+ /**
444
+ * Visible layout of the card. At least one of `caption`, `subcaption`,
445
+ * `trailing_caption`, `trailing_subcaption`, or `image_url` must be set, otherwise
446
+ * the card renders as an empty bubble.
447
+ *
448
+ * `image_url` displays a preview image at the top of the card. The image renders
449
+ * on the recipient's card whether or not they have your app installed. The small
450
+ * icon beside the caption is the app's own icon and is not settable here.
451
+ *
452
+ * `* Note - requires a trusted chat w/ inbound activity`
453
+ *
454
+ * `image_title` and `image_subtitle` render as text overlaid on the image (title
455
+ * bold, subtitle beneath it). They only appear when `image_url` is set — without
456
+ * an image there is nothing to overlay — so setting either without `image_url` is
457
+ * rejected.
458
+ */
459
+ layout: IMessageAppPartResponse.Layout;
460
+
461
+ /**
462
+ * Reactions on this message part
463
+ */
464
+ reactions: Array<Shared.Reaction> | null;
465
+
466
+ /**
467
+ * Indicates this is an iMessage app card part.
468
+ */
469
+ type: 'imessage_app';
470
+
471
+ /**
472
+ * The URL delivered to the iMessage app on tap.
473
+ */
474
+ url: string;
475
+
476
+ /**
477
+ * Fallback text for surfaces that cannot render the card.
478
+ */
479
+ fallback_text?: string | null;
480
+ }
481
+
482
+ export namespace IMessageAppPartResponse {
483
+ /**
484
+ * Identifies the iMessage app (Messages app extension) that backs the card.
485
+ */
486
+ export interface App {
487
+ /**
488
+ * Bundle identifier of the Messages app extension. Must not contain `:`.
489
+ */
490
+ bundle_id: string;
491
+
492
+ /**
493
+ * Display name of the app, shown by Messages' fallback UI.
494
+ */
495
+ name: string;
496
+
497
+ /**
498
+ * The app's 10-character uppercase alphanumeric team identifier.
499
+ */
500
+ team_id: string;
501
+
502
+ /**
503
+ * The owning app's App Store id (optional). When set, recipients without the
504
+ * iMessage app installed see a "Get the app" affordance.
505
+ */
506
+ app_store_id?: number;
507
+ }
508
+
509
+ /**
510
+ * Visible layout of the card. At least one of `caption`, `subcaption`,
511
+ * `trailing_caption`, `trailing_subcaption`, or `image_url` must be set, otherwise
512
+ * the card renders as an empty bubble.
513
+ *
514
+ * `image_url` displays a preview image at the top of the card. The image renders
515
+ * on the recipient's card whether or not they have your app installed. The small
516
+ * icon beside the caption is the app's own icon and is not settable here.
517
+ *
518
+ * `* Note - requires a trusted chat w/ inbound activity`
519
+ *
520
+ * `image_title` and `image_subtitle` render as text overlaid on the image (title
521
+ * bold, subtitle beneath it). They only appear when `image_url` is set — without
522
+ * an image there is nothing to overlay — so setting either without `image_url` is
523
+ * rejected.
524
+ */
525
+ export interface Layout {
526
+ /**
527
+ * Primary label, top-left and bold.
528
+ */
529
+ caption?: string;
530
+
531
+ /**
532
+ * Text shown below `image_title`, overlaid on the card image. Requires
533
+ * `image_url`.
534
+ */
535
+ image_subtitle?: string;
536
+
537
+ /**
538
+ * Bold text overlaid on the card image. Requires `image_url` (rejected without
539
+ * it).
540
+ */
541
+ image_title?: string;
542
+
543
+ /**
544
+ * URL of an image (JPEG, PNG, HEIF, or WebP) to display as the card's preview
545
+ * image; an unreachable or non-image URL returns a validation error. Renders for
546
+ * all recipients regardless of whether they have the app. Note - requires a
547
+ * trusted chat w/ inbound activity. In responses, this is the re-hosted
548
+ * `cdn.linqapp.com` copy of the image you supplied, not your original URL.
549
+ */
550
+ image_url?: string;
551
+
552
+ /**
553
+ * Secondary label, below `caption` on the left.
554
+ */
555
+ subcaption?: string;
556
+
557
+ /**
558
+ * Label shown top-right.
559
+ */
560
+ trailing_caption?: string;
561
+
562
+ /**
563
+ * Label shown below `trailing_caption`, on the right.
564
+ */
565
+ trailing_subcaption?: string;
566
+ }
567
+ }
568
+ }
569
+
570
+ /**
571
+ * iMessage effect applied to a message (screen or bubble effect)
572
+ */
573
+ export interface MessageEffect {
574
+ /**
575
+ * Name of the effect. Common values:
576
+ *
577
+ * - Screen effects: confetti, fireworks, lasers, sparkles, celebration, hearts,
578
+ * love, balloons, happy_birthday, echo, spotlight
579
+ * - Bubble effects: slam, loud, gentle, invisible
580
+ */
581
+ name?: string;
582
+
583
+ /**
584
+ * Type of effect
585
+ */
586
+ type?: 'screen' | 'bubble';
587
+ }
588
+
589
+ /**
590
+ * Indicates this message is a threaded reply to another message
591
+ */
592
+ export interface ReplyTo {
593
+ /**
594
+ * The ID of the message to reply to
595
+ */
596
+ message_id: string;
597
+
598
+ /**
599
+ * The specific message part to reply to (0-based index). Defaults to 0 (first
600
+ * part) if not provided. Use this when replying to a specific part of a multipart
601
+ * message.
602
+ */
603
+ part_index?: number;
604
+ }
605
+
606
+ /**
607
+ * Result of an auto-from send. Self-describing: which line was used, which chat
608
+ * the message landed in, whether a new chat was created, and the resulting message
609
+ * id(s).
610
+ */
611
+ export interface MessageCreateResponse {
612
+ /**
613
+ * The resolved chat (reused or newly created) the message landed in.
614
+ */
615
+ chat_id: string;
616
+
617
+ /**
618
+ * True when a new chat was created (new or failover), false on reuse.
619
+ */
620
+ created_new_chat: boolean;
621
+
622
+ /**
623
+ * The line (E.164) the message was actually sent from.
624
+ */
625
+ from: string;
626
+
627
+ /**
628
+ * Why this line/chat was chosen.
629
+ */
630
+ from_selection: MessageCreateResponse.FromSelection;
631
+
632
+ /**
633
+ * Participants of the resolved chat.
634
+ */
635
+ handles: Array<Shared.ChatHandle>;
636
+
637
+ /**
638
+ * Whether the resolved chat is a group chat.
639
+ */
640
+ is_group: boolean;
641
+
642
+ /**
643
+ * A message that was sent (used in CreateChat and SendMessage responses)
644
+ */
645
+ message: MessagesAPI.SentMessage;
646
+
647
+ /**
648
+ * Messaging service type
649
+ */
650
+ service: Shared.ServiceType;
651
+
652
+ /**
653
+ * Set ONLY on `failover_flagged`: the abandoned flagged chat that was NOT sent
654
+ * into. Null otherwise.
655
+ */
656
+ previous_chat_id?: string | null;
657
+ }
658
+
659
+ export namespace MessageCreateResponse {
660
+ /**
661
+ * Why this line/chat was chosen.
662
+ */
663
+ export interface FromSelection {
664
+ /**
665
+ * - `reused_active_chat` — reused an existing chat on its healthy line
666
+ * - `new_best_number` — created a new chat on the best available line
667
+ * - `failover_flagged` — no existing chat for these recipients was on a line that
668
+ * could send; created a new chat on a fresh line
669
+ */
670
+ reason: 'reused_active_chat' | 'new_best_number' | 'failover_flagged';
671
+
672
+ /**
673
+ * True only when an existing chat was reused.
674
+ */
675
+ reused_existing_chat: boolean;
676
+ }
677
+ }
678
+
679
+ export interface MessageAddReactionResponse {
680
+ message?: string;
681
+
682
+ status?: string;
683
+
684
+ trace_id?: string;
685
+ }
686
+
687
+ /**
688
+ * Response for sending a message to a chat
689
+ */
690
+ export interface MessageUpdateAppCardResponse {
691
+ /**
692
+ * Unique identifier of the chat this message was sent to
693
+ */
694
+ chat_id: string;
695
+
696
+ /**
697
+ * A message that was sent (used in CreateChat and SendMessage responses)
698
+ */
699
+ message: MessagesAPI.SentMessage;
700
+ }
701
+
702
+ export interface MessageCreateParams {
703
+ /**
704
+ * Body param: Message content container. Groups all message-related fields
705
+ * together, separating the "what" (message content) from the "where" (routing
706
+ * fields like from/to).
707
+ *
708
+ * A message carries EITHER `parts` — text and attachments, which compose into one
709
+ * bubble — or a single `action`, which invokes an experience inside Linq's
710
+ * iMessage app. Never both: an app card is the whole message (Apple's `MSMessage`
711
+ * cannot coexist with text), so copy and a card are two sends, not one.
712
+ */
713
+ message: ChatsAPI.MessageContent;
714
+
715
+ /**
716
+ * Body param: Recipient handles (E.164 phone numbers or email addresses). One
717
+ * handle is a direct chat; multiple handles a group chat. Order-independent — the
718
+ * set identifies the chat.
719
+ */
720
+ to: Array<string>;
721
+
722
+ /**
723
+ * Body param: Text-only fallback that **replaces** `message` ONLY on the failover
724
+ * branch — when a chat with these recipients already existed but its line was
725
+ * flagged, so a new chat is created on a fresh line. On that branch this text is
726
+ * sent as the single message instead of `message` (the recipient is on a new
727
+ * number, so you typically want a fresh-number-appropriate opener rather than the
728
+ * original content). Ignored otherwise (a healthy reuse, or genuine first
729
+ * contact). Carries no parts, media, or effects — exactly one message is ever
730
+ * sent.
731
+ */
732
+ continuation_message?: MessageCreateParams.ContinuationMessage;
733
+
734
+ /**
735
+ * Body param: Lines (E.164) not to pick for this send. Applies for this request
736
+ * only — nothing is remembered between calls.
737
+ *
738
+ * **Exclusion only affects picking a line for a new chat.** If `to` already has a
739
+ * chat, that chat is reused on its own line, and a chat on a non-excluded line is
740
+ * preferred when there is more than one. If the only chat these recipients have is
741
+ * on an excluded line, it is still reused — an exclusion never abandons a live
742
+ * chat or moves it to a new number. Check `from` in the response to see the line
743
+ * that was actually used.
744
+ *
745
+ * Numbers that are not your lines are ignored. Every entry must be E.164 — a value
746
+ * like `4155551234` is rejected rather than silently skipped. Excluding every one
747
+ * of your available lines returns 400 when a line has to be picked.
748
+ */
749
+ exclude_from?: Array<string>;
750
+
751
+ /**
752
+ * Body param: Send even though the recipient asked you to stop (`403`, error code
753
+ * `2024`). Applies to this request only: the opt-out stays in place, so the next
754
+ * send without this flag is rejected again. Every override is recorded against
755
+ * your API key.
756
+ */
757
+ override_optout?: boolean;
758
+
759
+ /**
760
+ * Header param: Optional idempotency key for the send. Reuse the same key to
761
+ * safely retry without sending twice. May also be supplied as
762
+ * `message.idempotency_key`.
763
+ */
764
+ 'Idempotency-Key'?: string;
765
+ }
766
+
767
+ export namespace MessageCreateParams {
768
+ /**
769
+ * Text-only fallback that **replaces** `message` ONLY on the failover branch —
770
+ * when a chat with these recipients already existed but its line was flagged, so a
771
+ * new chat is created on a fresh line. On that branch this text is sent as the
772
+ * single message instead of `message` (the recipient is on a new number, so you
773
+ * typically want a fresh-number-appropriate opener rather than the original
774
+ * content). Ignored otherwise (a healthy reuse, or genuine first contact). Carries
775
+ * no parts, media, or effects — exactly one message is ever sent.
776
+ */
777
+ export interface ContinuationMessage {
778
+ /**
779
+ * The replacement message text, sent as the single message on failover.
780
+ */
781
+ text: string;
782
+ }
783
+ }
784
+
785
+ export interface MessageUpdateParams {
786
+ /**
787
+ * New text content for the message part
788
+ */
789
+ text: string;
790
+
791
+ /**
792
+ * Index of the message part to edit. Defaults to 0.
793
+ */
794
+ part_index?: number;
795
+ }
796
+
797
+ export interface MessageAddReactionParams {
798
+ /**
799
+ * Whether to add or remove the reaction
800
+ */
801
+ operation: 'add' | 'remove';
802
+
803
+ /**
804
+ * Type of reaction. Standard iMessage tapbacks are love, like, dislike, laugh,
805
+ * emphasize, question. Custom emoji reactions have type "custom" with the actual
806
+ * emoji in the custom_emoji field. Sticker reactions have type "sticker" with
807
+ * sticker attachment details in the sticker field.
808
+ */
809
+ type: Shared.ReactionType;
810
+
811
+ /**
812
+ * Custom emoji string. Required when type is "custom".
813
+ */
814
+ custom_emoji?: string;
815
+
816
+ /**
817
+ * Optional index of the message part to react to. If not provided, reacts to the
818
+ * entire message (part 0).
819
+ */
820
+ part_index?: number;
821
+ }
822
+
823
+ export interface MessageListMessagesThreadParams extends ListMessagesPaginationParams {
824
+ /**
825
+ * Sort order for messages (asc = oldest first, desc = newest first)
826
+ */
827
+ order?: 'asc' | 'desc';
828
+ }
829
+
830
+ export interface MessageUpdateAppCardParams {
831
+ /**
832
+ * Visible layout of the card. At least one of `caption`, `subcaption`,
833
+ * `trailing_caption`, `trailing_subcaption`, or `image_url` must be set, otherwise
834
+ * the card renders as an empty bubble.
835
+ *
836
+ * `image_url` displays a preview image at the top of the card. The image renders
837
+ * on the recipient's card whether or not they have your app installed. The small
838
+ * icon beside the caption is the app's own icon and is not settable here.
839
+ *
840
+ * `* Note - requires a trusted chat w/ inbound activity`
841
+ *
842
+ * `image_title` and `image_subtitle` render as text overlaid on the image (title
843
+ * bold, subtitle beneath it). They only appear when `image_url` is set — without
844
+ * an image there is nothing to overlay — so setting either without `image_url` is
845
+ * rejected.
846
+ */
847
+ layout: MessageUpdateAppCardParams.Layout;
848
+
849
+ /**
850
+ * Text shown on surfaces that cannot render the card (notifications, lock screen).
851
+ * Defaults to the caption when omitted.
852
+ */
853
+ fallback_text?: string;
854
+
855
+ /**
856
+ * Whether the updated card renders as your app's interactive balloon for
857
+ * recipients who have your iMessage app installed. `true` (default) lets your
858
+ * installed extension draw its live view; `false` always shows the static `layout`
859
+ * card. Recipients without your app always see the static card regardless of this
860
+ * flag.
861
+ *
862
+ * Defaults to `true` when omitted — it is **not** inherited from the original
863
+ * card. To keep a card static across updates, re-send `interactive: false` on each
864
+ * update.
865
+ */
866
+ interactive?: boolean;
867
+
868
+ /**
869
+ * URL the recipient's app opens when they tap the updated card.
870
+ */
871
+ url?: string;
872
+ }
873
+
874
+ export namespace MessageUpdateAppCardParams {
875
+ /**
876
+ * Visible layout of the card. At least one of `caption`, `subcaption`,
877
+ * `trailing_caption`, `trailing_subcaption`, or `image_url` must be set, otherwise
878
+ * the card renders as an empty bubble.
879
+ *
880
+ * `image_url` displays a preview image at the top of the card. The image renders
881
+ * on the recipient's card whether or not they have your app installed. The small
882
+ * icon beside the caption is the app's own icon and is not settable here.
883
+ *
884
+ * `* Note - requires a trusted chat w/ inbound activity`
885
+ *
886
+ * `image_title` and `image_subtitle` render as text overlaid on the image (title
887
+ * bold, subtitle beneath it). They only appear when `image_url` is set — without
888
+ * an image there is nothing to overlay — so setting either without `image_url` is
889
+ * rejected.
890
+ */
891
+ export interface Layout {
892
+ /**
893
+ * Primary label, top-left and bold.
894
+ */
895
+ caption?: string;
896
+
897
+ /**
898
+ * Text shown below `image_title`, overlaid on the card image. Requires
899
+ * `image_url`.
900
+ */
901
+ image_subtitle?: string;
902
+
903
+ /**
904
+ * Bold text overlaid on the card image. Requires `image_url` (rejected without
905
+ * it).
906
+ */
907
+ image_title?: string;
908
+
909
+ /**
910
+ * URL of an image (JPEG, PNG, HEIF, or WebP) to display as the card's preview
911
+ * image; an unreachable or non-image URL returns a validation error. Renders for
912
+ * all recipients regardless of whether they have the app. Note - requires a
913
+ * trusted chat w/ inbound activity. In responses, this is the re-hosted
914
+ * `cdn.linqapp.com` copy of the image you supplied, not your original URL.
915
+ */
916
+ image_url?: string;
917
+
918
+ /**
919
+ * Secondary label, below `caption` on the left.
920
+ */
921
+ subcaption?: string;
922
+
923
+ /**
924
+ * Label shown top-right.
925
+ */
926
+ trailing_caption?: string;
927
+
928
+ /**
929
+ * Label shown below `trailing_caption`, on the right.
930
+ */
931
+ trailing_subcaption?: string;
932
+ }
933
+ }
934
+
935
+ Messages.Poll = Poll;
936
+
937
+ export declare namespace Messages {
938
+ export {
939
+ type Message as Message,
940
+ type MessageEffect as MessageEffect,
941
+ type ReplyTo as ReplyTo,
942
+ type MessageCreateResponse as MessageCreateResponse,
943
+ type MessageAddReactionResponse as MessageAddReactionResponse,
944
+ type MessageUpdateAppCardResponse as MessageUpdateAppCardResponse,
945
+ type MessagesListMessagesPagination as MessagesListMessagesPagination,
946
+ type MessageCreateParams as MessageCreateParams,
947
+ type MessageUpdateParams as MessageUpdateParams,
948
+ type MessageAddReactionParams as MessageAddReactionParams,
949
+ type MessageListMessagesThreadParams as MessageListMessagesThreadParams,
950
+ type MessageUpdateAppCardParams as MessageUpdateAppCardParams,
951
+ };
952
+
953
+ export {
954
+ Poll as Poll,
955
+ type PollAddOptionsParams as PollAddOptionsParams,
956
+ type PollVoteParams as PollVoteParams,
957
+ };
958
+ }