@linqapp/sdk 0.32.0 → 0.33.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 (148) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/client.d.mts +41 -5
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +41 -5
  5. package/client.d.ts.map +1 -1
  6. package/client.js +38 -2
  7. package/client.js.map +1 -1
  8. package/client.mjs +38 -2
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/available-number.d.mts +13 -1
  12. package/resources/available-number.d.mts.map +1 -1
  13. package/resources/available-number.d.ts +13 -1
  14. package/resources/available-number.d.ts.map +1 -1
  15. package/resources/available-number.js +2 -1
  16. package/resources/available-number.js.map +1 -1
  17. package/resources/available-number.mjs +2 -1
  18. package/resources/available-number.mjs.map +1 -1
  19. package/resources/chats/chats.d.mts +125 -64
  20. package/resources/chats/chats.d.mts.map +1 -1
  21. package/resources/chats/chats.d.ts +125 -64
  22. package/resources/chats/chats.d.ts.map +1 -1
  23. package/resources/chats/chats.js +59 -59
  24. package/resources/chats/chats.js.map +1 -1
  25. package/resources/chats/chats.mjs +59 -59
  26. package/resources/chats/chats.mjs.map +1 -1
  27. package/resources/chats/index.d.mts +2 -2
  28. package/resources/chats/index.d.mts.map +1 -1
  29. package/resources/chats/index.d.ts +2 -2
  30. package/resources/chats/index.d.ts.map +1 -1
  31. package/resources/chats/location.d.mts +25 -25
  32. package/resources/chats/location.d.mts.map +1 -1
  33. package/resources/chats/location.d.ts +25 -25
  34. package/resources/chats/location.d.ts.map +1 -1
  35. package/resources/chats/location.js +27 -27
  36. package/resources/chats/location.js.map +1 -1
  37. package/resources/chats/location.mjs +27 -27
  38. package/resources/chats/location.mjs.map +1 -1
  39. package/resources/chats/messages.d.mts +17 -17
  40. package/resources/chats/messages.d.mts.map +1 -1
  41. package/resources/chats/messages.d.ts +17 -17
  42. package/resources/chats/messages.d.ts.map +1 -1
  43. package/resources/chats/messages.js +16 -16
  44. package/resources/chats/messages.js.map +1 -1
  45. package/resources/chats/messages.mjs +16 -16
  46. package/resources/chats/messages.mjs.map +1 -1
  47. package/resources/contact-card.d.mts +29 -28
  48. package/resources/contact-card.d.mts.map +1 -1
  49. package/resources/contact-card.d.ts +29 -28
  50. package/resources/contact-card.d.ts.map +1 -1
  51. package/resources/contact-card.js +23 -22
  52. package/resources/contact-card.js.map +1 -1
  53. package/resources/contact-card.mjs +23 -22
  54. package/resources/contact-card.mjs.map +1 -1
  55. package/resources/experiences.d.mts +91 -0
  56. package/resources/experiences.d.mts.map +1 -0
  57. package/resources/experiences.d.ts +91 -0
  58. package/resources/experiences.d.ts.map +1 -0
  59. package/resources/experiences.js +29 -0
  60. package/resources/experiences.js.map +1 -0
  61. package/resources/experiences.mjs +25 -0
  62. package/resources/experiences.mjs.map +1 -0
  63. package/resources/index.d.mts +7 -3
  64. package/resources/index.d.mts.map +1 -1
  65. package/resources/index.d.ts +7 -3
  66. package/resources/index.d.ts.map +1 -1
  67. package/resources/index.js +9 -1
  68. package/resources/index.js.map +1 -1
  69. package/resources/index.mjs +4 -0
  70. package/resources/index.mjs.map +1 -1
  71. package/resources/messages.d.mts +71 -35
  72. package/resources/messages.d.mts.map +1 -1
  73. package/resources/messages.d.ts +71 -35
  74. package/resources/messages.d.ts.map +1 -1
  75. package/resources/messages.js +41 -30
  76. package/resources/messages.js.map +1 -1
  77. package/resources/messages.mjs +41 -30
  78. package/resources/messages.mjs.map +1 -1
  79. package/resources/payment-handles.d.mts +87 -0
  80. package/resources/payment-handles.d.mts.map +1 -0
  81. package/resources/payment-handles.d.ts +87 -0
  82. package/resources/payment-handles.d.ts.map +1 -0
  83. package/resources/payment-handles.js +76 -0
  84. package/resources/payment-handles.js.map +1 -0
  85. package/resources/payment-handles.mjs +72 -0
  86. package/resources/payment-handles.mjs.map +1 -0
  87. package/resources/payment-providers.d.mts +58 -0
  88. package/resources/payment-providers.d.mts.map +1 -0
  89. package/resources/payment-providers.d.ts +58 -0
  90. package/resources/payment-providers.d.ts.map +1 -0
  91. package/resources/payment-providers.js +45 -0
  92. package/resources/payment-providers.js.map +1 -0
  93. package/resources/payment-providers.mjs +41 -0
  94. package/resources/payment-providers.mjs.map +1 -0
  95. package/resources/payment-requests.d.mts +2 -2
  96. package/resources/payment-requests.d.ts +2 -2
  97. package/resources/payment-requests.js +2 -2
  98. package/resources/payment-requests.mjs +2 -2
  99. package/resources/payments.d.mts +116 -0
  100. package/resources/payments.d.mts.map +1 -0
  101. package/resources/payments.d.ts +116 -0
  102. package/resources/payments.d.ts.map +1 -0
  103. package/resources/payments.js +70 -0
  104. package/resources/payments.js.map +1 -0
  105. package/resources/payments.mjs +66 -0
  106. package/resources/payments.mjs.map +1 -0
  107. package/resources/phone-numbers.d.mts +11 -11
  108. package/resources/phone-numbers.d.mts.map +1 -1
  109. package/resources/phone-numbers.d.ts +11 -11
  110. package/resources/phone-numbers.d.ts.map +1 -1
  111. package/resources/phone-numbers.js +13 -13
  112. package/resources/phone-numbers.js.map +1 -1
  113. package/resources/phone-numbers.mjs +13 -13
  114. package/resources/phone-numbers.mjs.map +1 -1
  115. package/resources/webhook-subscriptions.d.mts +11 -11
  116. package/resources/webhook-subscriptions.d.mts.map +1 -1
  117. package/resources/webhook-subscriptions.d.ts +11 -11
  118. package/resources/webhook-subscriptions.d.ts.map +1 -1
  119. package/resources/webhook-subscriptions.js +13 -13
  120. package/resources/webhook-subscriptions.js.map +1 -1
  121. package/resources/webhook-subscriptions.mjs +13 -13
  122. package/resources/webhook-subscriptions.mjs.map +1 -1
  123. package/resources/webhooks.d.mts +59 -0
  124. package/resources/webhooks.d.mts.map +1 -1
  125. package/resources/webhooks.d.ts +59 -0
  126. package/resources/webhooks.d.ts.map +1 -1
  127. package/src/client.ts +77 -6
  128. package/src/resources/available-number.ts +14 -1
  129. package/src/resources/chats/chats.ts +142 -79
  130. package/src/resources/chats/index.ts +2 -2
  131. package/src/resources/chats/location.ts +28 -28
  132. package/src/resources/chats/messages.ts +28 -28
  133. package/src/resources/contact-card.ts +36 -35
  134. package/src/resources/experiences.ts +118 -0
  135. package/src/resources/index.ts +22 -4
  136. package/src/resources/messages.ts +85 -47
  137. package/src/resources/payment-handles.ts +114 -0
  138. package/src/resources/payment-providers.ts +81 -0
  139. package/src/resources/payment-requests.ts +2 -2
  140. package/src/resources/payments.ts +163 -0
  141. package/src/resources/phone-numbers.ts +14 -14
  142. package/src/resources/webhook-subscriptions.ts +14 -14
  143. package/src/resources/webhooks.ts +61 -0
  144. package/src/version.ts +1 -1
  145. package/version.d.mts +1 -1
  146. package/version.d.ts +1 -1
  147. package/version.js +1 -1
  148. package/version.mjs +1 -1
@@ -122,46 +122,6 @@ export class Chats extends APIResource {
122
122
  return this._client.post('/v3/chats', { body, ...options });
123
123
  }
124
124
 
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
125
  /**
166
126
  * Retrieve a chat by its unique identifier.
167
127
  *
@@ -195,23 +155,6 @@ export class Chats extends APIResource {
195
155
  return this._client.put(path`/v3/chats/${chatID}`, { body, ...options });
196
156
  }
197
157
 
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
158
  /**
216
159
  * Removes your phone number from a group chat. Once you leave, you will no longer
217
160
  * receive messages from the group and all interaction endpoints (send message,
@@ -239,21 +182,57 @@ export class Chats extends APIResource {
239
182
  }
240
183
 
241
184
  /**
242
- * Share your contact information (Name and Photo Sharing) with a chat.
185
+ * Retrieves a paginated list of chats for the authenticated partner.
243
186
  *
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).
187
+ * **Filtering:**
188
+ *
189
+ * - If `from` is provided, returns chats for that specific phone number
190
+ * - If `from` is omitted, returns chats across all phone numbers owned by the
191
+ * partner
192
+ * - If `to` is provided, only returns chats where the specified handle is a
193
+ * participant
194
+ *
195
+ * **Pagination:**
196
+ *
197
+ * - Use `limit` to control page size (default: 20, max: 100)
198
+ * - The response includes `next_cursor` for fetching the next page
199
+ * - When `next_cursor` is `null`, there are no more results to fetch
200
+ * - Pass the `next_cursor` value as the `cursor` parameter for the next request
201
+ *
202
+ * **Example pagination flow:**
203
+ *
204
+ * 1. First request: `GET /v3/chats?from=%2B12223334444&limit=20`
205
+ * 2. Response includes `next_cursor: "20"` (more results exist)
206
+ * 3. Next request: `GET /v3/chats?from=%2B12223334444&limit=20&cursor=20`
207
+ * 4. Response includes `next_cursor: null` (no more results)
247
208
  *
248
209
  * @example
249
210
  * ```ts
250
- * await client.chats.shareContactCard(
211
+ * // Automatically fetches more pages as needed.
212
+ * for await (const chat of client.chats.listChats()) {
213
+ * // ...
214
+ * }
215
+ * ```
216
+ */
217
+ listChats(
218
+ query: ChatListChatsParams | null | undefined = {},
219
+ options?: RequestOptions,
220
+ ): PagePromise<ChatsListChatsPagination, Chat> {
221
+ return this._client.getAPIList('/v3/chats', ListChatsPagination<Chat>, { query, ...options });
222
+ }
223
+
224
+ /**
225
+ * Mark all messages in a chat as read.
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * await client.chats.markAsRead(
251
230
  * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
252
231
  * );
253
232
  * ```
254
233
  */
255
- shareContactCard(chatID: string, options?: RequestOptions): APIPromise<void> {
256
- return this._client.post(path`/v3/chats/${chatID}/share_contact_card`, {
234
+ markAsRead(chatID: string, options?: RequestOptions): APIPromise<void> {
235
+ return this._client.post(path`/v3/chats/${chatID}/read`, {
257
236
  ...options,
258
237
  headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
259
238
  });
@@ -290,6 +269,27 @@ export class Chats extends APIResource {
290
269
  ): APIPromise<ChatSendVoicememoResponse> {
291
270
  return this._client.post(path`/v3/chats/${chatID}/voicememo`, { body, ...options });
292
271
  }
272
+
273
+ /**
274
+ * Share your contact information (Name and Photo Sharing) with a chat.
275
+ *
276
+ * **Note:** A contact card must be configured before sharing. You can set up your
277
+ * contact card via the [Contact Card API](#tag/Contact-Card) or on the
278
+ * [Linq dashboard](https://dashboard.linqapp.com/contact-cards).
279
+ *
280
+ * @example
281
+ * ```ts
282
+ * await client.chats.shareContactCard(
283
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
284
+ * );
285
+ * ```
286
+ */
287
+ shareContactCard(chatID: string, options?: RequestOptions): APIPromise<void> {
288
+ return this._client.post(path`/v3/chats/${chatID}/share_contact_card`, {
289
+ ...options,
290
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
291
+ });
292
+ }
293
293
  }
294
294
 
295
295
  export type ChatsListChatsPagination = ListChatsPagination<Chat>;
@@ -383,6 +383,17 @@ export namespace Chat {
383
383
  * Current health bucket for the chat. See the
384
384
  * [Chat Health guide](/guides/chats/chat-health) for what each value means and how
385
385
  * to react. `doc_url` deep-links to the relevant section.
386
+ *
387
+ * `OPTED_OUT` is terminal — the recipient sent `STOP`, `UNSUBSCRIBE`, `OPTOUT`,
388
+ * `CANCEL`, `END`, or `QUIT`, and you should send nothing further on this chat.
389
+ * The keyword must be the whole trimmed message, never part of a longer one:
390
+ * `STOP` counts, `please stop` does not. Most keywords must match exactly,
391
+ * including case. `OPT OUT` is the exception — it matches in any casing, with or
392
+ * without the space or a hyphen, so `opt out`, `Opt-Out` and `optout` all count.
393
+ * It clears if they later send `START`, `OPTIN`, or `UNSTOP`, or if they keep
394
+ * replying on the chat — sustained two-way conversation is treated as a sign the
395
+ * stop keyword was a false positive. Suppressing sends to opted-out recipients is
396
+ * your responsibility — Linq surfaces the status but does not block the send.
386
397
  */
387
398
  status: 'HEALTHY' | 'AT_RISK' | 'CRITICAL' | 'OPTED_OUT';
388
399
 
@@ -468,6 +479,16 @@ export interface MediaPart {
468
479
  * cannot coexist with text), so copy and a card are two sends, not one.
469
480
  */
470
481
  export interface MessageContent {
482
+ /**
483
+ * Invokes an action on an experience — a third party that renders inside Linq's
484
+ * iMessage app. Linq resolves the recipient's connection, mints any session the
485
+ * action needs, composes the card and sends it; none of that is visible to you.
486
+ *
487
+ * Call `GET /v3/experiences/{experience}` for the actions you may invoke and the
488
+ * fields each accepts.
489
+ */
490
+ action?: MessageContent.Action;
491
+
471
492
  /**
472
493
  * iMessage effect to apply to this message (screen or bubble effect)
473
494
  */
@@ -475,7 +496,9 @@ export interface MessageContent {
475
496
 
476
497
  /**
477
498
  * Optional idempotency key for this message. Use this to prevent duplicate sends
478
- * of the same message.
499
+ * of the same message. Reusing a key whose message was deleted — or was an
500
+ * ephemeral message that has since expired — returns 404; the message is never
501
+ * resent.
479
502
  */
480
503
  idempotency_key?: string;
481
504
 
@@ -532,6 +555,35 @@ export interface MessageContent {
532
555
  }
533
556
 
534
557
  export namespace MessageContent {
558
+ /**
559
+ * Invokes an action on an experience — a third party that renders inside Linq's
560
+ * iMessage app. Linq resolves the recipient's connection, mints any session the
561
+ * action needs, composes the card and sends it; none of that is visible to you.
562
+ *
563
+ * Call `GET /v3/experiences/{experience}` for the actions you may invoke and the
564
+ * fields each accepts.
565
+ */
566
+ export interface Action {
567
+ /**
568
+ * Which of its actions, e.g. `attach_card`.
569
+ */
570
+ action: string;
571
+
572
+ /**
573
+ * The experience to invoke, e.g. `agentcard`.
574
+ */
575
+ experience: string;
576
+
577
+ /**
578
+ * Values for the fields this action exposes. Keys are exactly the field names
579
+ * listed for the action — no mapping, no nesting.
580
+ *
581
+ * Display copy only, except a `url`-type field — that value sets the destination,
582
+ * and must be an absolute `https` URL.
583
+ */
584
+ params?: { [key: string]: unknown };
585
+ }
586
+
535
587
  /**
536
588
  * An iMessage app card, backed by a Messages app extension. iMessage only — an
537
589
  * `imessage_app` part must be the **only** part in the message and is never
@@ -795,6 +847,17 @@ export namespace ChatCreateResponse {
795
847
  * Current health bucket for the chat. See the
796
848
  * [Chat Health guide](/guides/chats/chat-health) for what each value means and how
797
849
  * to react. `doc_url` deep-links to the relevant section.
850
+ *
851
+ * `OPTED_OUT` is terminal — the recipient sent `STOP`, `UNSUBSCRIBE`, `OPTOUT`,
852
+ * `CANCEL`, `END`, or `QUIT`, and you should send nothing further on this chat.
853
+ * The keyword must be the whole trimmed message, never part of a longer one:
854
+ * `STOP` counts, `please stop` does not. Most keywords must match exactly,
855
+ * including case. `OPT OUT` is the exception — it matches in any casing, with or
856
+ * without the space or a hyphen, so `opt out`, `Opt-Out` and `optout` all count.
857
+ * It clears if they later send `START`, `OPTIN`, or `UNSTOP`, or if they keep
858
+ * replying on the chat — sustained two-way conversation is treated as a sign the
859
+ * stop keyword was a false positive. Suppressing sends to opted-out recipients is
860
+ * your responsibility — Linq surfaces the status but does not block the send.
798
861
  */
799
862
  status: 'HEALTHY' | 'AT_RISK' | 'CRITICAL' | 'OPTED_OUT';
800
863
 
@@ -952,6 +1015,18 @@ export interface ChatCreateParams {
952
1015
  to: Array<string>;
953
1016
  }
954
1017
 
1018
+ export interface ChatUpdateParams {
1019
+ /**
1020
+ * New display name for the chat (group chats only)
1021
+ */
1022
+ display_name?: string;
1023
+
1024
+ /**
1025
+ * URL of an image to set as the group chat icon (group chats only)
1026
+ */
1027
+ group_chat_icon?: string;
1028
+ }
1029
+
955
1030
  export interface ChatListChatsParams extends ListChatsPaginationParams {
956
1031
  /**
957
1032
  * Phone number to filter chats by. Returns chats made from this phone number. Must
@@ -970,18 +1045,6 @@ export interface ChatListChatsParams extends ListChatsPaginationParams {
970
1045
  to?: string;
971
1046
  }
972
1047
 
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
1048
  export interface ChatSendVoicememoParams {
986
1049
  /**
987
1050
  * Reference to a voice memo file pre-uploaded via `POST /v3/attachments`. The file
@@ -1017,8 +1080,8 @@ export declare namespace Chats {
1017
1080
  type ChatSendVoicememoResponse as ChatSendVoicememoResponse,
1018
1081
  type ChatsListChatsPagination as ChatsListChatsPagination,
1019
1082
  type ChatCreateParams as ChatCreateParams,
1020
- type ChatListChatsParams as ChatListChatsParams,
1021
1083
  type ChatUpdateParams as ChatUpdateParams,
1084
+ type ChatListChatsParams as ChatListChatsParams,
1022
1085
  type ChatSendVoicememoParams as ChatSendVoicememoParams,
1023
1086
  };
1024
1087
 
@@ -1036,8 +1099,8 @@ export declare namespace Chats {
1036
1099
  Messages as Messages,
1037
1100
  type SentMessage as SentMessage,
1038
1101
  type MessageSendResponse as MessageSendResponse,
1039
- type MessageSendParams as MessageSendParams,
1040
1102
  type MessageListParams as MessageListParams,
1103
+ type MessageSendParams as MessageSendParams,
1041
1104
  };
1042
1105
 
1043
1106
  export {
@@ -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,
@@ -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 {
@@ -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, MessagesAPI.Message> {
96
+ return this._client.getAPIList(
97
+ path`/v3/chats/${chatID}/messages`,
98
+ ListMessagesPagination<MessagesAPI.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
  /**
@@ -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,
@@ -398,14 +400,12 @@ export interface MessageSendParams {
398
400
  message: ChatsAPI.MessageContent;
399
401
  }
400
402
 
401
- export interface MessageListParams extends ListMessagesPaginationParams {}
402
-
403
403
  export declare namespace Messages {
404
404
  export {
405
405
  type SentMessage as SentMessage,
406
406
  type MessageSendResponse as MessageSendResponse,
407
- type MessageSendParams as MessageSendParams,
408
407
  type MessageListParams as MessageListParams,
408
+ type MessageSendParams as MessageSendParams,
409
409
  };
410
410
  }
411
411
 
@@ -14,32 +14,16 @@ import { RequestOptions } from '../internal/request-options';
14
14
  * **Sharing behavior:** Sharing may not take effect in every chat due to limitations outside our control. We recommend calling the share endpoint once per day, after the first outbound activity.
15
15
  */
16
16
  export class ContactCard extends APIResource {
17
- /**
18
- * Returns the contact card for a specific phone number, or all contact cards for
19
- * the authenticated partner if no `phone_number` is provided.
20
- *
21
- * @example
22
- * ```ts
23
- * const contactCard = await client.contactCard.retrieve();
24
- * ```
25
- */
26
- retrieve(
27
- query: ContactCardRetrieveParams | null | undefined = {},
28
- options?: RequestOptions,
29
- ): APIPromise<ContactCardRetrieveResponse> {
30
- return this._client.get('/v3/contact_card', { query, ...options });
31
- }
32
-
33
17
  /**
34
18
  * Creates a contact card for a phone number. This endpoint is intended for
35
19
  * initial, one-time setup only.
36
20
  *
37
- * The contact card is stored in an inactive state first. Once it's applied
38
- * successfully, it is activated and `is_active` is returned as `true`. On failure,
39
- * `is_active` is `false`.
21
+ * If setup does not complete, the response is `500` (`2022`) — call this endpoint
22
+ * again.
40
23
  *
41
- * **Note:** To update an existing contact card after setup, use
42
- * `PATCH /v3/contact_card` instead.
24
+ * **Note:** once a card is active, this endpoint returns `409` (`2014`) so an
25
+ * existing card is never overwritten by accident. Use `PATCH /v3/contact_card` to
26
+ * change it.
43
27
  *
44
28
  * @example
45
29
  * ```ts
@@ -57,13 +41,30 @@ export class ContactCard extends APIResource {
57
41
  }
58
42
 
59
43
  /**
60
- * Partially updates an existing active contact card for a phone number.
44
+ * Returns the contact card for a specific phone number, or all contact cards for
45
+ * the authenticated partner if no `phone_number` is provided.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const contactCard = await client.contactCard.retrieve();
50
+ * ```
51
+ */
52
+ retrieve(
53
+ query: ContactCardRetrieveParams | null | undefined = {},
54
+ options?: RequestOptions,
55
+ ): APIPromise<ContactCardRetrieveResponse> {
56
+ return this._client.get('/v3/contact_card', { query, ...options });
57
+ }
58
+
59
+ /**
60
+ * Partially updates the contact card for a phone number.
61
61
  *
62
- * Fetches the current active contact card and merges the provided fields. Only
63
- * fields present in the request body are updated; omitted fields retain their
64
- * existing values.
62
+ * Fetches the current contact card and merges the provided fields. Only fields
63
+ * present in the request body are updated; omitted fields retain their existing
64
+ * values.
65
65
  *
66
- * Requires an active contact card to exist for the phone number.
66
+ * If the update does not complete, the response is `500` (`2022`) — call this
67
+ * endpoint again.
67
68
  *
68
69
  * @example
69
70
  * ```ts
@@ -127,14 +128,6 @@ export namespace ContactCardRetrieveResponse {
127
128
  }
128
129
  }
129
130
 
130
- export interface ContactCardRetrieveParams {
131
- /**
132
- * E.164 phone number to filter by. If omitted, all my cards for the partner are
133
- * returned.
134
- */
135
- phone_number?: string;
136
- }
137
-
138
131
  export interface ContactCardCreateParams {
139
132
  /**
140
133
  * First name for the contact card. Required.
@@ -157,6 +150,14 @@ export interface ContactCardCreateParams {
157
150
  last_name?: string;
158
151
  }
159
152
 
153
+ export interface ContactCardRetrieveParams {
154
+ /**
155
+ * E.164 phone number to filter by. If omitted, all my cards for the partner are
156
+ * returned.
157
+ */
158
+ phone_number?: string;
159
+ }
160
+
160
161
  export interface ContactCardUpdateParams {
161
162
  /**
162
163
  * Query param: E.164 phone number of the contact card to update
@@ -183,8 +184,8 @@ export declare namespace ContactCard {
183
184
  export {
184
185
  type SetContactCard as SetContactCard,
185
186
  type ContactCardRetrieveResponse as ContactCardRetrieveResponse,
186
- type ContactCardRetrieveParams as ContactCardRetrieveParams,
187
187
  type ContactCardCreateParams as ContactCardCreateParams,
188
+ type ContactCardRetrieveParams as ContactCardRetrieveParams,
188
189
  type ContactCardUpdateParams as ContactCardUpdateParams,
189
190
  };
190
191
  }