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