@linqapp/sdk 0.32.1 → 0.33.1

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 (203) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +82 -112
  3. package/client.d.mts +42 -6
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +42 -6
  6. package/client.d.ts.map +1 -1
  7. package/client.js +39 -3
  8. package/client.js.map +1 -1
  9. package/client.mjs +39 -3
  10. package/client.mjs.map +1 -1
  11. package/core/error.d.mts +13 -0
  12. package/core/error.d.mts.map +1 -1
  13. package/core/error.d.ts +13 -0
  14. package/core/error.d.ts.map +1 -1
  15. package/core/error.js +5 -1
  16. package/core/error.js.map +1 -1
  17. package/core/error.mjs +5 -1
  18. package/core/error.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/resources/available-number.d.mts +13 -1
  21. package/resources/available-number.d.mts.map +1 -1
  22. package/resources/available-number.d.ts +13 -1
  23. package/resources/available-number.d.ts.map +1 -1
  24. package/resources/available-number.js +2 -1
  25. package/resources/available-number.js.map +1 -1
  26. package/resources/available-number.mjs +2 -1
  27. package/resources/available-number.mjs.map +1 -1
  28. package/resources/chats/chats.d.mts +175 -70
  29. package/resources/chats/chats.d.mts.map +1 -1
  30. package/resources/chats/chats.d.ts +175 -70
  31. package/resources/chats/chats.d.ts.map +1 -1
  32. package/resources/chats/chats.js +65 -61
  33. package/resources/chats/chats.js.map +1 -1
  34. package/resources/chats/chats.mjs +65 -61
  35. package/resources/chats/chats.mjs.map +1 -1
  36. package/resources/chats/index.d.mts +3 -2
  37. package/resources/chats/index.d.mts.map +1 -1
  38. package/resources/chats/index.d.ts +3 -2
  39. package/resources/chats/index.d.ts.map +1 -1
  40. package/resources/chats/index.js +3 -1
  41. package/resources/chats/index.js.map +1 -1
  42. package/resources/chats/index.mjs +1 -0
  43. package/resources/chats/index.mjs.map +1 -1
  44. package/resources/chats/location.d.mts +25 -25
  45. package/resources/chats/location.d.mts.map +1 -1
  46. package/resources/chats/location.d.ts +25 -25
  47. package/resources/chats/location.d.ts.map +1 -1
  48. package/resources/chats/location.js +27 -27
  49. package/resources/chats/location.js.map +1 -1
  50. package/resources/chats/location.mjs +27 -27
  51. package/resources/chats/location.mjs.map +1 -1
  52. package/resources/chats/messages.d.mts +28 -21
  53. package/resources/chats/messages.d.mts.map +1 -1
  54. package/resources/chats/messages.d.ts +28 -21
  55. package/resources/chats/messages.d.ts.map +1 -1
  56. package/resources/chats/messages.js +16 -16
  57. package/resources/chats/messages.js.map +1 -1
  58. package/resources/chats/messages.mjs +16 -16
  59. package/resources/chats/messages.mjs.map +1 -1
  60. package/resources/chats/polls.d.mts +171 -0
  61. package/resources/chats/polls.d.mts.map +1 -0
  62. package/resources/chats/polls.d.ts +171 -0
  63. package/resources/chats/polls.d.ts.map +1 -0
  64. package/resources/chats/polls.js +95 -0
  65. package/resources/chats/polls.js.map +1 -0
  66. package/resources/chats/polls.mjs +91 -0
  67. package/resources/chats/polls.mjs.map +1 -0
  68. package/resources/contact-card.d.mts +29 -28
  69. package/resources/contact-card.d.mts.map +1 -1
  70. package/resources/contact-card.d.ts +29 -28
  71. package/resources/contact-card.d.ts.map +1 -1
  72. package/resources/contact-card.js +23 -22
  73. package/resources/contact-card.js.map +1 -1
  74. package/resources/contact-card.mjs +23 -22
  75. package/resources/contact-card.mjs.map +1 -1
  76. package/resources/experiences.d.mts +91 -0
  77. package/resources/experiences.d.mts.map +1 -0
  78. package/resources/experiences.d.ts +91 -0
  79. package/resources/experiences.d.ts.map +1 -0
  80. package/resources/experiences.js +29 -0
  81. package/resources/experiences.js.map +1 -0
  82. package/resources/experiences.mjs +25 -0
  83. package/resources/experiences.mjs.map +1 -0
  84. package/resources/index.d.mts +7 -3
  85. package/resources/index.d.mts.map +1 -1
  86. package/resources/index.d.ts +7 -3
  87. package/resources/index.d.ts.map +1 -1
  88. package/resources/index.js +10 -2
  89. package/resources/index.js.map +1 -1
  90. package/resources/index.mjs +5 -1
  91. package/resources/index.mjs.map +1 -1
  92. package/resources/messages/index.d.mts +3 -0
  93. package/resources/messages/index.d.mts.map +1 -0
  94. package/resources/messages/index.d.ts +3 -0
  95. package/resources/messages/index.d.ts.map +1 -0
  96. package/resources/messages/index.js +9 -0
  97. package/resources/messages/index.js.map +1 -0
  98. package/resources/messages/index.mjs +4 -0
  99. package/resources/messages/index.mjs.map +1 -0
  100. package/resources/messages/messages.d.mts +795 -0
  101. package/resources/messages/messages.d.mts.map +1 -0
  102. package/resources/messages/messages.d.ts +795 -0
  103. package/resources/messages/messages.d.ts.map +1 -0
  104. package/resources/messages/messages.js +298 -0
  105. package/resources/messages/messages.js.map +1 -0
  106. package/resources/messages/messages.mjs +293 -0
  107. package/resources/messages/messages.mjs.map +1 -0
  108. package/resources/messages/poll.d.mts +131 -0
  109. package/resources/messages/poll.d.mts.map +1 -0
  110. package/resources/messages/poll.d.ts +131 -0
  111. package/resources/messages/poll.d.ts.map +1 -0
  112. package/resources/messages/poll.js +119 -0
  113. package/resources/messages/poll.js.map +1 -0
  114. package/resources/messages/poll.mjs +115 -0
  115. package/resources/messages/poll.mjs.map +1 -0
  116. package/resources/messages.d.mts +1 -747
  117. package/resources/messages.d.mts.map +1 -1
  118. package/resources/messages.d.ts +1 -747
  119. package/resources/messages.d.ts.map +1 -1
  120. package/resources/messages.js +2 -275
  121. package/resources/messages.js.map +1 -1
  122. package/resources/messages.mjs +1 -273
  123. package/resources/messages.mjs.map +1 -1
  124. package/resources/payment-handles.d.mts +87 -0
  125. package/resources/payment-handles.d.mts.map +1 -0
  126. package/resources/payment-handles.d.ts +87 -0
  127. package/resources/payment-handles.d.ts.map +1 -0
  128. package/resources/payment-handles.js +76 -0
  129. package/resources/payment-handles.js.map +1 -0
  130. package/resources/payment-handles.mjs +72 -0
  131. package/resources/payment-handles.mjs.map +1 -0
  132. package/resources/payment-providers.d.mts +58 -0
  133. package/resources/payment-providers.d.mts.map +1 -0
  134. package/resources/payment-providers.d.ts +58 -0
  135. package/resources/payment-providers.d.ts.map +1 -0
  136. package/resources/payment-providers.js +45 -0
  137. package/resources/payment-providers.js.map +1 -0
  138. package/resources/payment-providers.mjs +41 -0
  139. package/resources/payment-providers.mjs.map +1 -0
  140. package/resources/payment-requests.d.mts +2 -2
  141. package/resources/payment-requests.d.ts +2 -2
  142. package/resources/payment-requests.js +2 -2
  143. package/resources/payment-requests.mjs +2 -2
  144. package/resources/payments.d.mts +116 -0
  145. package/resources/payments.d.mts.map +1 -0
  146. package/resources/payments.d.ts +116 -0
  147. package/resources/payments.d.ts.map +1 -0
  148. package/resources/payments.js +70 -0
  149. package/resources/payments.js.map +1 -0
  150. package/resources/payments.mjs +66 -0
  151. package/resources/payments.mjs.map +1 -0
  152. package/resources/phone-numbers.d.mts +11 -11
  153. package/resources/phone-numbers.d.mts.map +1 -1
  154. package/resources/phone-numbers.d.ts +11 -11
  155. package/resources/phone-numbers.d.ts.map +1 -1
  156. package/resources/phone-numbers.js +13 -13
  157. package/resources/phone-numbers.js.map +1 -1
  158. package/resources/phone-numbers.mjs +13 -13
  159. package/resources/phone-numbers.mjs.map +1 -1
  160. package/resources/webhook-events.d.mts +1 -1
  161. package/resources/webhook-events.d.mts.map +1 -1
  162. package/resources/webhook-events.d.ts +1 -1
  163. package/resources/webhook-events.d.ts.map +1 -1
  164. package/resources/webhook-subscriptions.d.mts +11 -11
  165. package/resources/webhook-subscriptions.d.mts.map +1 -1
  166. package/resources/webhook-subscriptions.d.ts +11 -11
  167. package/resources/webhook-subscriptions.d.ts.map +1 -1
  168. package/resources/webhook-subscriptions.js +13 -13
  169. package/resources/webhook-subscriptions.js.map +1 -1
  170. package/resources/webhook-subscriptions.mjs +13 -13
  171. package/resources/webhook-subscriptions.mjs.map +1 -1
  172. package/resources/webhooks.d.mts +72 -1
  173. package/resources/webhooks.d.mts.map +1 -1
  174. package/resources/webhooks.d.ts +72 -1
  175. package/resources/webhooks.d.ts.map +1 -1
  176. package/src/client.ts +91 -20
  177. package/src/core/error.ts +20 -1
  178. package/src/resources/available-number.ts +14 -1
  179. package/src/resources/chats/chats.ts +203 -85
  180. package/src/resources/chats/index.ts +3 -2
  181. package/src/resources/chats/location.ts +28 -28
  182. package/src/resources/chats/messages.ts +40 -32
  183. package/src/resources/chats/polls.ts +196 -0
  184. package/src/resources/contact-card.ts +36 -35
  185. package/src/resources/experiences.ts +118 -0
  186. package/src/resources/index.ts +23 -5
  187. package/src/resources/messages/index.ts +18 -0
  188. package/src/resources/messages/messages.ts +958 -0
  189. package/src/resources/messages/poll.ts +151 -0
  190. package/src/resources/messages.ts +1 -894
  191. package/src/resources/payment-handles.ts +114 -0
  192. package/src/resources/payment-providers.ts +81 -0
  193. package/src/resources/payment-requests.ts +2 -2
  194. package/src/resources/payments.ts +163 -0
  195. package/src/resources/phone-numbers.ts +14 -14
  196. package/src/resources/webhook-events.ts +9 -0
  197. package/src/resources/webhook-subscriptions.ts +14 -14
  198. package/src/resources/webhooks.ts +82 -0
  199. package/src/version.ts +1 -1
  200. package/version.d.mts +1 -1
  201. package/version.d.ts +1 -1
  202. package/version.js +1 -1
  203. package/version.mjs +1 -1
@@ -1,11 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
- import * as MessagesAPI from '../messages';
5
4
  import * as Shared from '../shared';
6
5
  import * as LocationAPI from './location';
7
6
  import { GetChatLocationResponse, Location, LocationRequestResponse } from './location';
8
- import * as ChatsMessagesAPI from './messages';
7
+ import * as MessagesAPI from './messages';
9
8
  import { MessageListParams, MessageSendParams, MessageSendResponse, Messages, SentMessage } from './messages';
10
9
  import * as ParticipantsAPI from './participants';
11
10
  import {
@@ -15,8 +14,11 @@ import {
15
14
  ParticipantRemoveResponse,
16
15
  Participants,
17
16
  } from './participants';
17
+ import * as PollsAPI from './polls';
18
+ import { Poll, PollCreateParams, PollEnvelope, Polls } from './polls';
18
19
  import * as TypingAPI from './typing';
19
20
  import { Typing } from './typing';
21
+ import * as ResourcesMessagesAPI from '../messages/messages';
20
22
  import { APIPromise } from '../../core/api-promise';
21
23
  import { ListChatsPagination, type ListChatsPaginationParams, PagePromise } from '../../core/pagination';
22
24
  import { buildHeaders } from '../../internal/headers';
@@ -26,8 +28,9 @@ import { path } from '../../internal/utils/path';
26
28
  export class Chats extends APIResource {
27
29
  participants: ParticipantsAPI.Participants = new ParticipantsAPI.Participants(this._client);
28
30
  typing: TypingAPI.Typing = new TypingAPI.Typing(this._client);
29
- messages: ChatsMessagesAPI.Messages = new ChatsMessagesAPI.Messages(this._client);
31
+ messages: MessagesAPI.Messages = new MessagesAPI.Messages(this._client);
30
32
  location: LocationAPI.Location = new LocationAPI.Location(this._client);
33
+ polls: PollsAPI.Polls = new PollsAPI.Polls(this._client);
31
34
 
32
35
  /**
33
36
  * Create a new chat with specified participants and send an initial message. The
@@ -122,46 +125,6 @@ export class Chats extends APIResource {
122
125
  return this._client.post('/v3/chats', { body, ...options });
123
126
  }
124
127
 
125
- /**
126
- * Retrieves a paginated list of chats for the authenticated partner.
127
- *
128
- * **Filtering:**
129
- *
130
- * - If `from` is provided, returns chats for that specific phone number
131
- * - If `from` is omitted, returns chats across all phone numbers owned by the
132
- * partner
133
- * - If `to` is provided, only returns chats where the specified handle is a
134
- * participant
135
- *
136
- * **Pagination:**
137
- *
138
- * - Use `limit` to control page size (default: 20, max: 100)
139
- * - The response includes `next_cursor` for fetching the next page
140
- * - When `next_cursor` is `null`, there are no more results to fetch
141
- * - Pass the `next_cursor` value as the `cursor` parameter for the next request
142
- *
143
- * **Example pagination flow:**
144
- *
145
- * 1. First request: `GET /v3/chats?from=%2B12223334444&limit=20`
146
- * 2. Response includes `next_cursor: "20"` (more results exist)
147
- * 3. Next request: `GET /v3/chats?from=%2B12223334444&limit=20&cursor=20`
148
- * 4. Response includes `next_cursor: null` (no more results)
149
- *
150
- * @example
151
- * ```ts
152
- * // Automatically fetches more pages as needed.
153
- * for await (const chat of client.chats.listChats()) {
154
- * // ...
155
- * }
156
- * ```
157
- */
158
- listChats(
159
- query: ChatListChatsParams | null | undefined = {},
160
- options?: RequestOptions,
161
- ): PagePromise<ChatsListChatsPagination, Chat> {
162
- return this._client.getAPIList('/v3/chats', ListChatsPagination<Chat>, { query, ...options });
163
- }
164
-
165
128
  /**
166
129
  * Retrieve a chat by its unique identifier.
167
130
  *
@@ -195,23 +158,6 @@ export class Chats extends APIResource {
195
158
  return this._client.put(path`/v3/chats/${chatID}`, { body, ...options });
196
159
  }
197
160
 
198
- /**
199
- * Mark all messages in a chat as read.
200
- *
201
- * @example
202
- * ```ts
203
- * await client.chats.markAsRead(
204
- * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
205
- * );
206
- * ```
207
- */
208
- markAsRead(chatID: string, options?: RequestOptions): APIPromise<void> {
209
- return this._client.post(path`/v3/chats/${chatID}/read`, {
210
- ...options,
211
- headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
212
- });
213
- }
214
-
215
161
  /**
216
162
  * Removes your phone number from a group chat. Once you leave, you will no longer
217
163
  * receive messages from the group and all interaction endpoints (send message,
@@ -239,21 +185,57 @@ export class Chats extends APIResource {
239
185
  }
240
186
 
241
187
  /**
242
- * Share your contact information (Name and Photo Sharing) with a chat.
188
+ * Retrieves a paginated list of chats for the authenticated partner.
243
189
  *
244
- * **Note:** A contact card must be configured before sharing. You can set up your
245
- * contact card via the [Contact Card API](#tag/Contact-Card) or on the
246
- * [Linq dashboard](https://dashboard.linqapp.com/contact-cards).
190
+ * **Filtering:**
191
+ *
192
+ * - If `from` is provided, returns chats for that specific phone number
193
+ * - If `from` is omitted, returns chats across all phone numbers owned by the
194
+ * partner
195
+ * - If `to` is provided, only returns chats where the specified handle is a
196
+ * participant
197
+ *
198
+ * **Pagination:**
199
+ *
200
+ * - Use `limit` to control page size (default: 20, max: 100)
201
+ * - The response includes `next_cursor` for fetching the next page
202
+ * - When `next_cursor` is `null`, there are no more results to fetch
203
+ * - Pass the `next_cursor` value as the `cursor` parameter for the next request
204
+ *
205
+ * **Example pagination flow:**
206
+ *
207
+ * 1. First request: `GET /v3/chats?from=%2B12223334444&limit=20`
208
+ * 2. Response includes `next_cursor: "20"` (more results exist)
209
+ * 3. Next request: `GET /v3/chats?from=%2B12223334444&limit=20&cursor=20`
210
+ * 4. Response includes `next_cursor: null` (no more results)
247
211
  *
248
212
  * @example
249
213
  * ```ts
250
- * await client.chats.shareContactCard(
214
+ * // Automatically fetches more pages as needed.
215
+ * for await (const chat of client.chats.listChats()) {
216
+ * // ...
217
+ * }
218
+ * ```
219
+ */
220
+ listChats(
221
+ query: ChatListChatsParams | null | undefined = {},
222
+ options?: RequestOptions,
223
+ ): PagePromise<ChatsListChatsPagination, Chat> {
224
+ return this._client.getAPIList('/v3/chats', ListChatsPagination<Chat>, { query, ...options });
225
+ }
226
+
227
+ /**
228
+ * Mark all messages in a chat as read.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * await client.chats.markAsRead(
251
233
  * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
252
234
  * );
253
235
  * ```
254
236
  */
255
- shareContactCard(chatID: string, options?: RequestOptions): APIPromise<void> {
256
- return this._client.post(path`/v3/chats/${chatID}/share_contact_card`, {
237
+ markAsRead(chatID: string, options?: RequestOptions): APIPromise<void> {
238
+ return this._client.post(path`/v3/chats/${chatID}/read`, {
257
239
  ...options,
258
240
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
259
241
  });
@@ -290,6 +272,27 @@ export class Chats extends APIResource {
290
272
  ): APIPromise<ChatSendVoicememoResponse> {
291
273
  return this._client.post(path`/v3/chats/${chatID}/voicememo`, { body, ...options });
292
274
  }
275
+
276
+ /**
277
+ * Share your contact information (Name and Photo Sharing) with a chat.
278
+ *
279
+ * **Note:** A contact card must be configured before sharing. You can set up your
280
+ * contact card via the [Contact Card API](#tag/Contact-Card) or on the
281
+ * [Linq dashboard](https://dashboard.linqapp.com/contact-cards).
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * await client.chats.shareContactCard(
286
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
287
+ * );
288
+ * ```
289
+ */
290
+ shareContactCard(chatID: string, options?: RequestOptions): APIPromise<void> {
291
+ return this._client.post(path`/v3/chats/${chatID}/share_contact_card`, {
292
+ ...options,
293
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
294
+ });
295
+ }
293
296
  }
294
297
 
295
298
  export type ChatsListChatsPagination = ListChatsPagination<Chat>;
@@ -383,6 +386,21 @@ export namespace Chat {
383
386
  * Current health bucket for the chat. See the
384
387
  * [Chat Health guide](/guides/chats/chat-health) for what each value means and how
385
388
  * to react. `doc_url` deep-links to the relevant section.
389
+ *
390
+ * `OPTED_OUT` is terminal — the recipient sent `STOP`, `UNSUBSCRIBE`, `OPTOUT`,
391
+ * `CANCEL`, `END`, or `QUIT`. The keyword must be the whole trimmed message, never
392
+ * part of a longer one: `STOP` counts, `please stop` does not. Most keywords must
393
+ * match exactly, including case. `OPT OUT` is the exception — it matches in any
394
+ * casing, with or without the space or a hyphen, so `opt out`, `Opt-Out` and
395
+ * `optout` all count. It clears if they later send `START`, `OPTIN`, or `UNSTOP`,
396
+ * or if they keep replying on the chat — sustained two-way conversation is treated
397
+ * as a sign the stop keyword was a false positive.
398
+ *
399
+ * Linq enforces this: while a recipient is opted out, every send to them is
400
+ * rejected with `403` (error code `2024`) before the message is queued, across
401
+ * every chat and every line on your account. Nothing is delivered, including a
402
+ * final courtesy message — to send one, set `override_optout: true` on that single
403
+ * request.
386
404
  */
387
405
  status: 'HEALTHY' | 'AT_RISK' | 'CRITICAL' | 'OPTED_OUT';
388
406
 
@@ -468,14 +486,26 @@ export interface MediaPart {
468
486
  * cannot coexist with text), so copy and a card are two sends, not one.
469
487
  */
470
488
  export interface MessageContent {
489
+ /**
490
+ * Invokes an action on an experience — a third party that renders inside Linq's
491
+ * iMessage app. Linq resolves the recipient's connection, mints any session the
492
+ * action needs, composes the card and sends it; none of that is visible to you.
493
+ *
494
+ * Call `GET /v3/experiences/{experience}` for the actions you may invoke and the
495
+ * fields each accepts.
496
+ */
497
+ action?: MessageContent.Action;
498
+
471
499
  /**
472
500
  * iMessage effect to apply to this message (screen or bubble effect)
473
501
  */
474
- effect?: MessagesAPI.MessageEffect;
502
+ effect?: ResourcesMessagesAPI.MessageEffect;
475
503
 
476
504
  /**
477
505
  * Optional idempotency key for this message. Use this to prevent duplicate sends
478
- * of the same message.
506
+ * of the same message. Reusing a key whose message was deleted — or was an
507
+ * ephemeral message that has since expired — returns 404; the message is never
508
+ * resent.
479
509
  */
480
510
  idempotency_key?: string;
481
511
 
@@ -528,10 +558,39 @@ export interface MessageContent {
528
558
  /**
529
559
  * Reply to another message to create a threaded conversation
530
560
  */
531
- reply_to?: MessagesAPI.ReplyTo;
561
+ reply_to?: ResourcesMessagesAPI.ReplyTo;
532
562
  }
533
563
 
534
564
  export namespace MessageContent {
565
+ /**
566
+ * Invokes an action on an experience — a third party that renders inside Linq's
567
+ * iMessage app. Linq resolves the recipient's connection, mints any session the
568
+ * action needs, composes the card and sends it; none of that is visible to you.
569
+ *
570
+ * Call `GET /v3/experiences/{experience}` for the actions you may invoke and the
571
+ * fields each accepts.
572
+ */
573
+ export interface Action {
574
+ /**
575
+ * Which of its actions, e.g. `attach_card`.
576
+ */
577
+ action: string;
578
+
579
+ /**
580
+ * The experience to invoke, e.g. `agentcard`.
581
+ */
582
+ experience: string;
583
+
584
+ /**
585
+ * Values for the fields this action exposes. Keys are exactly the field names
586
+ * listed for the action — no mapping, no nesting.
587
+ *
588
+ * Display copy only, except a `url`-type field — that value sets the destination,
589
+ * and must be an absolute `https` URL.
590
+ */
591
+ params?: { [key: string]: unknown };
592
+ }
593
+
535
594
  /**
536
595
  * An iMessage app card, backed by a Messages app extension. iMessage only — an
537
596
  * `imessage_app` part must be the **only** part in the message and is never
@@ -692,6 +751,26 @@ export interface TextPart {
692
751
  */
693
752
  value: string;
694
753
 
754
+ /**
755
+ * @mention a chat participant (iMessage group chats only). Set to their handle —
756
+ * E.164 phone number or Apple ID email. `value` is the display text; use the bare
757
+ * name (`"Juan"`, not `"@Juan"`). The mentioned participant is notified even if
758
+ * the chat is muted. Falls back to plain text over SMS/RCS.
759
+ *
760
+ * By default the entire `value` renders as the mention; use `mention_range` to
761
+ * highlight only part of it.
762
+ */
763
+ mention?: string;
764
+
765
+ /**
766
+ * Optional character range `[start, end)` in `value` that renders as the `mention`
767
+ * highlight (e.g. just the name in `"Hey Kevin, can you look at this?"`). Requires
768
+ * `mention`. Without it, the entire `value` is highlighted. `start` is inclusive,
769
+ * `end` is exclusive. _Characters are measured as UTF-16 code units. Most
770
+ * characters count as 1; some emoji count as 2._
771
+ */
772
+ mention_range?: Array<number>;
773
+
695
774
  /**
696
775
  * Optional array of text decorations applied to character ranges in the `value`
697
776
  * field (iMessage only).
@@ -763,7 +842,7 @@ export namespace ChatCreateResponse {
763
842
  /**
764
843
  * A message that was sent (used in CreateChat and SendMessage responses)
765
844
  */
766
- message: ChatsMessagesAPI.SentMessage;
845
+ message: MessagesAPI.SentMessage;
767
846
 
768
847
  /**
769
848
  * Messaging service type
@@ -795,6 +874,21 @@ export namespace ChatCreateResponse {
795
874
  * Current health bucket for the chat. See the
796
875
  * [Chat Health guide](/guides/chats/chat-health) for what each value means and how
797
876
  * to react. `doc_url` deep-links to the relevant section.
877
+ *
878
+ * `OPTED_OUT` is terminal — the recipient sent `STOP`, `UNSUBSCRIBE`, `OPTOUT`,
879
+ * `CANCEL`, `END`, or `QUIT`. The keyword must be the whole trimmed message, never
880
+ * part of a longer one: `STOP` counts, `please stop` does not. Most keywords must
881
+ * match exactly, including case. `OPT OUT` is the exception — it matches in any
882
+ * casing, with or without the space or a hyphen, so `opt out`, `Opt-Out` and
883
+ * `optout` all count. It clears if they later send `START`, `OPTIN`, or `UNSTOP`,
884
+ * or if they keep replying on the chat — sustained two-way conversation is treated
885
+ * as a sign the stop keyword was a false positive.
886
+ *
887
+ * Linq enforces this: while a recipient is opted out, every send to them is
888
+ * rejected with `403` (error code `2024`) before the message is queued, across
889
+ * every chat and every line on your account. Nothing is delivered, including a
890
+ * final courtesy message — to send one, set `override_optout: true` on that single
891
+ * request.
798
892
  */
799
893
  status: 'HEALTHY' | 'AT_RISK' | 'CRITICAL' | 'OPTED_OUT';
800
894
 
@@ -950,6 +1044,26 @@ export interface ChatCreateParams {
950
1044
  * For individual chats, provide one recipient. For group chats, provide multiple.
951
1045
  */
952
1046
  to: Array<string>;
1047
+
1048
+ /**
1049
+ * Send even though the recipient asked you to stop (`403`, error code `2024`).
1050
+ * Applies to this request only: the opt-out stays in place, so the next send
1051
+ * without this flag is rejected again. Every override is recorded against your API
1052
+ * key.
1053
+ */
1054
+ override_optout?: boolean;
1055
+ }
1056
+
1057
+ export interface ChatUpdateParams {
1058
+ /**
1059
+ * New display name for the chat (group chats only)
1060
+ */
1061
+ display_name?: string;
1062
+
1063
+ /**
1064
+ * URL of an image to set as the group chat icon (group chats only)
1065
+ */
1066
+ group_chat_icon?: string;
953
1067
  }
954
1068
 
955
1069
  export interface ChatListChatsParams extends ListChatsPaginationParams {
@@ -970,18 +1084,6 @@ export interface ChatListChatsParams extends ListChatsPaginationParams {
970
1084
  to?: string;
971
1085
  }
972
1086
 
973
- export interface ChatUpdateParams {
974
- /**
975
- * New display name for the chat (group chats only)
976
- */
977
- display_name?: string;
978
-
979
- /**
980
- * URL of an image to set as the group chat icon (group chats only)
981
- */
982
- group_chat_icon?: string;
983
- }
984
-
985
1087
  export interface ChatSendVoicememoParams {
986
1088
  /**
987
1089
  * Reference to a voice memo file pre-uploaded via `POST /v3/attachments`. The file
@@ -991,6 +1093,14 @@ export interface ChatSendVoicememoParams {
991
1093
  */
992
1094
  attachment_id?: string;
993
1095
 
1096
+ /**
1097
+ * Send even though the recipient asked you to stop (`403`, error code `2024`).
1098
+ * Applies to this request only: the opt-out stays in place, so the next send
1099
+ * without this flag is rejected again. Every override is recorded against your API
1100
+ * key.
1101
+ */
1102
+ override_optout?: boolean;
1103
+
994
1104
  /**
995
1105
  * URL of the voice memo audio file. Must be a publicly accessible HTTPS URL.
996
1106
  *
@@ -1003,6 +1113,7 @@ Chats.Participants = Participants;
1003
1113
  Chats.Typing = Typing;
1004
1114
  Chats.Messages = Messages;
1005
1115
  Chats.Location = Location;
1116
+ Chats.Polls = Polls;
1006
1117
 
1007
1118
  export declare namespace Chats {
1008
1119
  export {
@@ -1017,8 +1128,8 @@ export declare namespace Chats {
1017
1128
  type ChatSendVoicememoResponse as ChatSendVoicememoResponse,
1018
1129
  type ChatsListChatsPagination as ChatsListChatsPagination,
1019
1130
  type ChatCreateParams as ChatCreateParams,
1020
- type ChatListChatsParams as ChatListChatsParams,
1021
1131
  type ChatUpdateParams as ChatUpdateParams,
1132
+ type ChatListChatsParams as ChatListChatsParams,
1022
1133
  type ChatSendVoicememoParams as ChatSendVoicememoParams,
1023
1134
  };
1024
1135
 
@@ -1036,8 +1147,8 @@ export declare namespace Chats {
1036
1147
  Messages as Messages,
1037
1148
  type SentMessage as SentMessage,
1038
1149
  type MessageSendResponse as MessageSendResponse,
1039
- type MessageSendParams as MessageSendParams,
1040
1150
  type MessageListParams as MessageListParams,
1151
+ type MessageSendParams as MessageSendParams,
1041
1152
  };
1042
1153
 
1043
1154
  export {
@@ -1045,4 +1156,11 @@ export declare namespace Chats {
1045
1156
  type GetChatLocationResponse as GetChatLocationResponse,
1046
1157
  type LocationRequestResponse as LocationRequestResponse,
1047
1158
  };
1159
+
1160
+ export {
1161
+ Polls as Polls,
1162
+ type Poll as Poll,
1163
+ type PollEnvelope as PollEnvelope,
1164
+ type PollCreateParams as PollCreateParams,
1165
+ };
1048
1166
  }
@@ -12,8 +12,8 @@ export {
12
12
  type ChatLeaveChatResponse,
13
13
  type ChatSendVoicememoResponse,
14
14
  type ChatCreateParams,
15
- type ChatListChatsParams,
16
15
  type ChatUpdateParams,
16
+ type ChatListChatsParams,
17
17
  type ChatSendVoicememoParams,
18
18
  type ChatsListChatsPagination,
19
19
  } from './chats';
@@ -22,8 +22,8 @@ export {
22
22
  Messages,
23
23
  type SentMessage,
24
24
  type MessageSendResponse,
25
- type MessageSendParams,
26
25
  type MessageListParams,
26
+ type MessageSendParams,
27
27
  } from './messages';
28
28
  export {
29
29
  Participants,
@@ -32,4 +32,5 @@ export {
32
32
  type ParticipantAddParams,
33
33
  type ParticipantRemoveParams,
34
34
  } from './participants';
35
+ export { Polls, type Poll, type PollEnvelope, type PollCreateParams } from './polls';
35
36
  export { Typing } from './typing';
@@ -45,34 +45,6 @@ import { path } from '../../internal/utils/path';
45
45
  * Messages conversation** with your number.
46
46
  */
47
47
  export class Location extends APIResource {
48
- /**
49
- * Request a contact in a chat to share their location. They receive an iMessage
50
- * prompt and must accept before any location is available; once they do, read
51
- * their location coordinates with `GET /v3/chats/{chatId}/location`.
52
- *
53
- * The request is delivered asynchronously. The endpoint returns immediately with
54
- * `{ "success": true, "message": "Location request sent" }` and does not return
55
- * coordinates.
56
- *
57
- * Location requests only work in **1:1 iMessage chats** (Apple limitation):
58
- *
59
- * - Group chats (any service) return `409` with code `2016`
60
- * (`GroupChatNotSupported`).
61
- * - 1:1 SMS and RCS chats return `409` with code `2017`
62
- * (`ChatServiceNotSupported`).
63
- *
64
- * @example
65
- * ```ts
66
- * const locationRequestResponse =
67
- * await client.chats.location.request(
68
- * '975d0776-bd17-4273-8337-f346b4c661b0',
69
- * );
70
- * ```
71
- */
72
- request(chatID: string, options?: RequestOptions): APIPromise<LocationRequestResponse> {
73
- return this._client.post(path`/v3/chats/${chatID}/location/request`, options);
74
- }
75
-
76
48
  /**
77
49
  * Retrieve the current location for contacts sharing with you in a chat.
78
50
  *
@@ -107,6 +79,34 @@ export class Location extends APIResource {
107
79
  headers: buildHeaders([{ Accept: 'application/geo+json' }, options?.headers]),
108
80
  });
109
81
  }
82
+
83
+ /**
84
+ * Request a contact in a chat to share their location. They receive an iMessage
85
+ * prompt and must accept before any location is available; once they do, read
86
+ * their location coordinates with `GET /v3/chats/{chatId}/location`.
87
+ *
88
+ * The request is delivered asynchronously. The endpoint returns immediately with
89
+ * `{ "success": true, "message": "Location request sent" }` and does not return
90
+ * coordinates.
91
+ *
92
+ * Location requests only work in **1:1 iMessage chats** (Apple limitation):
93
+ *
94
+ * - Group chats (any service) return `409` with code `2016`
95
+ * (`GroupChatNotSupported`).
96
+ * - 1:1 SMS and RCS chats return `409` with code `2017`
97
+ * (`ChatServiceNotSupported`).
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const locationRequestResponse =
102
+ * await client.chats.location.request(
103
+ * '975d0776-bd17-4273-8337-f346b4c661b0',
104
+ * );
105
+ * ```
106
+ */
107
+ request(chatID: string, options?: RequestOptions): APIPromise<LocationRequestResponse> {
108
+ return this._client.post(path`/v3/chats/${chatID}/location/request`, options);
109
+ }
110
110
  }
111
111
 
112
112
  export interface GetChatLocationResponse {
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../../core/resource';
4
- import * as MessagesAPI from '../messages';
5
- import { MessagesListMessagesPagination } from '../messages';
6
4
  import * as Shared from '../shared';
7
5
  import * as ChatsAPI from './chats';
6
+ import * as ResourcesMessagesAPI from '../messages/messages';
7
+ import { MessagesListMessagesPagination } from '../messages/messages';
8
8
  import { APIPromise } from '../../core/api-promise';
9
9
  import {
10
10
  ListMessagesPagination,
@@ -75,6 +75,31 @@ import { path } from '../../internal/utils/path';
75
75
  * **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.
76
76
  */
77
77
  export class Messages extends APIResource {
78
+ /**
79
+ * Retrieve messages from a specific chat with pagination support.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * // Automatically fetches more pages as needed.
84
+ * for await (const message of client.chats.messages.list(
85
+ * '550e8400-e29b-41d4-a716-446655440000',
86
+ * )) {
87
+ * // ...
88
+ * }
89
+ * ```
90
+ */
91
+ list(
92
+ chatID: string,
93
+ query: MessageListParams | null | undefined = {},
94
+ options?: RequestOptions,
95
+ ): PagePromise<MessagesListMessagesPagination, ResourcesMessagesAPI.Message> {
96
+ return this._client.getAPIList(
97
+ path`/v3/chats/${chatID}/messages`,
98
+ ListMessagesPagination<ResourcesMessagesAPI.Message>,
99
+ { query, ...options },
100
+ );
101
+ }
102
+
78
103
  /**
79
104
  * Send a message to an existing chat. Use this endpoint when you already have a
80
105
  * chat ID and want to send additional messages to it.
@@ -134,31 +159,6 @@ export class Messages extends APIResource {
134
159
  send(chatID: string, body: MessageSendParams, options?: RequestOptions): APIPromise<MessageSendResponse> {
135
160
  return this._client.post(path`/v3/chats/${chatID}/messages`, { body, ...options });
136
161
  }
137
-
138
- /**
139
- * Retrieve messages from a specific chat with pagination support.
140
- *
141
- * @example
142
- * ```ts
143
- * // Automatically fetches more pages as needed.
144
- * for await (const message of client.chats.messages.list(
145
- * '550e8400-e29b-41d4-a716-446655440000',
146
- * )) {
147
- * // ...
148
- * }
149
- * ```
150
- */
151
- list(
152
- chatID: string,
153
- query: MessageListParams | null | undefined = {},
154
- options?: RequestOptions,
155
- ): PagePromise<MessagesListMessagesPagination, MessagesAPI.Message> {
156
- return this._client.getAPIList(
157
- path`/v3/chats/${chatID}/messages`,
158
- ListMessagesPagination<MessagesAPI.Message>,
159
- { query, ...options },
160
- );
161
- }
162
162
  }
163
163
 
164
164
  /**
@@ -209,7 +209,7 @@ export interface SentMessage {
209
209
  /**
210
210
  * iMessage effect applied to a message (screen or bubble effect)
211
211
  */
212
- effect?: MessagesAPI.MessageEffect | null;
212
+ effect?: ResourcesMessagesAPI.MessageEffect | null;
213
213
 
214
214
  /**
215
215
  * The sender of this message as a full handle object
@@ -224,7 +224,7 @@ export interface SentMessage {
224
224
  /**
225
225
  * Indicates this message is a threaded reply to another message
226
226
  */
227
- reply_to?: MessagesAPI.ReplyTo | null;
227
+ reply_to?: ResourcesMessagesAPI.ReplyTo | null;
228
228
 
229
229
  /**
230
230
  * Messaging service type
@@ -384,6 +384,8 @@ export interface MessageSendResponse {
384
384
  message: SentMessage;
385
385
  }
386
386
 
387
+ export interface MessageListParams extends ListMessagesPaginationParams {}
388
+
387
389
  export interface MessageSendParams {
388
390
  /**
389
391
  * Message content container. Groups all message-related fields together,
@@ -396,16 +398,22 @@ export interface MessageSendParams {
396
398
  * cannot coexist with text), so copy and a card are two sends, not one.
397
399
  */
398
400
  message: ChatsAPI.MessageContent;
399
- }
400
401
 
401
- export interface MessageListParams extends ListMessagesPaginationParams {}
402
+ /**
403
+ * Send even though the recipient asked you to stop (`403`, error code `2024`).
404
+ * Applies to this request only: the opt-out stays in place, so the next send
405
+ * without this flag is rejected again. Every override is recorded against your API
406
+ * key.
407
+ */
408
+ override_optout?: boolean;
409
+ }
402
410
 
403
411
  export declare namespace Messages {
404
412
  export {
405
413
  type SentMessage as SentMessage,
406
414
  type MessageSendResponse as MessageSendResponse,
407
- type MessageSendParams as MessageSendParams,
408
415
  type MessageListParams as MessageListParams,
416
+ type MessageSendParams as MessageSendParams,
409
417
  };
410
418
  }
411
419