@zavudev/sdk 0.30.0 → 0.38.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 (305) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/client.d.mts +28 -4
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +28 -4
  5. package/client.d.ts.map +1 -1
  6. package/client.js +25 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs +25 -1
  9. package/client.mjs.map +1 -1
  10. package/internal/utils/env.js +2 -2
  11. package/internal/utils/env.js.map +1 -1
  12. package/internal/utils/env.mjs +2 -2
  13. package/internal/utils/env.mjs.map +1 -1
  14. package/package.json +1 -1
  15. package/resources/balance.d.mts +33 -0
  16. package/resources/balance.d.mts.map +1 -0
  17. package/resources/balance.d.ts +33 -0
  18. package/resources/balance.d.ts.map +1 -0
  19. package/resources/balance.js +16 -0
  20. package/resources/balance.js.map +1 -0
  21. package/resources/balance.mjs +12 -0
  22. package/resources/balance.mjs.map +1 -0
  23. package/resources/broadcasts/broadcasts.d.mts +31 -1
  24. package/resources/broadcasts/broadcasts.d.mts.map +1 -1
  25. package/resources/broadcasts/broadcasts.d.ts +31 -1
  26. package/resources/broadcasts/broadcasts.d.ts.map +1 -1
  27. package/resources/broadcasts/broadcasts.js +28 -0
  28. package/resources/broadcasts/broadcasts.js.map +1 -1
  29. package/resources/broadcasts/broadcasts.mjs +28 -0
  30. package/resources/broadcasts/broadcasts.mjs.map +1 -1
  31. package/resources/broadcasts/index.d.mts +1 -1
  32. package/resources/broadcasts/index.d.mts.map +1 -1
  33. package/resources/broadcasts/index.d.ts +1 -1
  34. package/resources/broadcasts/index.d.ts.map +1 -1
  35. package/resources/broadcasts/index.js.map +1 -1
  36. package/resources/broadcasts/index.mjs.map +1 -1
  37. package/resources/contacts/channels.d.mts +127 -0
  38. package/resources/contacts/channels.d.mts.map +1 -0
  39. package/resources/contacts/channels.d.ts +127 -0
  40. package/resources/contacts/channels.d.ts.map +1 -0
  41. package/resources/contacts/channels.js +76 -0
  42. package/resources/contacts/channels.js.map +1 -0
  43. package/resources/contacts/channels.mjs +72 -0
  44. package/resources/contacts/channels.mjs.map +1 -0
  45. package/resources/contacts/contacts.d.mts +262 -0
  46. package/resources/contacts/contacts.d.mts.map +1 -0
  47. package/resources/contacts/contacts.d.ts +262 -0
  48. package/resources/contacts/contacts.d.ts.map +1 -0
  49. package/resources/contacts/contacts.js +118 -0
  50. package/resources/contacts/contacts.js.map +1 -0
  51. package/resources/contacts/contacts.mjs +113 -0
  52. package/resources/contacts/contacts.mjs.map +1 -0
  53. package/resources/contacts/index.d.mts +3 -0
  54. package/resources/contacts/index.d.mts.map +1 -0
  55. package/resources/contacts/index.d.ts +3 -0
  56. package/resources/contacts/index.d.ts.map +1 -0
  57. package/resources/contacts/index.js +9 -0
  58. package/resources/contacts/index.js.map +1 -0
  59. package/resources/contacts/index.mjs +4 -0
  60. package/resources/contacts/index.mjs.map +1 -0
  61. package/resources/contacts.d.mts +1 -144
  62. package/resources/contacts.d.mts.map +1 -1
  63. package/resources/contacts.d.ts +1 -144
  64. package/resources/contacts.d.ts.map +1 -1
  65. package/resources/contacts.js +2 -31
  66. package/resources/contacts.js.map +1 -1
  67. package/resources/contacts.mjs +1 -29
  68. package/resources/contacts.mjs.map +1 -1
  69. package/resources/exports.d.mts +101 -0
  70. package/resources/exports.d.mts.map +1 -0
  71. package/resources/exports.d.ts +101 -0
  72. package/resources/exports.d.ts.map +1 -0
  73. package/resources/exports.js +53 -0
  74. package/resources/exports.js.map +1 -0
  75. package/resources/exports.mjs +49 -0
  76. package/resources/exports.mjs.map +1 -0
  77. package/resources/index.d.mts +10 -2
  78. package/resources/index.d.mts.map +1 -1
  79. package/resources/index.d.ts +10 -2
  80. package/resources/index.d.ts.map +1 -1
  81. package/resources/index.js +18 -2
  82. package/resources/index.js.map +1 -1
  83. package/resources/index.mjs +9 -1
  84. package/resources/index.mjs.map +1 -1
  85. package/resources/invitations.d.mts +133 -0
  86. package/resources/invitations.d.mts.map +1 -0
  87. package/resources/invitations.d.ts +133 -0
  88. package/resources/invitations.d.ts.map +1 -0
  89. package/resources/invitations.js +67 -0
  90. package/resources/invitations.js.map +1 -0
  91. package/resources/invitations.mjs +63 -0
  92. package/resources/invitations.mjs.map +1 -0
  93. package/resources/messages.d.mts +37 -4
  94. package/resources/messages.d.mts.map +1 -1
  95. package/resources/messages.d.ts +37 -4
  96. package/resources/messages.d.ts.map +1 -1
  97. package/resources/number-10dlc/brands.d.mts +258 -0
  98. package/resources/number-10dlc/brands.d.mts.map +1 -0
  99. package/resources/number-10dlc/brands.d.ts +258 -0
  100. package/resources/number-10dlc/brands.d.ts.map +1 -0
  101. package/resources/number-10dlc/brands.js +132 -0
  102. package/resources/number-10dlc/brands.js.map +1 -0
  103. package/resources/number-10dlc/brands.mjs +128 -0
  104. package/resources/number-10dlc/brands.mjs.map +1 -0
  105. package/resources/number-10dlc/campaigns/campaigns.d.mts +223 -0
  106. package/resources/number-10dlc/campaigns/campaigns.d.mts.map +1 -0
  107. package/resources/number-10dlc/campaigns/campaigns.d.ts +223 -0
  108. package/resources/number-10dlc/campaigns/campaigns.d.ts.map +1 -0
  109. package/resources/number-10dlc/campaigns/campaigns.js +133 -0
  110. package/resources/number-10dlc/campaigns/campaigns.js.map +1 -0
  111. package/resources/number-10dlc/campaigns/campaigns.mjs +128 -0
  112. package/resources/number-10dlc/campaigns/campaigns.mjs.map +1 -0
  113. package/resources/number-10dlc/campaigns/index.d.mts +3 -0
  114. package/resources/number-10dlc/campaigns/index.d.mts.map +1 -0
  115. package/resources/number-10dlc/campaigns/index.d.ts +3 -0
  116. package/resources/number-10dlc/campaigns/index.d.ts.map +1 -0
  117. package/resources/number-10dlc/campaigns/index.js +9 -0
  118. package/resources/number-10dlc/campaigns/index.js.map +1 -0
  119. package/resources/number-10dlc/campaigns/index.mjs +4 -0
  120. package/resources/number-10dlc/campaigns/index.mjs.map +1 -0
  121. package/resources/number-10dlc/campaigns/phone-numbers.d.mts +79 -0
  122. package/resources/number-10dlc/campaigns/phone-numbers.d.mts.map +1 -0
  123. package/resources/number-10dlc/campaigns/phone-numbers.d.ts +79 -0
  124. package/resources/number-10dlc/campaigns/phone-numbers.d.ts.map +1 -0
  125. package/resources/number-10dlc/campaigns/phone-numbers.js +59 -0
  126. package/resources/number-10dlc/campaigns/phone-numbers.js.map +1 -0
  127. package/resources/number-10dlc/campaigns/phone-numbers.mjs +55 -0
  128. package/resources/number-10dlc/campaigns/phone-numbers.mjs.map +1 -0
  129. package/resources/number-10dlc/campaigns.d.mts +2 -0
  130. package/resources/number-10dlc/campaigns.d.mts.map +1 -0
  131. package/resources/number-10dlc/campaigns.d.ts +2 -0
  132. package/resources/number-10dlc/campaigns.d.ts.map +1 -0
  133. package/resources/number-10dlc/campaigns.js +6 -0
  134. package/resources/number-10dlc/campaigns.js.map +1 -0
  135. package/resources/number-10dlc/campaigns.mjs +3 -0
  136. package/resources/number-10dlc/campaigns.mjs.map +1 -0
  137. package/resources/number-10dlc/index.d.mts +4 -0
  138. package/resources/number-10dlc/index.d.mts.map +1 -0
  139. package/resources/number-10dlc/index.d.ts +4 -0
  140. package/resources/number-10dlc/index.d.ts.map +1 -0
  141. package/resources/number-10dlc/index.js +11 -0
  142. package/resources/number-10dlc/index.js.map +1 -0
  143. package/resources/number-10dlc/index.mjs +5 -0
  144. package/resources/number-10dlc/index.mjs.map +1 -0
  145. package/resources/number-10dlc/number-10dlc.d.mts +14 -0
  146. package/resources/number-10dlc/number-10dlc.d.mts.map +1 -0
  147. package/resources/number-10dlc/number-10dlc.d.ts +14 -0
  148. package/resources/number-10dlc/number-10dlc.d.ts.map +1 -0
  149. package/resources/number-10dlc/number-10dlc.js +21 -0
  150. package/resources/number-10dlc/number-10dlc.js.map +1 -0
  151. package/resources/number-10dlc/number-10dlc.mjs +16 -0
  152. package/resources/number-10dlc/number-10dlc.mjs.map +1 -0
  153. package/resources/number-10dlc.d.mts +2 -0
  154. package/resources/number-10dlc.d.mts.map +1 -0
  155. package/resources/number-10dlc.d.ts +2 -0
  156. package/resources/number-10dlc.d.ts.map +1 -0
  157. package/resources/number-10dlc.js +6 -0
  158. package/resources/number-10dlc.js.map +1 -0
  159. package/resources/number-10dlc.mjs +3 -0
  160. package/resources/number-10dlc.mjs.map +1 -0
  161. package/resources/plan.d.mts +43 -0
  162. package/resources/plan.d.mts.map +1 -0
  163. package/resources/plan.d.ts +43 -0
  164. package/resources/plan.d.ts.map +1 -0
  165. package/resources/plan.js +16 -0
  166. package/resources/plan.js.map +1 -0
  167. package/resources/plan.mjs +12 -0
  168. package/resources/plan.mjs.map +1 -0
  169. package/resources/senders/agent/agent.d.mts +4 -4
  170. package/resources/senders/agent/agent.d.mts.map +1 -1
  171. package/resources/senders/agent/agent.d.ts +4 -4
  172. package/resources/senders/agent/agent.d.ts.map +1 -1
  173. package/resources/senders/agent/agent.js.map +1 -1
  174. package/resources/senders/agent/agent.mjs.map +1 -1
  175. package/resources/senders/agent/flows.d.mts +40 -114
  176. package/resources/senders/agent/flows.d.mts.map +1 -1
  177. package/resources/senders/agent/flows.d.ts +40 -114
  178. package/resources/senders/agent/flows.d.ts.map +1 -1
  179. package/resources/senders/agent/index.d.mts +2 -2
  180. package/resources/senders/agent/index.d.mts.map +1 -1
  181. package/resources/senders/agent/index.d.ts +2 -2
  182. package/resources/senders/agent/index.d.ts.map +1 -1
  183. package/resources/senders/agent/index.js.map +1 -1
  184. package/resources/senders/agent/index.mjs.map +1 -1
  185. package/resources/senders/agent/tools.d.mts +15 -47
  186. package/resources/senders/agent/tools.d.mts.map +1 -1
  187. package/resources/senders/agent/tools.d.ts +15 -47
  188. package/resources/senders/agent/tools.d.ts.map +1 -1
  189. package/resources/senders/index.d.mts +1 -0
  190. package/resources/senders/index.d.mts.map +1 -1
  191. package/resources/senders/index.d.ts +1 -0
  192. package/resources/senders/index.d.ts.map +1 -1
  193. package/resources/senders/index.js +3 -1
  194. package/resources/senders/index.js.map +1 -1
  195. package/resources/senders/index.mjs +1 -0
  196. package/resources/senders/index.mjs.map +1 -1
  197. package/resources/senders/senders.d.mts +17 -1
  198. package/resources/senders/senders.d.mts.map +1 -1
  199. package/resources/senders/senders.d.ts +17 -1
  200. package/resources/senders/senders.d.ts.map +1 -1
  201. package/resources/senders/senders.js +4 -0
  202. package/resources/senders/senders.js.map +1 -1
  203. package/resources/senders/senders.mjs +4 -0
  204. package/resources/senders/senders.mjs.map +1 -1
  205. package/resources/senders/whatsapp-sync.d.mts +134 -0
  206. package/resources/senders/whatsapp-sync.d.mts.map +1 -0
  207. package/resources/senders/whatsapp-sync.d.ts +134 -0
  208. package/resources/senders/whatsapp-sync.d.ts.map +1 -0
  209. package/resources/senders/whatsapp-sync.js +56 -0
  210. package/resources/senders/whatsapp-sync.js.map +1 -0
  211. package/resources/senders/whatsapp-sync.mjs +52 -0
  212. package/resources/senders/whatsapp-sync.mjs.map +1 -0
  213. package/resources/sub-accounts/api-keys.d.mts +85 -0
  214. package/resources/sub-accounts/api-keys.d.mts.map +1 -0
  215. package/resources/sub-accounts/api-keys.d.ts +85 -0
  216. package/resources/sub-accounts/api-keys.d.ts.map +1 -0
  217. package/resources/sub-accounts/api-keys.js +53 -0
  218. package/resources/sub-accounts/api-keys.js.map +1 -0
  219. package/resources/sub-accounts/api-keys.mjs +49 -0
  220. package/resources/sub-accounts/api-keys.mjs.map +1 -0
  221. package/resources/sub-accounts/index.d.mts +3 -0
  222. package/resources/sub-accounts/index.d.mts.map +1 -0
  223. package/resources/sub-accounts/index.d.ts +3 -0
  224. package/resources/sub-accounts/index.d.ts.map +1 -0
  225. package/resources/sub-accounts/index.js +9 -0
  226. package/resources/sub-accounts/index.js.map +1 -0
  227. package/resources/sub-accounts/index.mjs +4 -0
  228. package/resources/sub-accounts/index.mjs.map +1 -0
  229. package/resources/sub-accounts/sub-accounts.d.mts +168 -0
  230. package/resources/sub-accounts/sub-accounts.d.mts.map +1 -0
  231. package/resources/sub-accounts/sub-accounts.d.ts +168 -0
  232. package/resources/sub-accounts/sub-accounts.d.ts.map +1 -0
  233. package/resources/sub-accounts/sub-accounts.js +94 -0
  234. package/resources/sub-accounts/sub-accounts.js.map +1 -0
  235. package/resources/sub-accounts/sub-accounts.mjs +89 -0
  236. package/resources/sub-accounts/sub-accounts.mjs.map +1 -0
  237. package/resources/sub-accounts.d.mts +2 -0
  238. package/resources/sub-accounts.d.mts.map +1 -0
  239. package/resources/sub-accounts.d.ts +2 -0
  240. package/resources/sub-accounts.d.ts.map +1 -0
  241. package/resources/sub-accounts.js +6 -0
  242. package/resources/sub-accounts.js.map +1 -0
  243. package/resources/sub-accounts.mjs +3 -0
  244. package/resources/sub-accounts.mjs.map +1 -0
  245. package/resources/templates.d.mts +42 -2
  246. package/resources/templates.d.mts.map +1 -1
  247. package/resources/templates.d.ts +42 -2
  248. package/resources/templates.d.ts.map +1 -1
  249. package/resources/urls.d.mts +88 -0
  250. package/resources/urls.d.mts.map +1 -0
  251. package/resources/urls.d.ts +88 -0
  252. package/resources/urls.d.ts.map +1 -0
  253. package/resources/urls.js +55 -0
  254. package/resources/urls.js.map +1 -0
  255. package/resources/urls.mjs +51 -0
  256. package/resources/urls.mjs.map +1 -0
  257. package/resources/usage.d.mts +36 -0
  258. package/resources/usage.d.mts.map +1 -0
  259. package/resources/usage.d.ts +36 -0
  260. package/resources/usage.d.ts.map +1 -0
  261. package/resources/usage.js +16 -0
  262. package/resources/usage.js.map +1 -0
  263. package/resources/usage.mjs +12 -0
  264. package/resources/usage.mjs.map +1 -0
  265. package/src/client.ts +130 -6
  266. package/src/internal/utils/env.ts +2 -2
  267. package/src/resources/balance.ts +43 -0
  268. package/src/resources/broadcasts/broadcasts.ts +40 -0
  269. package/src/resources/broadcasts/index.ts +2 -0
  270. package/src/resources/contacts/channels.ts +177 -0
  271. package/src/resources/contacts/contacts.ts +360 -0
  272. package/src/resources/contacts/index.ts +22 -0
  273. package/src/resources/contacts.ts +1 -196
  274. package/src/resources/exports.ts +141 -0
  275. package/src/resources/index.ts +51 -1
  276. package/src/resources/invitations.ts +188 -0
  277. package/src/resources/messages.ts +43 -3
  278. package/src/resources/number-10dlc/brands.ts +377 -0
  279. package/src/resources/number-10dlc/campaigns/campaigns.ts +349 -0
  280. package/src/resources/number-10dlc/campaigns/index.ts +23 -0
  281. package/src/resources/number-10dlc/campaigns/phone-numbers.ts +123 -0
  282. package/src/resources/number-10dlc/campaigns.ts +3 -0
  283. package/src/resources/number-10dlc/index.ts +30 -0
  284. package/src/resources/number-10dlc/number-10dlc.ts +71 -0
  285. package/src/resources/number-10dlc.ts +3 -0
  286. package/src/resources/plan.ts +62 -0
  287. package/src/resources/senders/agent/agent.ts +6 -0
  288. package/src/resources/senders/agent/flows.ts +44 -126
  289. package/src/resources/senders/agent/index.ts +3 -0
  290. package/src/resources/senders/agent/tools.ts +13 -50
  291. package/src/resources/senders/index.ts +9 -0
  292. package/src/resources/senders/senders.ts +38 -1
  293. package/src/resources/senders/whatsapp-sync.ts +175 -0
  294. package/src/resources/sub-accounts/api-keys.ts +126 -0
  295. package/src/resources/sub-accounts/index.ts +22 -0
  296. package/src/resources/sub-accounts/sub-accounts.ts +246 -0
  297. package/src/resources/sub-accounts.ts +3 -0
  298. package/src/resources/templates.ts +51 -2
  299. package/src/resources/urls.ts +125 -0
  300. package/src/resources/usage.ts +48 -0
  301. package/src/version.ts +1 -1
  302. package/version.d.mts +1 -1
  303. package/version.d.ts +1 -1
  304. package/version.js +1 -1
  305. package/version.mjs +1 -1
@@ -0,0 +1,43 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ export class Balance extends APIResource {
8
+ /**
9
+ * Get balance for the API key's team. If the API key belongs to a sub-account,
10
+ * also includes the sub-account's total spending and credit limit.
11
+ */
12
+ retrieve(options?: RequestOptions): APIPromise<BalanceRetrieveResponse> {
13
+ return this._client.get('/v1/balance', options);
14
+ }
15
+ }
16
+
17
+ export interface BalanceRetrieveResponse {
18
+ /**
19
+ * Team balance in cents. All charges are billed to the parent team.
20
+ */
21
+ balance: number;
22
+
23
+ currency: string;
24
+
25
+ /**
26
+ * Spending cap in cents (only for sub-accounts).
27
+ */
28
+ creditLimit?: number | null;
29
+
30
+ /**
31
+ * Whether this API key belongs to a sub-account.
32
+ */
33
+ isSubAccount?: boolean;
34
+
35
+ /**
36
+ * Total amount spent by this sub-account in cents (only for sub-accounts).
37
+ */
38
+ totalSpent?: number | null;
39
+ }
40
+
41
+ export declare namespace Balance {
42
+ export { type BalanceRetrieveResponse as BalanceRetrieveResponse };
43
+ }
@@ -114,6 +114,21 @@ export class Broadcasts extends APIResource {
114
114
  return this._client.post(path`/v1/broadcasts/${broadcastID}/cancel`, options);
115
115
  }
116
116
 
117
+ /**
118
+ * Request manual review by the Zavu team for a rejected broadcast. Use this after
119
+ * automated review rejection if you believe the content is legitimate.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * const response = await client.broadcasts.escalateReview(
124
+ * 'broadcastId',
125
+ * );
126
+ * ```
127
+ */
128
+ escalateReview(broadcastID: string, options?: RequestOptions): APIPromise<BroadcastEscalateReviewResponse> {
129
+ return this._client.post(path`/v1/broadcasts/${broadcastID}/escalate`, options);
130
+ }
131
+
117
132
  /**
118
133
  * Get real-time progress of a broadcast including delivery counts and estimated
119
134
  * completion time.
@@ -149,6 +164,21 @@ export class Broadcasts extends APIResource {
149
164
  return this._client.patch(path`/v1/broadcasts/${broadcastID}/schedule`, { body, ...options });
150
165
  }
151
166
 
167
+ /**
168
+ * Resubmit a rejected broadcast for AI review after editing content. Maximum 3
169
+ * review attempts allowed per broadcast.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * const response = await client.broadcasts.retryReview(
174
+ * 'broadcastId',
175
+ * );
176
+ * ```
177
+ */
178
+ retryReview(broadcastID: string, options?: RequestOptions): APIPromise<BroadcastRetryReviewResponse> {
179
+ return this._client.post(path`/v1/broadcasts/${broadcastID}/retry-review`, options);
180
+ }
181
+
152
182
  /**
153
183
  * Start sending the broadcast immediately or schedule for later. Broadcasts go
154
184
  * through automated AI content review before sending. If the review passes, the
@@ -470,10 +500,18 @@ export interface BroadcastCancelResponse {
470
500
  broadcast: Broadcast;
471
501
  }
472
502
 
503
+ export interface BroadcastEscalateReviewResponse {
504
+ broadcast: Broadcast;
505
+ }
506
+
473
507
  export interface BroadcastRescheduleResponse {
474
508
  broadcast: Broadcast;
475
509
  }
476
510
 
511
+ export interface BroadcastRetryReviewResponse {
512
+ broadcast: Broadcast;
513
+ }
514
+
477
515
  export interface BroadcastSendResponse {
478
516
  broadcast: Broadcast;
479
517
  }
@@ -586,7 +624,9 @@ export declare namespace Broadcasts {
586
624
  type BroadcastRetrieveResponse as BroadcastRetrieveResponse,
587
625
  type BroadcastUpdateResponse as BroadcastUpdateResponse,
588
626
  type BroadcastCancelResponse as BroadcastCancelResponse,
627
+ type BroadcastEscalateReviewResponse as BroadcastEscalateReviewResponse,
589
628
  type BroadcastRescheduleResponse as BroadcastRescheduleResponse,
629
+ type BroadcastRetryReviewResponse as BroadcastRetryReviewResponse,
590
630
  type BroadcastSendResponse as BroadcastSendResponse,
591
631
  type BroadcastsCursor as BroadcastsCursor,
592
632
  type BroadcastCreateParams as BroadcastCreateParams,
@@ -14,7 +14,9 @@ export {
14
14
  type BroadcastRetrieveResponse,
15
15
  type BroadcastUpdateResponse,
16
16
  type BroadcastCancelResponse,
17
+ type BroadcastEscalateReviewResponse,
17
18
  type BroadcastRescheduleResponse,
19
+ type BroadcastRetryReviewResponse,
18
20
  type BroadcastSendResponse,
19
21
  type BroadcastCreateParams,
20
22
  type BroadcastUpdateParams,
@@ -0,0 +1,177 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as ContactsAPI from './contacts';
5
+ import { APIPromise } from '../../core/api-promise';
6
+ import { buildHeaders } from '../../internal/headers';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+ import { path } from '../../internal/utils/path';
9
+
10
+ export class Channels extends APIResource {
11
+ /**
12
+ * Update a contact's channel properties.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const channel = await client.contacts.channels.update(
17
+ * 'channelId',
18
+ * { contactId: 'contactId' },
19
+ * );
20
+ * ```
21
+ */
22
+ update(
23
+ channelID: string,
24
+ params: ChannelUpdateParams,
25
+ options?: RequestOptions,
26
+ ): APIPromise<ChannelUpdateResponse> {
27
+ const { contactId, ...body } = params;
28
+ return this._client.patch(path`/v1/contacts/${contactId}/channels/${channelID}`, { body, ...options });
29
+ }
30
+
31
+ /**
32
+ * Add a new communication channel to an existing contact.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const response = await client.contacts.channels.add(
37
+ * 'contactId',
38
+ * {
39
+ * channel: 'email',
40
+ * identifier: 'john.work@company.com',
41
+ * label: 'work',
42
+ * },
43
+ * );
44
+ * ```
45
+ */
46
+ add(contactID: string, body: ChannelAddParams, options?: RequestOptions): APIPromise<ChannelAddResponse> {
47
+ return this._client.post(path`/v1/contacts/${contactID}/channels`, { body, ...options });
48
+ }
49
+
50
+ /**
51
+ * Remove a communication channel from a contact. Cannot remove the last channel.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * await client.contacts.channels.remove('channelId', {
56
+ * contactId: 'contactId',
57
+ * });
58
+ * ```
59
+ */
60
+ remove(channelID: string, params: ChannelRemoveParams, options?: RequestOptions): APIPromise<void> {
61
+ const { contactId } = params;
62
+ return this._client.delete(path`/v1/contacts/${contactId}/channels/${channelID}`, {
63
+ ...options,
64
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Set a channel as the primary channel for its type.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const response = await client.contacts.channels.setPrimary(
74
+ * 'channelId',
75
+ * { contactId: 'contactId' },
76
+ * );
77
+ * ```
78
+ */
79
+ setPrimary(
80
+ channelID: string,
81
+ params: ChannelSetPrimaryParams,
82
+ options?: RequestOptions,
83
+ ): APIPromise<ChannelSetPrimaryResponse> {
84
+ const { contactId } = params;
85
+ return this._client.post(path`/v1/contacts/${contactId}/channels/${channelID}/primary`, options);
86
+ }
87
+ }
88
+
89
+ export interface ChannelUpdateResponse {
90
+ /**
91
+ * A communication channel for a contact.
92
+ */
93
+ channel: ContactsAPI.ContactChannel;
94
+ }
95
+
96
+ export interface ChannelAddResponse {
97
+ /**
98
+ * A communication channel for a contact.
99
+ */
100
+ channel: ContactsAPI.ContactChannel;
101
+ }
102
+
103
+ export interface ChannelSetPrimaryResponse {
104
+ /**
105
+ * A communication channel for a contact.
106
+ */
107
+ channel: ContactsAPI.ContactChannel;
108
+ }
109
+
110
+ export interface ChannelUpdateParams {
111
+ /**
112
+ * Path param
113
+ */
114
+ contactId: string;
115
+
116
+ /**
117
+ * Body param: Optional label for the channel. Set to null to clear.
118
+ */
119
+ label?: string | null;
120
+
121
+ /**
122
+ * Body param
123
+ */
124
+ metadata?: { [key: string]: string };
125
+
126
+ /**
127
+ * Body param: Whether the channel is verified.
128
+ */
129
+ verified?: boolean;
130
+ }
131
+
132
+ export interface ChannelAddParams {
133
+ /**
134
+ * Channel type.
135
+ */
136
+ channel: 'sms' | 'whatsapp' | 'email' | 'telegram' | 'voice';
137
+
138
+ /**
139
+ * Channel identifier (phone number in E.164 format or email address).
140
+ */
141
+ identifier: string;
142
+
143
+ /**
144
+ * ISO country code for phone numbers.
145
+ */
146
+ countryCode?: string;
147
+
148
+ /**
149
+ * Whether this should be the primary channel for its type.
150
+ */
151
+ isPrimary?: boolean;
152
+
153
+ /**
154
+ * Optional label for the channel.
155
+ */
156
+ label?: string;
157
+ }
158
+
159
+ export interface ChannelRemoveParams {
160
+ contactId: string;
161
+ }
162
+
163
+ export interface ChannelSetPrimaryParams {
164
+ contactId: string;
165
+ }
166
+
167
+ export declare namespace Channels {
168
+ export {
169
+ type ChannelUpdateResponse as ChannelUpdateResponse,
170
+ type ChannelAddResponse as ChannelAddResponse,
171
+ type ChannelSetPrimaryResponse as ChannelSetPrimaryResponse,
172
+ type ChannelUpdateParams as ChannelUpdateParams,
173
+ type ChannelAddParams as ChannelAddParams,
174
+ type ChannelRemoveParams as ChannelRemoveParams,
175
+ type ChannelSetPrimaryParams as ChannelSetPrimaryParams,
176
+ };
177
+ }
@@ -0,0 +1,360 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as ChannelsAPI from './channels';
5
+ import {
6
+ ChannelAddParams,
7
+ ChannelAddResponse,
8
+ ChannelRemoveParams,
9
+ ChannelSetPrimaryParams,
10
+ ChannelSetPrimaryResponse,
11
+ ChannelUpdateParams,
12
+ ChannelUpdateResponse,
13
+ Channels,
14
+ } from './channels';
15
+ import { APIPromise } from '../../core/api-promise';
16
+ import { Cursor, type CursorParams, PagePromise } from '../../core/pagination';
17
+ import { buildHeaders } from '../../internal/headers';
18
+ import { RequestOptions } from '../../internal/request-options';
19
+ import { path } from '../../internal/utils/path';
20
+
21
+ export class Contacts extends APIResource {
22
+ channels: ChannelsAPI.Channels = new ChannelsAPI.Channels(this._client);
23
+
24
+ /**
25
+ * Create a new contact with one or more communication channels.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const contact = await client.contacts.create({
30
+ * channels: [
31
+ * {
32
+ * channel: 'sms',
33
+ * identifier: '+14155551234',
34
+ * isPrimary: true,
35
+ * },
36
+ * ],
37
+ * displayName: 'John Doe',
38
+ * });
39
+ * ```
40
+ */
41
+ create(body: ContactCreateParams, options?: RequestOptions): APIPromise<Contact> {
42
+ return this._client.post('/v1/contacts', { body, ...options });
43
+ }
44
+
45
+ /**
46
+ * Get contact
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const contact = await client.contacts.retrieve('contactId');
51
+ * ```
52
+ */
53
+ retrieve(contactID: string, options?: RequestOptions): APIPromise<Contact> {
54
+ return this._client.get(path`/v1/contacts/${contactID}`, options);
55
+ }
56
+
57
+ /**
58
+ * Update contact
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * const contact = await client.contacts.update('contactId');
63
+ * ```
64
+ */
65
+ update(contactID: string, body: ContactUpdateParams, options?: RequestOptions): APIPromise<Contact> {
66
+ return this._client.patch(path`/v1/contacts/${contactID}`, { body, ...options });
67
+ }
68
+
69
+ /**
70
+ * List contacts with their communication channels.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * // Automatically fetches more pages as needed.
75
+ * for await (const contact of client.contacts.list()) {
76
+ * // ...
77
+ * }
78
+ * ```
79
+ */
80
+ list(
81
+ query: ContactListParams | null | undefined = {},
82
+ options?: RequestOptions,
83
+ ): PagePromise<ContactsCursor, Contact> {
84
+ return this._client.getAPIList('/v1/contacts', Cursor<Contact>, { query, ...options });
85
+ }
86
+
87
+ /**
88
+ * Dismiss the merge suggestion for a contact.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * await client.contacts.dismissMergeSuggestion('contactId');
93
+ * ```
94
+ */
95
+ dismissMergeSuggestion(contactID: string, options?: RequestOptions): APIPromise<void> {
96
+ return this._client.delete(path`/v1/contacts/${contactID}/merge-suggestion`, {
97
+ ...options,
98
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
99
+ });
100
+ }
101
+
102
+ /**
103
+ * Merge a source contact into this contact. All channels from the source contact
104
+ * will be moved to the target contact, and the source contact will be marked as
105
+ * merged.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const contact = await client.contacts.merge('contactId', {
110
+ * sourceContactId: 'jx7xyz789',
111
+ * });
112
+ * ```
113
+ */
114
+ merge(contactID: string, body: ContactMergeParams, options?: RequestOptions): APIPromise<Contact> {
115
+ return this._client.post(path`/v1/contacts/${contactID}/merge`, { body, ...options });
116
+ }
117
+
118
+ /**
119
+ * Get contact by phone number
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * const contact = await client.contacts.retrieveByPhone(
124
+ * 'phoneNumber',
125
+ * );
126
+ * ```
127
+ */
128
+ retrieveByPhone(phoneNumber: string, options?: RequestOptions): APIPromise<Contact> {
129
+ return this._client.get(path`/v1/contacts/phone/${phoneNumber}`, options);
130
+ }
131
+ }
132
+
133
+ export type ContactsCursor = Cursor<Contact>;
134
+
135
+ export interface Contact {
136
+ id: string;
137
+
138
+ /**
139
+ * List of available messaging channels for this contact.
140
+ */
141
+ availableChannels: Array<string>;
142
+
143
+ createdAt: string;
144
+
145
+ metadata: { [key: string]: string };
146
+
147
+ /**
148
+ * Whether this contact has been verified.
149
+ */
150
+ verified: boolean;
151
+
152
+ /**
153
+ * All communication channels for this contact.
154
+ */
155
+ channels?: Array<ContactChannel>;
156
+
157
+ countryCode?: string;
158
+
159
+ /**
160
+ * Preferred channel for this contact.
161
+ */
162
+ defaultChannel?: 'sms' | 'whatsapp' | 'telegram' | 'email' | 'instagram' | 'voice';
163
+
164
+ /**
165
+ * Display name for the contact.
166
+ */
167
+ displayName?: string;
168
+
169
+ /**
170
+ * DEPRECATED: Use primaryPhone instead. Primary phone number in E.164 format.
171
+ */
172
+ phoneNumber?: string;
173
+
174
+ /**
175
+ * Primary email address.
176
+ */
177
+ primaryEmail?: string;
178
+
179
+ /**
180
+ * Primary phone number in E.164 format.
181
+ */
182
+ primaryPhone?: string;
183
+
184
+ /**
185
+ * Contact's WhatsApp profile name. Only available for WhatsApp contacts.
186
+ */
187
+ profileName?: string | null;
188
+
189
+ /**
190
+ * ID of a contact suggested for merging.
191
+ */
192
+ suggestedMergeWith?: string;
193
+
194
+ updatedAt?: string;
195
+ }
196
+
197
+ /**
198
+ * A communication channel for a contact.
199
+ */
200
+ export interface ContactChannel {
201
+ id: string;
202
+
203
+ /**
204
+ * Channel type.
205
+ */
206
+ channel: 'sms' | 'whatsapp' | 'email' | 'telegram' | 'voice';
207
+
208
+ createdAt: string;
209
+
210
+ /**
211
+ * Channel identifier (phone number or email address).
212
+ */
213
+ identifier: string;
214
+
215
+ /**
216
+ * Whether this is the primary channel for its type.
217
+ */
218
+ isPrimary: boolean;
219
+
220
+ /**
221
+ * Whether this channel has been verified.
222
+ */
223
+ verified: boolean;
224
+
225
+ /**
226
+ * ISO country code for phone numbers.
227
+ */
228
+ countryCode?: string;
229
+
230
+ /**
231
+ * Optional label for the channel.
232
+ */
233
+ label?: string;
234
+
235
+ /**
236
+ * Last time a message was received on this channel.
237
+ */
238
+ lastInboundAt?: string;
239
+
240
+ metadata?: { [key: string]: string };
241
+
242
+ /**
243
+ * Delivery metrics for this channel.
244
+ */
245
+ metrics?: ContactChannel.Metrics;
246
+
247
+ updatedAt?: string;
248
+ }
249
+
250
+ export namespace ContactChannel {
251
+ /**
252
+ * Delivery metrics for this channel.
253
+ */
254
+ export interface Metrics {
255
+ avgDeliveryTimeMs?: number;
256
+
257
+ failureCount?: number;
258
+
259
+ lastSuccessAt?: string;
260
+
261
+ successCount?: number;
262
+
263
+ totalAttempts?: number;
264
+ }
265
+ }
266
+
267
+ export interface ContactCreateParams {
268
+ /**
269
+ * Communication channels for the contact.
270
+ */
271
+ channels: Array<ContactCreateParams.Channel>;
272
+
273
+ /**
274
+ * Display name for the contact.
275
+ */
276
+ displayName?: string;
277
+
278
+ /**
279
+ * Arbitrary metadata to associate with the contact.
280
+ */
281
+ metadata?: { [key: string]: string };
282
+ }
283
+
284
+ export namespace ContactCreateParams {
285
+ /**
286
+ * Input for creating a contact channel.
287
+ */
288
+ export interface Channel {
289
+ /**
290
+ * Channel type.
291
+ */
292
+ channel: 'sms' | 'whatsapp' | 'email' | 'telegram' | 'voice';
293
+
294
+ /**
295
+ * Channel identifier (phone number in E.164 format or email address).
296
+ */
297
+ identifier: string;
298
+
299
+ /**
300
+ * ISO country code for phone numbers.
301
+ */
302
+ countryCode?: string;
303
+
304
+ /**
305
+ * Whether this should be the primary channel for its type.
306
+ */
307
+ isPrimary?: boolean;
308
+
309
+ /**
310
+ * Optional label for the channel.
311
+ */
312
+ label?: string;
313
+ }
314
+ }
315
+
316
+ export interface ContactUpdateParams {
317
+ /**
318
+ * Preferred channel for this contact. Set to null to clear.
319
+ */
320
+ defaultChannel?: 'sms' | 'whatsapp' | 'telegram' | 'email' | 'instagram' | 'voice' | null;
321
+
322
+ metadata?: { [key: string]: string };
323
+ }
324
+
325
+ export interface ContactListParams extends CursorParams {
326
+ phoneNumber?: string;
327
+ }
328
+
329
+ export interface ContactMergeParams {
330
+ /**
331
+ * ID of the contact to merge into the target contact. The source contact will be
332
+ * marked as merged.
333
+ */
334
+ sourceContactId: string;
335
+ }
336
+
337
+ Contacts.Channels = Channels;
338
+
339
+ export declare namespace Contacts {
340
+ export {
341
+ type Contact as Contact,
342
+ type ContactChannel as ContactChannel,
343
+ type ContactsCursor as ContactsCursor,
344
+ type ContactCreateParams as ContactCreateParams,
345
+ type ContactUpdateParams as ContactUpdateParams,
346
+ type ContactListParams as ContactListParams,
347
+ type ContactMergeParams as ContactMergeParams,
348
+ };
349
+
350
+ export {
351
+ Channels as Channels,
352
+ type ChannelUpdateResponse as ChannelUpdateResponse,
353
+ type ChannelAddResponse as ChannelAddResponse,
354
+ type ChannelSetPrimaryResponse as ChannelSetPrimaryResponse,
355
+ type ChannelUpdateParams as ChannelUpdateParams,
356
+ type ChannelAddParams as ChannelAddParams,
357
+ type ChannelRemoveParams as ChannelRemoveParams,
358
+ type ChannelSetPrimaryParams as ChannelSetPrimaryParams,
359
+ };
360
+ }
@@ -0,0 +1,22 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Channels,
5
+ type ChannelUpdateResponse,
6
+ type ChannelAddResponse,
7
+ type ChannelSetPrimaryResponse,
8
+ type ChannelUpdateParams,
9
+ type ChannelAddParams,
10
+ type ChannelRemoveParams,
11
+ type ChannelSetPrimaryParams,
12
+ } from './channels';
13
+ export {
14
+ Contacts,
15
+ type Contact,
16
+ type ContactChannel,
17
+ type ContactCreateParams,
18
+ type ContactUpdateParams,
19
+ type ContactListParams,
20
+ type ContactMergeParams,
21
+ type ContactsCursor,
22
+ } from './contacts';