@zavudev/sdk 0.58.1 → 0.59.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 (220) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +18 -0
  3. package/client.d.mts +2 -0
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +2 -0
  6. package/client.d.ts.map +1 -1
  7. package/client.js +2 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +2 -0
  10. package/client.mjs.map +1 -1
  11. package/package.json +21 -1
  12. package/src/client.ts +2 -0
  13. package/src/types.ts +29 -12
  14. package/src/v2/index.ts +4 -0
  15. package/src/v2/resources/agents/agents.ts +142 -0
  16. package/src/v2/resources/agents/channels.ts +66 -0
  17. package/src/v2/resources/agents/index.ts +18 -0
  18. package/src/v2/resources/agents.ts +3 -0
  19. package/src/v2/resources/campaigns/campaigns.ts +178 -0
  20. package/src/v2/resources/campaigns/index.ts +27 -0
  21. package/src/v2/resources/campaigns/recipients.ts +62 -0
  22. package/src/v2/resources/campaigns.ts +3 -0
  23. package/src/v2/resources/channels.ts +156 -0
  24. package/src/v2/resources/contacts.ts +112 -0
  25. package/src/v2/resources/conversations.ts +89 -0
  26. package/src/v2/resources/email-domains.ts +107 -0
  27. package/src/v2/resources/functions.ts +73 -0
  28. package/src/v2/resources/index.ts +138 -0
  29. package/src/v2/resources/messages.ts +129 -0
  30. package/src/v2/resources/numbers.ts +74 -0
  31. package/src/v2/resources/templates.ts +104 -0
  32. package/src/v2/resources/webhook.ts +102 -0
  33. package/src/v2/types.ts +2429 -0
  34. package/src/v2/v2.ts +315 -0
  35. package/src/v2.ts +3 -0
  36. package/src/version.ts +1 -1
  37. package/types.d.mts +29 -12
  38. package/types.d.mts.map +1 -1
  39. package/types.d.ts +29 -12
  40. package/types.d.ts.map +1 -1
  41. package/v2/index.d.mts +3 -0
  42. package/v2/index.d.mts.map +1 -0
  43. package/v2/index.d.ts +3 -0
  44. package/v2/index.d.ts.map +1 -0
  45. package/v2/index.js +9 -0
  46. package/v2/index.js.map +1 -0
  47. package/v2/index.mjs +4 -0
  48. package/v2/index.mjs.map +1 -0
  49. package/v2/resources/agents/agents.d.mts +81 -0
  50. package/v2/resources/agents/agents.d.mts.map +1 -0
  51. package/v2/resources/agents/agents.d.ts +81 -0
  52. package/v2/resources/agents/agents.d.ts.map +1 -0
  53. package/v2/resources/agents/agents.js +88 -0
  54. package/v2/resources/agents/agents.js.map +1 -0
  55. package/v2/resources/agents/agents.mjs +83 -0
  56. package/v2/resources/agents/agents.mjs.map +1 -0
  57. package/v2/resources/agents/channels.d.mts +39 -0
  58. package/v2/resources/agents/channels.d.mts.map +1 -0
  59. package/v2/resources/agents/channels.d.ts +39 -0
  60. package/v2/resources/agents/channels.d.ts.map +1 -0
  61. package/v2/resources/agents/channels.js +44 -0
  62. package/v2/resources/agents/channels.js.map +1 -0
  63. package/v2/resources/agents/channels.mjs +40 -0
  64. package/v2/resources/agents/channels.mjs.map +1 -0
  65. package/v2/resources/agents/index.d.mts +3 -0
  66. package/v2/resources/agents/index.d.mts.map +1 -0
  67. package/v2/resources/agents/index.d.ts +3 -0
  68. package/v2/resources/agents/index.d.ts.map +1 -0
  69. package/v2/resources/agents/index.js +9 -0
  70. package/v2/resources/agents/index.js.map +1 -0
  71. package/v2/resources/agents/index.mjs +4 -0
  72. package/v2/resources/agents/index.mjs.map +1 -0
  73. package/v2/resources/agents.d.mts +2 -0
  74. package/v2/resources/agents.d.mts.map +1 -0
  75. package/v2/resources/agents.d.ts +2 -0
  76. package/v2/resources/agents.d.ts.map +1 -0
  77. package/v2/resources/agents.js +6 -0
  78. package/v2/resources/agents.js.map +1 -0
  79. package/v2/resources/agents.mjs +3 -0
  80. package/v2/resources/agents.mjs.map +1 -0
  81. package/v2/resources/campaigns/campaigns.d.mts +100 -0
  82. package/v2/resources/campaigns/campaigns.d.mts.map +1 -0
  83. package/v2/resources/campaigns/campaigns.d.ts +100 -0
  84. package/v2/resources/campaigns/campaigns.d.ts.map +1 -0
  85. package/v2/resources/campaigns/campaigns.js +106 -0
  86. package/v2/resources/campaigns/campaigns.js.map +1 -0
  87. package/v2/resources/campaigns/campaigns.mjs +101 -0
  88. package/v2/resources/campaigns/campaigns.mjs.map +1 -0
  89. package/v2/resources/campaigns/index.d.mts +3 -0
  90. package/v2/resources/campaigns/index.d.mts.map +1 -0
  91. package/v2/resources/campaigns/index.d.ts +3 -0
  92. package/v2/resources/campaigns/index.d.ts.map +1 -0
  93. package/v2/resources/campaigns/index.js +9 -0
  94. package/v2/resources/campaigns/index.js.map +1 -0
  95. package/v2/resources/campaigns/index.mjs +4 -0
  96. package/v2/resources/campaigns/index.mjs.map +1 -0
  97. package/v2/resources/campaigns/recipients.d.mts +43 -0
  98. package/v2/resources/campaigns/recipients.d.mts.map +1 -0
  99. package/v2/resources/campaigns/recipients.d.ts +43 -0
  100. package/v2/resources/campaigns/recipients.d.ts.map +1 -0
  101. package/v2/resources/campaigns/recipients.js +41 -0
  102. package/v2/resources/campaigns/recipients.js.map +1 -0
  103. package/v2/resources/campaigns/recipients.mjs +37 -0
  104. package/v2/resources/campaigns/recipients.mjs.map +1 -0
  105. package/v2/resources/campaigns.d.mts +2 -0
  106. package/v2/resources/campaigns.d.mts.map +1 -0
  107. package/v2/resources/campaigns.d.ts +2 -0
  108. package/v2/resources/campaigns.d.ts.map +1 -0
  109. package/v2/resources/campaigns.js +6 -0
  110. package/v2/resources/campaigns.js.map +1 -0
  111. package/v2/resources/campaigns.mjs +3 -0
  112. package/v2/resources/campaigns.mjs.map +1 -0
  113. package/v2/resources/channels.d.mts +101 -0
  114. package/v2/resources/channels.d.mts.map +1 -0
  115. package/v2/resources/channels.d.ts +101 -0
  116. package/v2/resources/channels.d.ts.map +1 -0
  117. package/v2/resources/channels.js +107 -0
  118. package/v2/resources/channels.js.map +1 -0
  119. package/v2/resources/channels.mjs +103 -0
  120. package/v2/resources/channels.mjs.map +1 -0
  121. package/v2/resources/contacts.d.mts +62 -0
  122. package/v2/resources/contacts.d.mts.map +1 -0
  123. package/v2/resources/contacts.d.ts +62 -0
  124. package/v2/resources/contacts.d.ts.map +1 -0
  125. package/v2/resources/contacts.js +66 -0
  126. package/v2/resources/contacts.js.map +1 -0
  127. package/v2/resources/contacts.mjs +62 -0
  128. package/v2/resources/contacts.mjs.map +1 -0
  129. package/v2/resources/conversations.d.mts +51 -0
  130. package/v2/resources/conversations.d.mts.map +1 -0
  131. package/v2/resources/conversations.d.ts +51 -0
  132. package/v2/resources/conversations.d.ts.map +1 -0
  133. package/v2/resources/conversations.js +55 -0
  134. package/v2/resources/conversations.js.map +1 -0
  135. package/v2/resources/conversations.mjs +51 -0
  136. package/v2/resources/conversations.mjs.map +1 -0
  137. package/v2/resources/email-domains.d.mts +72 -0
  138. package/v2/resources/email-domains.d.mts.map +1 -0
  139. package/v2/resources/email-domains.d.ts +72 -0
  140. package/v2/resources/email-domains.d.ts.map +1 -0
  141. package/v2/resources/email-domains.js +80 -0
  142. package/v2/resources/email-domains.js.map +1 -0
  143. package/v2/resources/email-domains.mjs +76 -0
  144. package/v2/resources/email-domains.mjs.map +1 -0
  145. package/v2/resources/functions.d.mts +41 -0
  146. package/v2/resources/functions.d.mts.map +1 -0
  147. package/v2/resources/functions.d.ts +41 -0
  148. package/v2/resources/functions.d.ts.map +1 -0
  149. package/v2/resources/functions.js +41 -0
  150. package/v2/resources/functions.js.map +1 -0
  151. package/v2/resources/functions.mjs +37 -0
  152. package/v2/resources/functions.mjs.map +1 -0
  153. package/v2/resources/index.d.mts +12 -0
  154. package/v2/resources/index.d.mts.map +1 -0
  155. package/v2/resources/index.d.ts +12 -0
  156. package/v2/resources/index.d.ts.map +1 -0
  157. package/v2/resources/index.js +27 -0
  158. package/v2/resources/index.js.map +1 -0
  159. package/v2/resources/index.mjs +13 -0
  160. package/v2/resources/index.mjs.map +1 -0
  161. package/v2/resources/messages.d.mts +82 -0
  162. package/v2/resources/messages.d.mts.map +1 -0
  163. package/v2/resources/messages.d.ts +82 -0
  164. package/v2/resources/messages.d.ts.map +1 -0
  165. package/v2/resources/messages.js +74 -0
  166. package/v2/resources/messages.js.map +1 -0
  167. package/v2/resources/messages.mjs +70 -0
  168. package/v2/resources/messages.mjs.map +1 -0
  169. package/v2/resources/numbers.d.mts +46 -0
  170. package/v2/resources/numbers.d.mts.map +1 -0
  171. package/v2/resources/numbers.d.ts +46 -0
  172. package/v2/resources/numbers.d.ts.map +1 -0
  173. package/v2/resources/numbers.js +41 -0
  174. package/v2/resources/numbers.js.map +1 -0
  175. package/v2/resources/numbers.mjs +37 -0
  176. package/v2/resources/numbers.mjs.map +1 -0
  177. package/v2/resources/templates.d.mts +56 -0
  178. package/v2/resources/templates.d.mts.map +1 -0
  179. package/v2/resources/templates.d.ts +56 -0
  180. package/v2/resources/templates.d.ts.map +1 -0
  181. package/v2/resources/templates.js +61 -0
  182. package/v2/resources/templates.js.map +1 -0
  183. package/v2/resources/templates.mjs +57 -0
  184. package/v2/resources/templates.mjs.map +1 -0
  185. package/v2/resources/webhook.d.mts +67 -0
  186. package/v2/resources/webhook.d.mts.map +1 -0
  187. package/v2/resources/webhook.d.ts +67 -0
  188. package/v2/resources/webhook.d.ts.map +1 -0
  189. package/v2/resources/webhook.js +70 -0
  190. package/v2/resources/webhook.js.map +1 -0
  191. package/v2/resources/webhook.mjs +66 -0
  192. package/v2/resources/webhook.mjs.map +1 -0
  193. package/v2/types.d.mts +2188 -0
  194. package/v2/types.d.mts.map +1 -0
  195. package/v2/types.d.ts +2188 -0
  196. package/v2/types.d.ts.map +1 -0
  197. package/v2/types.js +4 -0
  198. package/v2/types.js.map +1 -0
  199. package/v2/types.mjs +3 -0
  200. package/v2/types.mjs.map +1 -0
  201. package/v2/v2.d.mts +40 -0
  202. package/v2/v2.d.mts.map +1 -0
  203. package/v2/v2.d.ts +40 -0
  204. package/v2/v2.d.ts.map +1 -0
  205. package/v2/v2.js +47 -0
  206. package/v2/v2.js.map +1 -0
  207. package/v2/v2.mjs +42 -0
  208. package/v2/v2.mjs.map +1 -0
  209. package/v2.d.mts +2 -0
  210. package/v2.d.mts.map +1 -0
  211. package/v2.d.ts +2 -0
  212. package/v2.d.ts.map +1 -0
  213. package/v2.js +6 -0
  214. package/v2.js.map +1 -0
  215. package/v2.mjs +3 -0
  216. package/v2.mjs.map +1 -0
  217. package/version.d.mts +1 -1
  218. package/version.d.ts +1 -1
  219. package/version.js +1 -1
  220. package/version.mjs +1 -1
@@ -0,0 +1,142 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { Cursor, PagePromise } from '../../../core/pagination';
6
+ import { buildHeaders } from '../../../internal/headers';
7
+ import { RequestOptions } from '../../../internal/request-options';
8
+ import { path } from '../../../internal/utils/path';
9
+ import type * as T from '../../types';
10
+ import * as ChannelsAPI from './channels';
11
+ import { Channels, type ChannelConnectParams, type ChannelConnectResponse } from './channels';
12
+
13
+ export class Agents extends APIResource {
14
+ channels: ChannelsAPI.Channels = new ChannelsAPI.Channels(this._client);
15
+
16
+ /**
17
+ * List agents
18
+ *
19
+ * `GET /v2/agents`
20
+ */
21
+ list(
22
+ query: AgentListParams | null | undefined = {},
23
+ options?: RequestOptions,
24
+ ): PagePromise<AgentsCursor, Agent> {
25
+ return this._client.getAPIList('/v2/agents', Cursor<Agent>, { query, ...options });
26
+ }
27
+
28
+ /**
29
+ * Create an agent
30
+ *
31
+ * Connect it to an address with `POST /v2/agents/{agentId}/channels`.
32
+ *
33
+ * `POST /v2/agents`
34
+ */
35
+ create(body: AgentCreateParams, options?: RequestOptions): APIPromise<AgentCreateResponse> {
36
+ return this._client.post('/v2/agents', { body, ...options });
37
+ }
38
+
39
+ /**
40
+ * Get an agent
41
+ *
42
+ * `GET /v2/agents/{agentId}`
43
+ */
44
+ retrieve(agentID: string, options?: RequestOptions): APIPromise<AgentRetrieveResponse> {
45
+ return this._client.get(path`/v2/agents/${agentID}`, options);
46
+ }
47
+
48
+ /**
49
+ * Update an agent
50
+ *
51
+ * `PATCH /v2/agents/{agentId}`
52
+ */
53
+ update(
54
+ agentID: string,
55
+ body: AgentUpdateParams | null | undefined = {},
56
+ options?: RequestOptions,
57
+ ): APIPromise<AgentUpdateResponse> {
58
+ return this._client.patch(path`/v2/agents/${agentID}`, { body, ...options });
59
+ }
60
+
61
+ /**
62
+ * Delete an agent
63
+ *
64
+ * As `DELETE /v1/agents/{agentId}`.
65
+ *
66
+ * `DELETE /v2/agents/{agentId}`
67
+ */
68
+ delete(agentID: string, options?: RequestOptions): APIPromise<void> {
69
+ return this._client.delete(path`/v2/agents/${agentID}`, {
70
+ ...options,
71
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
72
+ });
73
+ }
74
+
75
+ /**
76
+ * Test an agent
77
+ *
78
+ * Run the agent's prompt, model and knowledge base against a message and return
79
+ * the reply instead of delivering it. Nothing is delivered and no execution is
80
+ * recorded.
81
+ *
82
+ * **Billed like a live reply.** On an agent with the `zavu` provider the run is
83
+ * charged to your balance at the same price per token, and refused with `402
84
+ * insufficient_balance` at a balance of zero; on a bring-your-own-key agent it
85
+ * costs your provider. `cost` on the response is what it charged. Runs are rate
86
+ * limited per project (`429`).
87
+ *
88
+ * **Tools.** By default the model is offered the agent's enabled tools but none is
89
+ * run: if it picks one, the reply stops there and `plannedToolCalls` says which,
90
+ * with what arguments. Set `executeTools` to run them. That reaches your real
91
+ * handlers, with whatever they cost and change; read `executedToolCalls`.
92
+ *
93
+ * `POST /v2/agents/{agentId}/test`
94
+ */
95
+ test(agentID: string, body: AgentTestParams, options?: RequestOptions): APIPromise<AgentTestResponse> {
96
+ return this._client.post(path`/v2/agents/${agentID}/test`, { body, ...options });
97
+ }
98
+ }
99
+
100
+ export type AgentListParams = T.AgentsListParams;
101
+
102
+ export type Agent = T.Agent;
103
+
104
+ export type AgentsCursor = Cursor<T.Agent>;
105
+
106
+ export type AgentProvider = T.AgentProvider;
107
+
108
+ export type AgentVoiceConfig = T.AgentVoiceConfig;
109
+
110
+ export type AgentCreateParams = T.AgentsCreateParams;
111
+
112
+ export type AgentCreateResponse = T.CreateAgentV2Response;
113
+
114
+ export type AgentRetrieveResponse = T.GetAgentV2Response;
115
+
116
+ export type AgentUpdateParams = T.AgentsUpdateParams;
117
+
118
+ export type AgentUpdateResponse = T.UpdateAgentV2Response;
119
+
120
+ export type AgentTestParams = T.AgentsTestParams;
121
+
122
+ export type AgentTestResponse = T.AgentTestResponse;
123
+
124
+ export declare namespace Agents {
125
+ export {
126
+ type Agent as Agent,
127
+ type AgentCreateParams as AgentCreateParams,
128
+ type AgentCreateResponse as AgentCreateResponse,
129
+ type AgentListParams as AgentListParams,
130
+ type AgentProvider as AgentProvider,
131
+ type AgentRetrieveResponse as AgentRetrieveResponse,
132
+ type AgentTestParams as AgentTestParams,
133
+ type AgentTestResponse as AgentTestResponse,
134
+ type AgentUpdateParams as AgentUpdateParams,
135
+ type AgentUpdateResponse as AgentUpdateResponse,
136
+ type AgentVoiceConfig as AgentVoiceConfig,
137
+ type AgentsCursor as AgentsCursor,
138
+ Channels as Channels,
139
+ type ChannelConnectParams as ChannelConnectParams,
140
+ type ChannelConnectResponse as ChannelConnectResponse,
141
+ };
142
+ }
@@ -0,0 +1,66 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { buildHeaders } from '../../../internal/headers';
6
+ import { RequestOptions } from '../../../internal/request-options';
7
+ import { path } from '../../../internal/utils/path';
8
+ import type * as T from '../../types';
9
+ import { type ChannelType } from '../messages';
10
+
11
+ export class Channels extends APIResource {
12
+ /**
13
+ * Connect an address
14
+ *
15
+ * Make the agent answer on an address. Connecting `{address, type}` connects the
16
+ * whole channel group that entry belongs to (the entries of `GET /v2/channels`
17
+ * that share its `v1SenderId`): the agent then answers on each transport of that
18
+ * group that its `triggerOnChannels` allows, which `channels` on the agent lists.
19
+ * `type` is what picks the group when two groups share the address.
20
+ *
21
+ * An address answers with one agent at a time; connecting one already answered by
22
+ * another agent returns `400` naming that agent.
23
+ *
24
+ * `POST /v2/agents/{agentId}/channels`
25
+ */
26
+ connect(
27
+ agentID: string,
28
+ body: ChannelConnectParams,
29
+ options?: RequestOptions,
30
+ ): APIPromise<ChannelConnectResponse> {
31
+ return this._client.post(path`/v2/agents/${agentID}/channels`, { body, ...options });
32
+ }
33
+
34
+ /**
35
+ * Disconnect an address
36
+ *
37
+ * Stop the agent answering on the address. This disconnects the channel group
38
+ * behind `{address, type}`, so every transport of that group stops reaching the
39
+ * agent. An agent created on /v1 for a sender keeps that sender: its addresses
40
+ * cannot be disconnected here, and that answers `400`.
41
+ *
42
+ * `DELETE /v2/agents/{agentId}/channels/{address}/{type}`
43
+ */
44
+ disconnect(
45
+ agentID: string,
46
+ address: string,
47
+ type: ChannelType,
48
+ options?: RequestOptions,
49
+ ): APIPromise<void> {
50
+ return this._client.delete(path`/v2/agents/${agentID}/channels/${address}/${type}`, {
51
+ ...options,
52
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
53
+ });
54
+ }
55
+ }
56
+
57
+ export type ChannelConnectParams = T.AgentsChannelsConnectParams;
58
+
59
+ export type ChannelConnectResponse = T.ConnectAgentChannelV2Response;
60
+
61
+ export declare namespace Channels {
62
+ export {
63
+ type ChannelConnectParams as ChannelConnectParams,
64
+ type ChannelConnectResponse as ChannelConnectResponse,
65
+ };
66
+ }
@@ -0,0 +1,18 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ export {
4
+ Agents,
5
+ type AgentListParams,
6
+ type Agent,
7
+ type AgentsCursor,
8
+ type AgentProvider,
9
+ type AgentVoiceConfig,
10
+ type AgentCreateParams,
11
+ type AgentCreateResponse,
12
+ type AgentRetrieveResponse,
13
+ type AgentUpdateParams,
14
+ type AgentUpdateResponse,
15
+ type AgentTestParams,
16
+ type AgentTestResponse,
17
+ } from './agents';
18
+ export { Channels, type ChannelConnectParams, type ChannelConnectResponse } from './channels';
@@ -0,0 +1,3 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ export * from './agents/index';
@@ -0,0 +1,178 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { Cursor, PagePromise } from '../../../core/pagination';
6
+ import { buildHeaders } from '../../../internal/headers';
7
+ import { RequestOptions } from '../../../internal/request-options';
8
+ import { path } from '../../../internal/utils/path';
9
+ import type * as T from '../../types';
10
+ import * as RecipientsAPI from './recipients';
11
+ import {
12
+ Recipients,
13
+ type RecipientAddParams,
14
+ type RecipientAddResponse,
15
+ type BroadcastContactInput,
16
+ type BroadcastContactsAddResponse,
17
+ } from './recipients';
18
+
19
+ export class Campaigns extends APIResource {
20
+ recipients: RecipientsAPI.Recipients = new RecipientsAPI.Recipients(this._client);
21
+
22
+ /**
23
+ * List campaigns
24
+ *
25
+ * Campaigns of this project, newest first, as `GET /v1/broadcasts`, each with
26
+ * `from` instead of `senderId`. Cursor pagination: pass `nextCursor` back as
27
+ * `cursor`.
28
+ *
29
+ * `GET /v2/campaigns`
30
+ */
31
+ list(
32
+ query: CampaignListParams | null | undefined = {},
33
+ options?: RequestOptions,
34
+ ): PagePromise<BroadcastsCursor, Broadcast> {
35
+ return this._client.getAPIList('/v2/campaigns', Cursor<Broadcast>, { query, ...options });
36
+ }
37
+
38
+ /**
39
+ * Create a campaign
40
+ *
41
+ * A campaign is a /v1 broadcast; the id works on `/v1/broadcasts/{broadcastId}`.
42
+ * Runs `POST /v1/broadcasts` with the sender resolved from `from`. A repeated
43
+ * `idempotencyKey` answers `409 conflict` with the original in `details.campaign`.
44
+ * A `channel` the resolved sender does not carry (`smart`: no channel at all) is
45
+ * refused at creation with `409 no_channel`, as on `POST /v2/messages`, rather
46
+ * than created and failed at send. `from` with a `channel` it does not carry (a
47
+ * `sms` campaign `from: "sms_oneway"`) is that same `409 no_channel`, in the words
48
+ * `POST /v2/messages` uses (`details.connected`, and `sms` vs `sms_oneway` told
49
+ * apart); `channel` only picks between senders that share an address, it never
50
+ * makes an existing address `404`.
51
+ *
52
+ * `POST /v2/campaigns`
53
+ */
54
+ create(body: CampaignCreateParams, options?: RequestOptions): APIPromise<CampaignCreateResponse> {
55
+ return this._client.post('/v2/campaigns', { body, ...options });
56
+ }
57
+
58
+ /**
59
+ * Get a campaign
60
+ *
61
+ * `GET /v2/campaigns/{campaignId}`
62
+ */
63
+ retrieve(campaignID: string, options?: RequestOptions): APIPromise<CampaignRetrieveResponse> {
64
+ return this._client.get(path`/v2/campaigns/${campaignID}`, options);
65
+ }
66
+
67
+ /**
68
+ * Delete a draft campaign
69
+ *
70
+ * Deletes a campaign that is still a `draft`, as `DELETE
71
+ * /v1/broadcasts/{broadcastId}`. Any other status is refused with `409
72
+ * invalid_status` (`details.status`): a campaign that was sent or cancelled is
73
+ * kept as the record of what went out, and one still in review, scheduled or
74
+ * sending is cancelled with `POST /v2/campaigns/{campaignId}/cancel`
75
+ * (`details.recommendation`). /v1 refuses the same with a `400`.
76
+ *
77
+ * `DELETE /v2/campaigns/{campaignId}`
78
+ */
79
+ delete(campaignID: string, options?: RequestOptions): APIPromise<void> {
80
+ return this._client.delete(path`/v2/campaigns/${campaignID}`, {
81
+ ...options,
82
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
83
+ });
84
+ }
85
+
86
+ /**
87
+ * Send or schedule a campaign
88
+ *
89
+ * Same review rules as `POST /v1/broadcasts/{broadcastId}/send`: a WhatsApp
90
+ * campaign on an approved template starts directly, email starts once automated
91
+ * review passes, other channels wait for a person. Omit `scheduledAt` to send now.
92
+ *
93
+ * `POST /v2/campaigns/{campaignId}/send`
94
+ */
95
+ send(
96
+ campaignID: string,
97
+ body: CampaignSendParams | null | undefined = {},
98
+ options?: RequestOptions,
99
+ ): APIPromise<CampaignSendResponse> {
100
+ return this._client.post(path`/v2/campaigns/${campaignID}/send`, { body, ...options });
101
+ }
102
+
103
+ /**
104
+ * Get campaign progress
105
+ *
106
+ * `GET /v2/campaigns/{campaignId}/progress`
107
+ */
108
+ progress(campaignID: string, options?: RequestOptions): APIPromise<CampaignProgressResponse> {
109
+ return this._client.get(path`/v2/campaigns/${campaignID}/progress`, options);
110
+ }
111
+
112
+ /**
113
+ * Cancel a campaign
114
+ *
115
+ * As `POST /v1/broadcasts/{broadcastId}/cancel`. Recipients not yet sent are
116
+ * skipped; messages already queued may still be delivered.
117
+ *
118
+ * `POST /v2/campaigns/{campaignId}/cancel`
119
+ */
120
+ cancel(campaignID: string, options?: RequestOptions): APIPromise<CampaignCancelResponse> {
121
+ return this._client.post(path`/v2/campaigns/${campaignID}/cancel`, options);
122
+ }
123
+ }
124
+
125
+ export type CampaignListParams = T.CampaignsListParams;
126
+
127
+ export type Broadcast = T.Broadcast;
128
+
129
+ export type BroadcastsCursor = Cursor<T.Broadcast>;
130
+
131
+ export type BroadcastChannel = T.BroadcastChannel;
132
+
133
+ export type BroadcastContent = T.BroadcastContent;
134
+
135
+ export type BroadcastMessageType = T.BroadcastMessageType;
136
+
137
+ export type BroadcastStatus = T.BroadcastStatus;
138
+
139
+ export type CampaignCreateParams = T.CampaignsCreateParams;
140
+
141
+ export type CampaignCreateResponse = T.CreateCampaignV2Response;
142
+
143
+ export type CampaignRetrieveResponse = T.GetCampaignV2Response;
144
+
145
+ export type CampaignSendParams = T.CampaignsSendParams;
146
+
147
+ export type CampaignSendResponse = T.SendCampaignV2Response;
148
+
149
+ export type CampaignProgressResponse = T.BroadcastProgress;
150
+
151
+ export type BroadcastProgress = T.BroadcastProgress;
152
+
153
+ export type CampaignCancelResponse = T.CancelCampaignV2Response;
154
+
155
+ export declare namespace Campaigns {
156
+ export {
157
+ type Broadcast as Broadcast,
158
+ type BroadcastChannel as BroadcastChannel,
159
+ type BroadcastContent as BroadcastContent,
160
+ type BroadcastMessageType as BroadcastMessageType,
161
+ type BroadcastProgress as BroadcastProgress,
162
+ type BroadcastStatus as BroadcastStatus,
163
+ type BroadcastsCursor as BroadcastsCursor,
164
+ type CampaignCancelResponse as CampaignCancelResponse,
165
+ type CampaignCreateParams as CampaignCreateParams,
166
+ type CampaignCreateResponse as CampaignCreateResponse,
167
+ type CampaignListParams as CampaignListParams,
168
+ type CampaignProgressResponse as CampaignProgressResponse,
169
+ type CampaignRetrieveResponse as CampaignRetrieveResponse,
170
+ type CampaignSendParams as CampaignSendParams,
171
+ type CampaignSendResponse as CampaignSendResponse,
172
+ Recipients as Recipients,
173
+ type RecipientAddParams as RecipientAddParams,
174
+ type RecipientAddResponse as RecipientAddResponse,
175
+ type BroadcastContactInput as BroadcastContactInput,
176
+ type BroadcastContactsAddResponse as BroadcastContactsAddResponse,
177
+ };
178
+ }
@@ -0,0 +1,27 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ export {
4
+ Campaigns,
5
+ type CampaignListParams,
6
+ type Broadcast,
7
+ type BroadcastsCursor,
8
+ type BroadcastChannel,
9
+ type BroadcastContent,
10
+ type BroadcastMessageType,
11
+ type BroadcastStatus,
12
+ type CampaignCreateParams,
13
+ type CampaignCreateResponse,
14
+ type CampaignRetrieveResponse,
15
+ type CampaignSendParams,
16
+ type CampaignSendResponse,
17
+ type CampaignProgressResponse,
18
+ type BroadcastProgress,
19
+ type CampaignCancelResponse,
20
+ } from './campaigns';
21
+ export {
22
+ Recipients,
23
+ type RecipientAddParams,
24
+ type RecipientAddResponse,
25
+ type BroadcastContactInput,
26
+ type BroadcastContactsAddResponse,
27
+ } from './recipients';
@@ -0,0 +1,62 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { RequestOptions } from '../../../internal/request-options';
6
+ import { path } from '../../../internal/utils/path';
7
+ import type * as T from '../../types';
8
+
9
+ export class Recipients extends APIResource {
10
+ /**
11
+ * Add recipients
12
+ *
13
+ * Up to 1,000 per call. Recipients are held to the rules `POST /v2/messages` holds
14
+ * `to` to. Validation happens in two steps with different outcomes:
15
+ *
16
+ * 1. **The request as a whole.** A phone number written with spaces, dashes, dots
17
+ * or parentheses after its `+` is read as the E.164 number first. Then a recipient
18
+ * that is not a phone number, email address, BSUID or chat id makes the whole
19
+ * request `400`, with `details.errors[].path` naming it (`["contacts", 2,
20
+ * "recipient"]`); so do 8-15 bare digits on an `sms`, `sms_oneway`, `whatsapp`,
21
+ * `voice` or `smart` campaign, with `details.errors[].suggestion` (`+<digits>`),
22
+ * as a send refuses them. Nothing is added.
23
+ * 2. **Each recipient against the campaign.** A well-formed recipient the campaign
24
+ * cannot reach is skipped and reported in `invalid` and `errors[{recipient,
25
+ * reason, code?}]`: `code: "unreachable_by_channel"` for an email address on a
26
+ * phone campaign or a phone number on an email campaign; `code:
27
+ * "ten_dlc_required"` for a US/Canadian (+1) number on an `sms` or `sms_oneway`
28
+ * campaign while this project has no approved 10DLC campaign (the send would
29
+ * refuse it, as `POST /v2/messages` answers `403 ten_dlc_required`). Repeats of a
30
+ * recipient already in the campaign or in the same call are skipped as
31
+ * `duplicates`. The others are added, and the call answers `201`.
32
+ *
33
+ * So `201` can mean some were not added: check `invalid`. A campaign that is not a
34
+ * draft answers `409 invalid_status`.
35
+ *
36
+ * `POST /v2/campaigns/{campaignId}/recipients`
37
+ */
38
+ add(
39
+ campaignID: string,
40
+ body: RecipientAddParams,
41
+ options?: RequestOptions,
42
+ ): APIPromise<RecipientAddResponse> {
43
+ return this._client.post(path`/v2/campaigns/${campaignID}/recipients`, { body, ...options });
44
+ }
45
+ }
46
+
47
+ export type RecipientAddParams = T.CampaignsRecipientsAddParams;
48
+
49
+ export type RecipientAddResponse = T.BroadcastContactsAddResponse;
50
+
51
+ export type BroadcastContactInput = T.BroadcastContactInput;
52
+
53
+ export type BroadcastContactsAddResponse = T.BroadcastContactsAddResponse;
54
+
55
+ export declare namespace Recipients {
56
+ export {
57
+ type BroadcastContactInput as BroadcastContactInput,
58
+ type BroadcastContactsAddResponse as BroadcastContactsAddResponse,
59
+ type RecipientAddParams as RecipientAddParams,
60
+ type RecipientAddResponse as RecipientAddResponse,
61
+ };
62
+ }
@@ -0,0 +1,3 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ export * from './campaigns/index';
@@ -0,0 +1,156 @@
1
+ // Generated by zavu-codegen from apps/docs/api-reference/v2/openapi.json. Do not edit: run `bun run codegen`.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { Cursor, PagePromise } from '../../core/pagination';
6
+ import { buildHeaders } from '../../internal/headers';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+ import { path } from '../../internal/utils/path';
9
+ import type * as T from '../types';
10
+ import { type ChannelType } from './messages';
11
+
12
+ /** Where the project can send from: one entry per (address, type). */
13
+ export class Channels extends APIResource {
14
+ /**
15
+ * List channels
16
+ *
17
+ * Every (address, type) the project can send from, and whether it can send right
18
+ * now. Paginated by sender: a page holds every entry of up to `limit` senders, so
19
+ * it can hold more than `limit` entries.
20
+ *
21
+ * `GET /v2/channels`
22
+ */
23
+ list(
24
+ query: ChannelListParams | null | undefined = {},
25
+ options?: RequestOptions,
26
+ ): PagePromise<ChannelEntriesCursor, ChannelEntry> {
27
+ return this._client.getAPIList('/v2/channels', Cursor<ChannelEntry>, { query, ...options });
28
+ }
29
+
30
+ /**
31
+ * Connect a channel
32
+ *
33
+ * Connect a channel without buying anything, so a new project can send its first
34
+ * message from /v2. Returns every entry of the connected address (`GET
35
+ * /v2/channels/{address}`).
36
+ *
37
+ * **Where it lands.** Channels are grouped: the entries of `GET /v2/channels` that
38
+ * share a `v1SenderId` are one group, and a group holds one connection per
39
+ * transport. The new channel joins the project's default group when that group
40
+ * does not carry the transport yet; otherwise, or when the project has none, it
41
+ * starts a new group (the first group of a project becomes its default). So in a
42
+ * fresh project every channel connected here lands on the default and `POST
43
+ * /v2/messages` needs no `from`; a second email address or a second bot starts its
44
+ * own group and is used by passing its address as `from`.
45
+ *
46
+ * **Idempotent** for `sms_oneway` and `email`: an address already connected
47
+ * answers `200` with its entries and changes nothing.
48
+ *
49
+ * **Active or not.** One-way SMS is active at once. An email or Telegram
50
+ * connection the plan includes is switched on by itself; one that would cost money
51
+ * is listed with `active: false` and is switched on with `POST
52
+ * /v2/channels/{address}/{type}/activate` (same price and limits as on /v1).
53
+ *
54
+ * A Telegram token that Telegram refuses leaves nothing behind.
55
+ *
56
+ * `POST /v2/channels`
57
+ */
58
+ connect(body: ChannelConnectParams, options?: RequestOptions): APIPromise<ChannelConnectResponse> {
59
+ return this._client.post('/v2/channels', { body, ...options });
60
+ }
61
+
62
+ /**
63
+ * Get the entries of one address
64
+ *
65
+ * Every transport the address carries, one entry each.
66
+ *
67
+ * `GET /v2/channels/{address}`
68
+ */
69
+ retrieve(address: string, options?: RequestOptions): APIPromise<ChannelRetrieveResponse> {
70
+ return this._client.get(path`/v2/channels/${address}`, options);
71
+ }
72
+
73
+ /**
74
+ * Activate a transport
75
+ *
76
+ * The same switch as **Activate** on Accounts in the dashboard, with the same
77
+ * price and limits: on a paid plan a month is charged at once, stated in
78
+ * `chargedCents` and `monthlyCents`. `activated: false` means it was already on
79
+ * and nothing was charged.
80
+ *
81
+ * `POST /v2/channels/{address}/{type}/activate`
82
+ */
83
+ activate(
84
+ address: string,
85
+ type: ActivatableChannel,
86
+ options?: RequestOptions,
87
+ ): APIPromise<ChannelActivateResponse> {
88
+ return this._client.post(path`/v2/channels/${address}/${type}/activate`, options);
89
+ }
90
+
91
+ /**
92
+ * Deactivate a transport
93
+ *
94
+ * Switch the connection off. It stays connected, so activating it again needs no
95
+ * reconnection. The month already paid is not refunded.
96
+ *
97
+ * `POST /v2/channels/{address}/{type}/deactivate`
98
+ */
99
+ deactivate(
100
+ address: string,
101
+ type: ActivatableChannel,
102
+ options?: RequestOptions,
103
+ ): APIPromise<ChannelDeactivateResponse> {
104
+ return this._client.post(path`/v2/channels/${address}/${type}/deactivate`, options);
105
+ }
106
+
107
+ /**
108
+ * Disconnect a channel
109
+ *
110
+ * Disconnect one (address, type). `sms_oneway`, `telegram` and `voice` can be
111
+ * disconnected here. The others answer `409 disconnect_unavailable` saying what to
112
+ * do instead: `whatsapp`, `instagram`, `messenger` and `email` can be switched off
113
+ * with `.../deactivate` (they stay connected); two-way `sms` comes with the
114
+ * address's number.
115
+ *
116
+ * `DELETE /v2/channels/{address}/{type}`
117
+ */
118
+ disconnect(address: string, type: ChannelType, options?: RequestOptions): APIPromise<void> {
119
+ return this._client.delete(path`/v2/channels/${address}/${type}`, {
120
+ ...options,
121
+ headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
122
+ });
123
+ }
124
+ }
125
+
126
+ export type ChannelListParams = T.ChannelsListParams;
127
+
128
+ export type ChannelEntry = T.ChannelEntry;
129
+
130
+ export type ChannelEntriesCursor = Cursor<T.ChannelEntry>;
131
+
132
+ export type ChannelConnectParams = T.ChannelsConnectParams;
133
+
134
+ export type ChannelConnectResponse = T.ConnectChannelV2Response;
135
+
136
+ export type ChannelRetrieveResponse = T.GetChannelV2Response;
137
+
138
+ export type ActivatableChannel = T.ActivatableChannel;
139
+
140
+ export type ChannelActivateResponse = T.ActivateChannelV2Response;
141
+
142
+ export type ChannelDeactivateResponse = T.DeactivateChannelV2Response;
143
+
144
+ export declare namespace Channels {
145
+ export {
146
+ type ActivatableChannel as ActivatableChannel,
147
+ type ChannelActivateResponse as ChannelActivateResponse,
148
+ type ChannelConnectParams as ChannelConnectParams,
149
+ type ChannelConnectResponse as ChannelConnectResponse,
150
+ type ChannelDeactivateResponse as ChannelDeactivateResponse,
151
+ type ChannelEntriesCursor as ChannelEntriesCursor,
152
+ type ChannelEntry as ChannelEntry,
153
+ type ChannelListParams as ChannelListParams,
154
+ type ChannelRetrieveResponse as ChannelRetrieveResponse,
155
+ };
156
+ }