@signalhouse-sms/sdk 1.12.0 → 1.14.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalhouse-sms/sdk",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "Signal House SDK for use with the Signal House platform",
5
5
  "type": "module",
6
6
  "main": "src/SignalHouseSDK.js",
@@ -47,6 +47,9 @@ import { Notifications } from "./domains/Notifications.js";
47
47
  import { Webhooks } from "./domains/Webhooks.js";
48
48
  import { Voice } from "./domains/Voice.js";
49
49
  import { Agents } from "./domains/Agents.js";
50
+ import { Audit } from "./domains/Audit.js";
51
+ import { Contracts } from "./domains/Contracts.js";
52
+ import { Verify } from "./domains/Verify.js";
50
53
 
51
54
  export class SignalHouseSDK {
52
55
  /**
@@ -98,6 +101,10 @@ export class SignalHouseSDK {
98
101
  this.voice = new Voice(client, this.enableAdmin);
99
102
  // AI Agents domain — customer-facing agent config under /agent.
100
103
  this.agents = new Agents(client, this.enableAdmin);
104
+ this.audit = new Audit(client, this.enableAdmin);
105
+ this.contracts = new Contracts(client, this.enableAdmin);
106
+ // Carrier phone-number checks (SIM Swap, Number Verify) under /verify.
107
+ this.verify = new Verify(client, this.enableAdmin);
101
108
  }
102
109
 
103
110
  /**
@@ -0,0 +1,39 @@
1
+ /** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
2
+ /**
3
+ * @template T
4
+ * @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
5
+ */
6
+
7
+ /**
8
+ * Audit domain: the staff read of who changed a registration or a message template, and what changed. Every method lives
9
+ * under the admin namespace, present only when the SDK is created with `enableAdmin: true`.
10
+ */
11
+ export class Audit {
12
+ constructor(client, enableAdmin) {
13
+ this.client = client;
14
+ this.enableAdmin = enableAdmin;
15
+
16
+ // Hidden Admin namespace INSIDE the domain
17
+ if (enableAdmin) {
18
+ this.admin = {
19
+ /**
20
+ * Get audit events, newest first: one registration's or template's, or a group's. Staff-only.
21
+ * @async
22
+ * @roles signalhouse
23
+ * @param {Object} params
24
+ * @param {("registration"|"template")} [params.entityType] - The entity type; required with entityId
25
+ * @param {string} [params.entityId] - The registration id or template id
26
+ * @param {string} [params.groupId] - The owning group; required when entityId is omitted
27
+ * @param {number} [params.page] - Page number (default 1)
28
+ * @param {number} [params.limit] - Events per page (default 25, max 100)
29
+ * @param {RequestOptions} [params.options] - Additional options for the request
30
+ * @returns {Promise<SdkResponse<any>>} - `{ data, total, page, limit }`; each event is `{ _id, occurredAt, actor: { type, userId, role }, entity: { type, id, groupId }, action, changes: [{ path, from, to }] }`
31
+ */
32
+ getAuditEvents: async ({ entityType, entityId, groupId, page, limit, options = {} } = {}) => {
33
+ const queryString = this.client._getQueryString({ entityType, entityId, groupId, page, limit });
34
+ return this.client(`/audit${queryString}`, { method: "GET", ...options });
35
+ },
36
+ };
37
+ }
38
+ }
39
+ }
@@ -519,6 +519,22 @@ export class Brands {
519
519
  return this.client(`/brand/appeal/${safeBrandId}`, { method: 'GET', ...options });
520
520
  }
521
521
 
522
+ /**
523
+ * Get TCR's identity feedback for a brand: why TCR could not verify it (status UNVERIFIED)
524
+ * @async
525
+ * @roles api, admin, developer, billing, user
526
+ * @param {Object} params - The parameters for getting the feedback
527
+ * @param {BrandLookupId} params.brandId - Brand lookup id (carrier Brand ID, record `_id`, or internal reference).
528
+ * @param {RequestOptions} [params.options] - Additional options for the request
529
+ * @throws {Error} Throws an error if the brandId parameter is missing
530
+ * @returns {Promise<SdkResponse<Object>>} BrandFeedback: { brandId, category: [{ id, displayName, description, fields, errors: [{ code, message }] }] }
531
+ */
532
+ async getBrandFeedback({ brandId, options = {} }) {
533
+ this.client._require({ brandId });
534
+ const safeBrandId = encodeURIComponent(brandId);
535
+ return this.client(`/brand/feedback/${safeBrandId}`, { method: 'GET', ...options });
536
+ }
537
+
522
538
  /**
523
539
  * Submit a brand identity status appeal with supporting documentation
524
540
  * @async
@@ -0,0 +1,117 @@
1
+ /** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
2
+ /**
3
+ * @template T
4
+ * @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
5
+ */
6
+
7
+ /**
8
+ * Contracts domain: the staff queue for pricing read from signed PandaDoc contracts. Every method lives under
9
+ * the admin namespace, present only when the SDK is created with `enableAdmin: true`. JS SDK only by design.
10
+ */
11
+ export class Contracts {
12
+ constructor(client, enableAdmin) {
13
+ this.client = client;
14
+ this.enableAdmin = enableAdmin;
15
+
16
+ // Hidden Admin namespace INSIDE the domain
17
+ if (enableAdmin) {
18
+ this.admin = {
19
+ /**
20
+ * List contracts for the staff queue, newest first. Staff-only.
21
+ * @async
22
+ * @roles signalhouse
23
+ * @param {Object} [params]
24
+ * @param {string|string[]} [params.status] - One status, or several (an array or a comma-separated string)
25
+ * @param {string} [params.groupId] - Only this group's contracts, newest signed first
26
+ * @param {number} [params.page] - Page number (default 1)
27
+ * @param {number} [params.limit] - Contracts per page (default 25, max 100)
28
+ * @param {RequestOptions} [params.options] - Additional options for the request
29
+ * @returns {Promise<SdkResponse<any>>} - `{ data, total, page, limit }`; each contract carries `pandadocUrl`
30
+ */
31
+ getContracts: async ({ status, groupId, page, limit, options = {} } = {}) => {
32
+ const queryString = this.client._getQueryString({ status: Array.isArray(status) ? status.join(",") : status, groupId, page, limit });
33
+ return this.client(`/contract${queryString}`, { method: "GET", ...options });
34
+ },
35
+
36
+ /**
37
+ * Get one contract: issues, diff, signers, a PandaDoc link and, when it has no group, a suggested one. Staff-only.
38
+ * @async
39
+ * @roles signalhouse
40
+ * @param {Object} params
41
+ * @param {string} params.contractId - The contract's ID
42
+ * @param {RequestOptions} [params.options] - Additional options for the request
43
+ * @returns {Promise<SdkResponse<any>>} - The contract with `pandadocUrl` and `suggestedGroup`
44
+ */
45
+ getContract: async ({ contractId, options = {} }) => {
46
+ this.client._require({ contractId });
47
+ return this.client(`/contract/${encodeURIComponent(contractId)}`, { method: "GET", ...options });
48
+ },
49
+
50
+ /**
51
+ * Link a contract to a group by hand; the document is then read again against that group. The link resets the contract's
52
+ * status, so a scheduled contract loses its schedule. Staff-only.
53
+ * @async
54
+ * @roles signalhouse
55
+ * @param {Object} params
56
+ * @param {string} params.contractId - The contract's ID
57
+ * @param {string} params.groupId - The group the contract is for
58
+ * @param {RequestOptions} [params.options] - Additional options for the request
59
+ * @returns {Promise<SdkResponse<any>>} - The contract after the re-read
60
+ */
61
+ linkContractGroup: async ({ contractId, groupId, options = {} }) => {
62
+ this.client._require({ contractId, groupId });
63
+ return this.client(`/contract/${encodeURIComponent(contractId)}/link`, { method: "POST", body: { groupId }, ...options });
64
+ },
65
+
66
+ /**
67
+ * Apply a contract's pricing to its group now (staff approval). A contract dated in the future is scheduled instead.
68
+ * Staff-only.
69
+ * @async
70
+ * @roles signalhouse
71
+ * @param {Object} params
72
+ * @param {string} params.contractId - The contract's ID
73
+ * @param {string} params.expectedUpdatedAt - The `updatedAt` of the contract as reviewed; a changed contract gets a 409
74
+ * @param {string} params.expectedGroupId - The group the contract was reviewed for
75
+ * @param {?number} [params.expectedPlanCharge] - The immediate charge shown from `applyPreview`, in microdollars; a plan
76
+ * create that would charge anything else is refused before charging
77
+ * @param {RequestOptions} [params.options] - Additional options for the request
78
+ * @returns {Promise<SdkResponse<any>>} - The contract after the apply
79
+ */
80
+ applyContract: async ({ contractId, expectedUpdatedAt, expectedGroupId, expectedPlanCharge, options = {} }) => {
81
+ this.client._require({ contractId, expectedUpdatedAt, expectedGroupId });
82
+ return this.client(`/contract/${encodeURIComponent(contractId)}/apply`, { method: "POST", body: { expectedUpdatedAt, expectedGroupId, ...(expectedPlanCharge !== undefined ? { expectedPlanCharge } : {}) }, ...options });
83
+ },
84
+
85
+ /**
86
+ * Reject a contract so it is never applied. Staff-only.
87
+ * @async
88
+ * @roles signalhouse
89
+ * @param {Object} params
90
+ * @param {string} params.contractId - The contract's ID
91
+ * @param {string} params.reason - Why it is rejected
92
+ * @param {RequestOptions} [params.options] - Additional options for the request
93
+ * @returns {Promise<SdkResponse<any>>} - The rejected contract
94
+ */
95
+ rejectContract: async ({ contractId, reason, options = {} }) => {
96
+ this.client._require({ contractId, reason });
97
+ return this.client(`/contract/${encodeURIComponent(contractId)}/reject`, { method: "POST", body: { reason }, ...options });
98
+ },
99
+
100
+ /**
101
+ * Read a contract from PandaDoc again and re-parse it. Not allowed while scheduled, or once pricing is being written or has been applied.
102
+ * Staff-only.
103
+ * @async
104
+ * @roles signalhouse
105
+ * @param {Object} params
106
+ * @param {string} params.contractId - The contract's ID
107
+ * @param {RequestOptions} [params.options] - Additional options for the request
108
+ * @returns {Promise<SdkResponse<any>>} - The contract after the re-read
109
+ */
110
+ reparseContract: async ({ contractId, options = {} }) => {
111
+ this.client._require({ contractId });
112
+ return this.client(`/contract/${encodeURIComponent(contractId)}/reparse`, { method: "POST", body: {}, ...options });
113
+ },
114
+ };
115
+ }
116
+ }
117
+ }
@@ -142,7 +142,7 @@ export class Messages {
142
142
  * @param {string} params.id - The message ID
143
143
  * @param {RequestOptions} [params.options] - Additional options for the request
144
144
  * @throws {Error} Throws an error if the id parameter is missing
145
- * @returns {Promise<SdkResponse<any>>} - A promise that resolves to the message; an unknown ID is a 404. An RCS message and its fallback leg also carry `costBreakdown`: `{ legs: [{ messageId, channel, billed, billingClass, segments, baseMicros, carrierMicros, rated }] }`, null when it cannot be computed
145
+ * @returns {Promise<SdkResponse<any>>} - A promise that resolves to the message; an unknown ID is a 404. An RCS message and its fallback leg also carry `costBreakdown`: `{ legs: [{ messageId, channel, billed, billingClass, segments, baseMicros, carrierMicros, rated }] }`, null when it cannot be computed. A settled RCS message also carries `carrierFeeMicros`: the carrier pass-through and media surcharge it was charged
146
146
  */
147
147
  async getMessage({ id, options = {} }) {
148
148
  this.client._require({ id });
@@ -427,6 +427,28 @@ export class Messages {
427
427
  return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
428
428
  }
429
429
 
430
+ /**
431
+ * Export the group's consent ledger, newest first: one append-only record per opt-out or opt-in a recipient gave (a STOP
432
+ * or START keyword, or the confirmation of an opt-out link). It records only; sends do not read it.
433
+ * @async
434
+ * @roles api, admin, developer, billing, user
435
+ * @param {Object} params - The parameters for exporting consent records
436
+ * @param {string} params.groupId - The group whose records to read
437
+ * @param {string} [params.recipientPhoneNumber] - One handset, in any spelling; matched on its digits
438
+ * @param {string} [params.startDate] - Earliest occurredAt, ISO-8601; a bare date is its whole UTC day, a timestamp is bound as sent
439
+ * @param {string} [params.endDate] - Latest occurredAt, ISO-8601; a bare date is its whole UTC day, a timestamp is bound as sent
440
+ * @param {number} [params.page] - Page number (default 1)
441
+ * @param {number} [params.limit] - Records per page (default 100, max 500)
442
+ * @param {RequestOptions} [params.options] - Additional options for the request
443
+ * @returns {Promise<SdkResponse<any>>} - `{ data, total, page, limit }`. Each record carries groupId, subgroupId, recipientPhoneNumber (the handset),
444
+ * phoneNumber (the business number or RCS agent id that received it), scope `{ type: CAMPAIGN|AGENT|SUBGROUP, id }`,
445
+ * clearedScopes (for OPT_IN, every `{ type, id }` the START cleared; empty for OPT_OUT), action (OPT_OUT or OPT_IN), source (KEYWORD or LINK), keyword, messageType (SMS, MMS or RCS), messageId, actor `{ type: "RECIPIENT" }`, occurredAt and createdAt.
446
+ */
447
+ async getConsentRecords({ groupId, recipientPhoneNumber, startDate, endDate, page, limit, options = {} }) {
448
+ const queryString = this.client._getQueryString({ groupId, recipientPhoneNumber, startDate, endDate, page, limit });
449
+ return this.client(`/message/dnc/consent-records${queryString}`, { method: "GET", ...options });
450
+ }
451
+
430
452
  /**
431
453
  * Send an SMS message to one or more recipient phone numbers
432
454
  *
@@ -47,6 +47,16 @@
47
47
  * @property {string} [mobile] - Mobile number, E.164
48
48
  */
49
49
 
50
+ /**
51
+ * Where one prefilled field's value came from. The agent's `autofill` holds one per field, keyed by its path
52
+ * (`consent.optInDetails`); the API marks a field `edited` once its value changes.
53
+ * @typedef {Object} RcsAgentAutofillMarker
54
+ * @property {("brand"|"campaign"|"landing")} source - The record the value came from
55
+ * @property {string|null} [sourceId] - That record's id (brand ID, campaign ID or landing page ID)
56
+ * @property {string} [at] - When the field was filled (ISO 8601; default now)
57
+ * @property {boolean} [edited] - Whether the value changed since (default false)
58
+ */
59
+
50
60
  /**
51
61
  * One recipient of an RCS send.
52
62
  * @typedef {Object} RcsRecipient
@@ -111,14 +121,15 @@ export class RcsAgents {
111
121
  * @param {{ mode?: string, channel?: string, from?: string }|null} [params.defaultFallback] - Fallback mode (auto, rcs_only, sms_only, none), channel (auto, sms, mms) and from, a number on the linked campaign
112
122
  * @param {string[]} [params.excludedCarriers] - [] or ["T_MOBILE"] (the carrier partner's carrier name)
113
123
  * @param {string[]} [params.testers] - Tester numbers (up to 200), invited once the agent exists at the carrier
124
+ * @param {Object<string, RcsAgentAutofillMarker>} [params.autofill] - Where the fields you prefilled came from, by path (`consent.optInDetails`); the API adds its own for what it fills
114
125
  * @param {RequestOptions} [params.options] - Additional options for the request
115
126
  * @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent (status DRAFT)
116
127
  */
117
- async create({ brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, options = {} }) {
128
+ async create({ brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill, options = {} }) {
118
129
  this.client._require({ brandId });
119
130
  return this.client("/rcs/agent", {
120
131
  method: "POST",
121
- body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers },
132
+ body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill },
122
133
  ...options,
123
134
  });
124
135
  }
@@ -150,7 +161,7 @@ export class RcsAgents {
150
161
  * @param {Object} params - The lookup
151
162
  * @param {string} params.agentId - The agent ID (e.g. RCSA7K2M1QZ8RP)
152
163
  * @param {RequestOptions} [params.options] - Additional options for the request
153
- * @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent
164
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent; googleAgentId is Google's id for it, null until Google has created the agent
154
165
  */
155
166
  async get({ agentId, options = {} }) {
156
167
  this.client._require({ agentId });
@@ -159,9 +170,11 @@ export class RcsAgents {
159
170
 
160
171
  /**
161
172
  * Edit an agent while it may change: a draft, a Signal House rejection, a request for changes, or an agent in
162
- * testing (the change is pushed to the carrier partner). `agent`, `consent` and `contact` merge field by field;
163
- * every other key replaces; campaignId: null unlinks the campaign. 409 in any other status; brandId is locked once
164
- * the agent exists at the partner and billingCategory once a launch was requested.
173
+ * testing (the change is pushed to the carrier partner). After a carrier rejected a launch other carriers took
174
+ * (PARTIALLY_LAUNCHED with a REJECTED carrier), only `consent` and `contact` may change, and nothing is pushed: send
175
+ * them with requestCarrierUpdate. `agent`, `consent` and `contact` merge field by field; every other key replaces;
176
+ * campaignId: null unlinks the campaign. 409 in any other status; brandId is locked once the agent exists at the
177
+ * partner and billingCategory once a launch was requested.
165
178
  * @async
166
179
  * @roles api, admin, developer, billing, user
167
180
  * @param {Object} params - The edit
@@ -176,14 +189,15 @@ export class RcsAgents {
176
189
  * @param {Object|null} [params.defaultFallback] - The fallback
177
190
  * @param {string[]} [params.excludedCarriers] - [] or ["T_MOBILE"] (the carrier partner's carrier name)
178
191
  * @param {string[]} [params.testers] - Tester numbers
192
+ * @param {Object<string, RcsAgentAutofillMarker>} [params.autofill] - Replaces the prefill markers; omitted, the stored ones are kept and a changed field's marker turns edited
179
193
  * @param {RequestOptions} [params.options] - Additional options for the request
180
194
  * @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent
181
195
  */
182
- async update({ agentId, brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, options = {} }) {
196
+ async update({ agentId, brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill, options = {} }) {
183
197
  this.client._require({ agentId });
184
198
  return this.client(`/rcs/agent/${encodeURIComponent(agentId)}`, {
185
199
  method: "PUT",
186
- body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers },
200
+ body: { brandId, campaignId, agent, consent, contact, useCase, billingCategory, defaultFallback, excludedCarriers, testers, autofill },
187
201
  ...options,
188
202
  });
189
203
  }
@@ -192,6 +206,8 @@ export class RcsAgents {
192
206
  * Check an agent against the next gate on its path without writing: before it exists at the carrier partner, what
193
207
  * creating it needs (the full profile, useCase, a billingCategory); after that, what the launch request needs
194
208
  * (a VERIFIED brand, the campaign, the full consent with the video, the contact)
209
+ * The launch gate also runs the carriers' copy rules; each error carries the carrier partner's key as `code`, for
210
+ * example OPT_IN_MSG_RATE_DISCL_MISSING.
195
211
  * @async
196
212
  * @roles api, admin, developer, billing, user
197
213
  * @param {Object} params - The lookup
@@ -208,6 +224,8 @@ export class RcsAgents {
208
224
  * Submit a draft: create the agent at the carrier partner, with no review first. It needs the full profile, a
209
225
  * useCase and a billingCategory; otherwise a 400 whose details carry { code: "REGISTRATION_INCOMPLETE",
210
226
  * errors, warnings }. The agent moves to AGENT_CREATING, then IN_TESTING once the partner reports it ready.
227
+ * A group that has not finished account verification gets a 403 with code GROUP_UNVERIFIED, and a rejected one a 403
228
+ * with code GROUP_REJECTED; a pending verification passes.
211
229
  * @async
212
230
  * @roles api, admin, developer, billing, user
213
231
  * @param {Object} params - The submission
@@ -224,7 +242,9 @@ export class RcsAgents {
224
242
  * Request the agent's launch: the launch requirements are checked and the agent goes to Signal House review (status
225
243
  * PENDING_REVIEW), whose approval files the launch with the carrier partner. Allowed from IN_TESTING, REJECTED and
226
244
  * CARRIER_REJECTED (409 otherwise); a failed requirement is a 400 whose details carry { code:
227
- * "REGISTRATION_INCOMPLETE", errors, warnings }. Sends POST /registration/:agentId/launch: the agent is a registration.
245
+ * "REGISTRATION_INCOMPLETE", errors, warnings }, and a copy-rule error carries the carrier partner's key as its `code`
246
+ * (for example OPT_IN_MSG_RATE_DISCL_MISSING). A group that has not finished account verification gets a 403 with code
247
+ * GROUP_UNVERIFIED, and a rejected one a 403 with code GROUP_REJECTED. Sends POST /registration/:agentId/launch: the agent is a registration.
228
248
  * The request charges the agent's launch fees: a wallet that cannot cover them gets a 402, and the agent stays where it is. When any fee is due the request must set acknowledgeFees: true, or it gets a 400 with code FEE_ACKNOWLEDGEMENT_REQUIRED and nothing is held; a launch with nothing due needs no acknowledgement. The agent's launchFees quotes what the next request charges.
229
249
  * When the agent's brand vertical is healthcare or insurance, the launch needs the protected health information (PHI) disclosure acknowledged: send acknowledgePhi: true, or the request gets a 400 REGISTRATION_INCOMPLETE whose errors name consent.phiAcknowledgement. The API records the acknowledgement as consent.phiAcknowledgement { acknowledgedAt, acknowledgedBy } from the caller; the client sends only the boolean, and an agent update cannot set it. Once recorded, a later launch request needs no new acknowledgement.
230
250
  * @async
@@ -241,6 +261,24 @@ export class RcsAgents {
241
261
  return this.client(`/registration/${encodeURIComponent(agentId)}/launch`, { method: "POST", body: { acknowledgeFees, acknowledgePhi }, ...options });
242
262
  }
243
263
 
264
+ /**
265
+ * Send Signal House the corrected launch answers after a carrier rejected a launch other carriers took. The carrier
266
+ * partner takes no change through its API once a carrier launched, so Signal House emails it the update; edit
267
+ * `consent` and `contact` first. The agent's carrierUpdate reads REQUESTED for the rejected carriers, then SENT once
268
+ * Signal House sent it. 409 when no carrier is REJECTED after a partial launch, or an update already waits.
269
+ * Sends POST /registration/:agentId/carrier-update: the agent is a registration.
270
+ * @async
271
+ * @roles api, admin, developer, billing, user
272
+ * @param {Object} params - The request
273
+ * @param {string} params.agentId - The agent ID
274
+ * @param {RequestOptions} [params.options] - Additional options for the request
275
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the agent's registration, with data.carrierUpdate
276
+ */
277
+ async requestCarrierUpdate({ agentId, options = {} }) {
278
+ this.client._require({ agentId });
279
+ return this.client(`/registration/${encodeURIComponent(agentId)}/carrier-update`, { method: "POST", ...options });
280
+ }
281
+
244
282
  /**
245
283
  * Archive an agent. One the carrier partner created stops sending at once and stays ARCHIVE_PENDING until Signal House confirms the partner cancelled it, then ARCHIVED. Archiving cannot be undone; an agent already ARCHIVE_PENDING answers 409.
246
284
  * @async
@@ -255,6 +293,24 @@ export class RcsAgents {
255
293
  return this.client(`/rcs/agent/${encodeURIComponent(agentId)}/archive`, { method: "POST", ...options });
256
294
  }
257
295
 
296
+ /**
297
+ * Make the links that start a chat with the agent: an sms: deep link in Google's format, and a short link that redirects to it,
298
+ * to print as a QR code. With the agent's defaultFallback.from, the deep link names that number, so a handset that cannot reach
299
+ * the agent texts it instead. The same request returns the same short link. The links work for approved testers until a carrier
300
+ * launches the agent; before Google has created the agent the request answers 409 with code GOOGLE_AGENT_PENDING.
301
+ * @async
302
+ * @roles api, admin, developer, billing, user
303
+ * @param {Object} params - The request
304
+ * @param {string} params.agentId - The agent ID
305
+ * @param {string} [params.body] - The message the chat opens with, prefilled on the handset (max 1,000 characters)
306
+ * @param {RequestOptions} [params.options] - Additional options for the request
307
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to { googleAgentId, deepLink, shortLink }
308
+ */
309
+ async createEntryPoints({ agentId, body, options = {} }) {
310
+ this.client._require({ agentId });
311
+ return this.client(`/rcs/agent/${encodeURIComponent(agentId)}/entry-points`, { method: "POST", body: { body }, ...options });
312
+ }
313
+
258
314
  /**
259
315
  * Resend a tester's expired invitation, which starts a new 24 hours for the tester to accept it. The number must be
260
316
  * a tester on the agent (404) and its invitation must be EXPIRED (409); up to 20 invitations go out a day (429).
@@ -356,6 +412,42 @@ export class RcsMessages {
356
412
  });
357
413
  }
358
414
 
415
+ /**
416
+ * Send an RCS message to up to 10,000 recipients in the background. The request runs the send's request checks, splits the
417
+ * recipients into chunks of 100, queues each chunk and answers 202. Every message carries the shared bulkId; track progress with
418
+ * the messages list filtered by bulkId (GET /message?bulkId=) and per-message webhooks. A chunk the wallet cannot cover, or that is
419
+ * refused after acceptance, gets BLOCKED messages with blockReason INSUFFICIENT_FUNDS or SEND_REFUSED; a chunk that keeps failing
420
+ * gets SEND_FAILED. Pass options.idempotencyKey to make a retry safe (same bulkId, no duplicate sends); a retry without one may
421
+ * send duplicates.
422
+ * @async
423
+ * @roles api, admin, developer, billing, user
424
+ * @param {Object} params - The send; the same fields as send
425
+ * @param {string} params.agentId - The agent that sends (RCSA…)
426
+ * @param {RcsRecipient[]} params.recipients - Up to 10,000 recipients
427
+ * @param {string} [params.templateId] - A template to send; exactly one of templateId or content
428
+ * @param {number} [params.templateVersion] - A published version of templateId; needs templateId. Pinned when the batch is accepted
429
+ * @param {Object} [params.content] - Inline content; exactly one of templateId or content
430
+ * @param {string} [params.contentFormat] - content.v1 (default) or google.rcs
431
+ * @param {("AUTHENTICATION"|"TRANSACTION"|"SERVICEREQUEST"|"ACKNOWLEDGEMENT"|"PROMOTION")} [params.trafficType] - Required on a MULTI_USE agent when the template sets none
432
+ * @param {number} [params.ttlSeconds] - Seconds each RCS message may wait for delivery, from when its chunk is sent; at most one of ttlSeconds or expireTime
433
+ * @param {string} [params.expireTime] - ISO-8601 time the RCS messages expire
434
+ * @param {RcsMessageFallback} [params.fallback] - The fallback for this send
435
+ * @param {string} [params.statusCallbackUrl] - URL that receives each message's events
436
+ * @param {boolean} [params.enableShortlink] - Shorten the links in the message
437
+ * @param {boolean} [params.isTest] - Send as a test; approved testers only
438
+ * @param {("not_capable"|"ttl_expired"|"delivered"|"read")} [params.simulate] - Simulate this outcome; approved testers only
439
+ * @param {RequestOptions} [params.options] - Additional options for the request
440
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to { bulkId, status: "ACCEPTED", recipientCount } (202). Every message of the batch carries bulkId. A recipient from 19999990000 to 19999990359 makes the whole request a simulation, as on send
441
+ */
442
+ async sendBatch({ agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate, options = {} }) {
443
+ this.client._require({ agentId, recipients });
444
+ return this.client("/message/rcs/batch", {
445
+ method: "POST",
446
+ body: { agentId, recipients, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, statusCallbackUrl, enableShortlink, isTest, simulate },
447
+ ...options,
448
+ });
449
+ }
450
+
359
451
  /**
360
452
  * Check a send without writing anything. Takes the same parameters as send.
361
453
  * @async
@@ -404,7 +496,7 @@ export class RcsMessages {
404
496
  * @param {string} [params.expireTime] - ISO-8601 time the RCS message expires
405
497
  * @param {RcsMessageFallback} [params.fallback] - The fallback to price; its from is optional here, and with none the leg is priced on the channel of the agent's linked campaign
406
498
  * @param {RequestOptions} [params.options] - Additional options for the request
407
- * @returns {Promise<SdkResponse<any>>} A promise that resolves to { billingClass, segments, recipientCount, rcsLeg, fallbackLeg, totals, balance, issues, warnings }; rcsLeg.mediaSurcharge is the carrier's surcharge on media over 5 MB for one recipient, and rcsLeg.cost already holds it for every recipient; rcsLeg.cost is null with the fallback mode sms_only; a message over 100 MB adds a MEDIA_TOO_LARGE issue.
499
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to { billingClass, segments, recipientCount, rcsLeg, fallbackLeg, totals, balance, issues, warnings }; rcsLeg.mediaSurcharge is the carrier's surcharge on media over 5 MB for one recipient, and rcsLeg.cost already holds it for every recipient; rcsLeg.cost is null with the fallback mode sms_only; a message over 100 MB adds a MEDIA_TOO_LARGE issue, and an external media URL that redirects adds a MEDIA_REDIRECT issue.
408
500
  */
409
501
  async estimate({ agentId, recipients, recipientCount, templateId, templateVersion, content, contentFormat, trafficType, ttlSeconds, expireTime, fallback, options = {} }) {
410
502
  this.client._require({ agentId });
@@ -460,7 +552,7 @@ export class RcsMessages {
460
552
  * @param {Object} params - The lookup
461
553
  * @param {string} params.messageId - The message ID
462
554
  * @param {RequestOptions} [params.options] - Additional options for the request
463
- * @returns {Promise<SdkResponse<any>>} A promise that resolves to the message; an unknown ID is a 404
555
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the message; an unknown ID is a 404. A settled RCS message carries carrierFeeMicros, the carrier pass-through and media surcharge it was charged
464
556
  */
465
557
  async get({ messageId, options = {} }) {
466
558
  this.client._require({ messageId });
@@ -488,7 +580,7 @@ export class RcsMessages {
488
580
  * @param {string} [params.deliveredChannel] - Filter by the channel that delivered the message (rcs, sms, mms)
489
581
  * @param {boolean} [params.isTest] - true for test messages only, false to leave them out
490
582
  * @param {RequestOptions} [params.options] - Additional options for the request
491
- * @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of messages
583
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of messages; a settled RCS message carries carrierFeeMicros
492
584
  */
493
585
  async list({ groupId, from, to, agentId, status, page, limit, templateId, templateVersion, bulkId, fallbackReason, billingClass, deliveredChannel, isTest, options = {} }) {
494
586
  this.client._require({ groupId, from, to });
@@ -159,6 +159,63 @@ export class Registrations {
159
159
  ...options,
160
160
  });
161
161
  },
162
+
163
+ /**
164
+ * Mark an RCS agent's requested carrier update as sent, once staff emailed it to the carrier partner (signalhouse only)
165
+ * @async
166
+ * @roles signalhouse
167
+ * @param {Object} params - The parameters for the update
168
+ * @param {string} params.registrationId - The agent's registration ID (e.g. RCSA7K2M1QZ8RP)
169
+ * @param {RequestOptions} [params.options] - Additional options for the request
170
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to the registration, as staff read it; 409 when no update is REQUESTED
171
+ */
172
+ markCarrierUpdateSent: async ({ registrationId, options = {} }) => {
173
+ this.client._require({ registrationId });
174
+ const safeId = encodeURIComponent(registrationId);
175
+ return this.client(`/registration/${safeId}/carrier-update`, {
176
+ method: "PUT",
177
+ body: { status: "SENT" },
178
+ ...options,
179
+ });
180
+ },
181
+
182
+ /**
183
+ * Add an internal comment to a registration of any type; comments are append-only and never reach the customer (signalhouse only)
184
+ * @async
185
+ * @roles signalhouse
186
+ * @param {Object} params - The parameters for the comment
187
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
188
+ * @param {string} params.comment - The comment, 1 to 2,000 characters
189
+ * @param {RequestOptions} [params.options] - Additional options for the request
190
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to { comment, createdAt, createdBy, createdByRole }
191
+ */
192
+ addComment: async ({ registrationId, comment, options = {} }) => {
193
+ this.client._require({ registrationId, comment });
194
+ const safeId = encodeURIComponent(registrationId);
195
+ return this.client(`/registration/${safeId}/comments`, {
196
+ method: "POST",
197
+ body: { comment },
198
+ ...options,
199
+ });
200
+ },
201
+
202
+ /**
203
+ * List a registration's internal comments, newest first (signalhouse only)
204
+ * @async
205
+ * @roles signalhouse
206
+ * @param {Object} params - The parameters for the read
207
+ * @param {string} params.registrationId - The registration ID (e.g. RCSA7K2M1QZ8RP)
208
+ * @param {RequestOptions} [params.options] - Additional options for the request
209
+ * @returns {Promise<SdkResponse<any>>} A promise that resolves to { comments: [{ comment, createdAt, createdBy, createdByRole }] }
210
+ */
211
+ getComments: async ({ registrationId, options = {} }) => {
212
+ this.client._require({ registrationId });
213
+ const safeId = encodeURIComponent(registrationId);
214
+ return this.client(`/registration/${safeId}/comments`, {
215
+ method: "GET",
216
+ ...options,
217
+ });
218
+ },
162
219
  };
163
220
  }
164
221
  }
@@ -278,7 +335,8 @@ export class Registrations {
278
335
  * Submit a draft. A type Signal House reviews goes to SIGNAL_HOUSE_REVIEW; a type it does not (RCS_AGENT) goes to
279
336
  * SUBMITTING and is filed with the provider at once. A draft that fails a requirement gets a 400 whose details carry
280
337
  * { code: "REGISTRATION_INCOMPLETE", errors, warnings }; a second submit, or one of a registration the provider
281
- * already holds, gets a 409.
338
+ * already holds, gets a 409. An RCS agent whose group has not finished account verification gets a 403 with code
339
+ * GROUP_UNVERIFIED, and one whose group is rejected a 403 with code GROUP_REJECTED.
282
340
  * @async
283
341
  * @roles api, admin, developer, billing, user
284
342
  * @param {Object} params - The parameters for the submission
@@ -297,7 +355,9 @@ export class Registrations {
297
355
  * are checked and the registration goes to SIGNAL_HOUSE_REVIEW, whose approval files the provider's launch request.
298
356
  * Allowed while the provider reports the agent ready for testing, after a Signal House rejection, or after every
299
357
  * carrier refused an earlier launch (409 otherwise); a failed requirement is a 400 whose details carry
300
- * { code: "REGISTRATION_INCOMPLETE", errors, warnings }.
358
+ * { code: "REGISTRATION_INCOMPLETE", errors, warnings }; an RCS agent's copy-rule error carries the carrier partner's key
359
+ * as its `code` (for example OPT_IN_MSG_RATE_DISCL_MISSING). An RCS agent whose group has not finished account
360
+ * verification gets a 403 with code GROUP_UNVERIFIED, and one whose group is rejected a 403 with code GROUP_REJECTED.
301
361
  * An RCS agent's launch request charges its launch fees: a wallet that cannot cover them gets a 402, and nothing changes. When any fee is due the request must set acknowledgeFees: true, or it gets a 400 with code FEE_ACKNOWLEDGEMENT_REQUIRED and nothing is held; a launch with nothing due needs no acknowledgement.
302
362
  * When the agent's brand vertical is healthcare or insurance, the launch needs the protected health information (PHI) disclosure acknowledged: send acknowledgePhi: true, or the request gets a 400 REGISTRATION_INCOMPLETE whose errors name consent.phiAcknowledgement. The API records the acknowledgement as consent.phiAcknowledgement { acknowledgedAt, acknowledgedBy } from the caller; the client sends only the boolean, and an agent update cannot set it. Once recorded, a later launch request needs no new acknowledgement.
303
363
  * @async
@@ -11,12 +11,20 @@
11
11
  */
12
12
 
13
13
  /**
14
+ * A declared placeholder. Placeholders go in text, card titles and descriptions, button labels and fallback text. A url
15
+ * variable may fill a whole link or media URL, and any variable may fill a URL's path, query or fragment, percent-encoded. A
16
+ * dial number takes one phoneNumber variable and a calendar time one dateTime variable, each for the whole field. A calendar
17
+ * title and description and postbackData take text. A location's address and label take none. The send checks each filled
18
+ * field and blocks a recipient whose field fails with CONTENT_INVALID.
14
19
  * @typedef {Object} RcsVariable
15
20
  * @property {string} key - Placeholder key used as {{key}} (/^[a-z][a-z0-9_]{0,63}$/)
16
21
  * @property {string} [label] - Display label
17
22
  * @property {"text"|"number"|"dateTime"|"phoneNumber"|"url"} type - Value type
18
- * @property {boolean} required - Whether a send must supply a value
19
- * @property {string} [default] - Value used when none is supplied
23
+ * @property {boolean} required - Without missingPolicy: whether a recipient with no value and no default is blocked
24
+ * @property {"default"|"block"|"drop"} [missingPolicy] - What a recipient with no value gets: the default (empty when none),
25
+ * a VARIABLE_MISSING block, or the send without each block that uses the variable. Omitted keeps the older rule: the
26
+ * default, else VARIABLE_MISSING when required, else empty. An empty value, or one of only spaces, counts as no value
27
+ * @property {string} [default] - Value used when none is supplied, by the default policy or with no policy
20
28
  * @property {string} [sample] - Example value for previews
21
29
  */
22
30
 
@@ -117,6 +125,8 @@
117
125
  * @property {"image"|"video"|"audio"|"file"} kind - Media kind
118
126
  * @property {number|null} width - Pixel width, when known
119
127
  * @property {number|null} height - Pixel height, when known
128
+ * @property {{ mms?: { url: string, bytes: number } }} variants - An image over the MMS size limit has an MMS copy, which an
129
+ * MMS fallback leg sends; {} otherwise
120
130
  * @property {string} createdAt - ISO timestamp
121
131
  */
122
132
 
@@ -138,7 +148,8 @@
138
148
  * @property {Object<string, string[]>} trafficByUseCase - The traffic types each agent use case may send
139
149
  * @property {Object<string, string>} defaultTrafficByUseCase - The traffic type a single-purpose agent sends when a request names none
140
150
  * @property {{ cardButtonsInline: number, suggestedActionsInline: number, linesPerField: number, charsPerLine: number }} ios - How an iPhone lays out RCS content
141
- * @property {{ maxUploadBytes: number, mimeTypes: string[] }} media - Upload constraints
151
+ * @property {{ maxUploadBytes: number, mimeTypes: string[], maxImageEdge: number, imageTargetBytes: number }} media - Upload
152
+ * constraints; an image over maxImageEdge or imageTargetBytes is compressed to both
142
153
  * @property {{ available: boolean }} geocoding - Whether this server resolves VIEW_LOCATION addresses (geocodeAddress answers 503 when false)
143
154
  * @property {{ provider: "infobip"|"sinch", adapterVersion: string, limits: Object<string, number>, unsupported: Array<{ feature: string, code: string, message: string }> }|null} provider - Provider-specific limits when a provider was requested
144
155
  */
@@ -308,7 +319,7 @@ export class Templates {
308
319
 
309
320
  /**
310
321
  * Publish a template's current draft; no draft returns 409 NO_DRAFT, a draft changed mid-publish returns 409 DRAFT_CHANGED (publish again) and an incomplete draft returns 400 TEMPLATE_INVALID
311
- * A block whose text or image the Moderation API flags is an error with code CONTENT_POLICY_FLAGGED, whose message names the category ("Content moderation flagged this text: spam"). The check passes when the Moderation API fails.
322
+ * A block whose text or image the Moderation API flags is an error with code CONTENT_POLICY_FLAGGED, whose message names the category ("Content moderation flagged this text: spam"). The check passes when the Moderation API fails. An image URL with a variable is moderated at send instead, with its value filled in, and a refused image blocks the recipient with MODERATION.
312
323
  * @async
313
324
  * @roles api, admin, developer
314
325
  * @param {Object} params - The parameters for publishing a template
@@ -368,7 +379,7 @@ export class Templates {
368
379
 
369
380
  /**
370
381
  * Validate an unsaved body or a stored version without writing anything
371
- * Validate runs the publish checks, the content policy check included: a block whose text or image the Moderation API flags is an error with code CONTENT_POLICY_FLAGGED. Saving a draft does not run that check.
382
+ * Validate runs the publish checks, the content policy check included: a block whose text or image the Moderation API flags is an error with code CONTENT_POLICY_FLAGGED. An image URL with a variable is moderated at send instead, with its value filled in, and a refused image blocks the recipient with MODERATION. Saving a draft does not run that check.
372
383
  * @async
373
384
  * @roles api, admin, developer, billing, user
374
385
  * @param {Object} params - The parameters for validation; pass exactly one of body or version
@@ -424,7 +435,9 @@ export class Templates {
424
435
  }
425
436
 
426
437
  /**
427
- * Upload a media file for use in template bodies; returns its public URL. 503 when media storage is not configured
438
+ * Upload a media file for use in template bodies; returns its public URL. An image over 1920 px on its longest edge or over
439
+ * 5,000,000 bytes is compressed to both, and one over the MMS size limit also gets an MMS copy in variants.mms. 503 when
440
+ * media storage is not configured
428
441
  * @async
429
442
  * @roles api, admin, developer
430
443
  * @param {Object} params - The parameters for the upload