@signalhousellc/sdk 1.0.69 → 1.2.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 +1 -1
- package/src/SignalHouseSDK.js +2 -0
- package/src/domains/Agents.js +131 -0
- package/src/domains/Auth.js +6 -2
- package/src/domains/Brands.js +56 -3
- package/src/domains/Messages.js +71 -31
- package/src/domains/Numbers.js +3 -2
- package/src/domains/Registrations.js +247 -0
- package/src/domains/Shortlinks.js +30 -0
package/package.json
CHANGED
package/src/SignalHouseSDK.js
CHANGED
|
@@ -28,6 +28,7 @@ import { Groups } from "./domains/Groups.js";
|
|
|
28
28
|
import { Landings } from "./domains/Landings.js";
|
|
29
29
|
import { Messages } from "./domains/Messages.js";
|
|
30
30
|
import { Numbers } from "./domains/Numbers.js";
|
|
31
|
+
import { Registrations } from "./domains/Registrations.js";
|
|
31
32
|
import { Onboarding } from "./domains/Onboarding.js";
|
|
32
33
|
import { Dnc } from "./domains/Dnc.js";
|
|
33
34
|
import { Shortlinks } from "./domains/Shortlinks.js";
|
|
@@ -73,6 +74,7 @@ export class SignalHouseSDK {
|
|
|
73
74
|
this.landings = new Landings(client, multipartClient, this.enableAdmin);
|
|
74
75
|
this.messages = new Messages(client, multipartClient, this.enableAdmin);
|
|
75
76
|
this.numbers = new Numbers(client, multipartClient, this.enableAdmin);
|
|
77
|
+
this.registrations = new Registrations(client, this.enableAdmin);
|
|
76
78
|
this.onboarding = new Onboarding(client, this.enableAdmin);
|
|
77
79
|
this.dnc = new Dnc(client, this.enableAdmin);
|
|
78
80
|
this.shortlinks = new Shortlinks(client, this.enableAdmin);
|
package/src/domains/Agents.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
14
14
|
* @property {string} [greeting] - Opening line the agent leads with.
|
|
15
15
|
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
16
|
+
* @property {string} [sendAuthority] - Default send authority: "review" or "autopilot" (defaults to "review"). Deployments may override it per subgroup.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -22,6 +23,48 @@
|
|
|
22
23
|
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
23
24
|
* @property {string} [greeting] - Opening line the agent leads with.
|
|
24
25
|
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
26
|
+
* @property {string} [sendAuthority] - Default send authority: "review" or "autopilot". Deployments may override it per subgroup.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An agent profile as returned by the server. `publishStatus` and `publishedAt` are read-only:
|
|
31
|
+
* they change only through `publishAgentProfile` and `unpublishAgentProfile`.
|
|
32
|
+
* @typedef {Object} AgentProfile
|
|
33
|
+
* @property {string} agentProfileId - The agent profile id.
|
|
34
|
+
* @property {string} groupId - The owning group id.
|
|
35
|
+
* @property {string|null} subgroupId - The owning subgroup id; null for a group-level agent.
|
|
36
|
+
* @property {string} name - The agent's name.
|
|
37
|
+
* @property {string} status - Lifecycle status: "active" or "inactive".
|
|
38
|
+
* @property {string} [systemPrompt] - Base system prompt composed into every conversation.
|
|
39
|
+
* @property {string} [greeting] - Opening line the agent leads with.
|
|
40
|
+
* @property {string} [guardrails] - Freeform guardrail instructions appended to the composed prompt.
|
|
41
|
+
* @property {string} sendAuthority - Default send authority: "review" or "autopilot".
|
|
42
|
+
* @property {string} publishStatus - "draft" or "published" (read-only).
|
|
43
|
+
* @property {string|null} publishedAt - When the profile was last published; null while never published (read-only).
|
|
44
|
+
* @property {string} createdAt - Creation timestamp.
|
|
45
|
+
* @property {string} updatedAt - Last-update timestamp.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The fields of a deployment of a group-level agent to a subgroup.
|
|
50
|
+
* @typedef {Object} AgentDeploymentData
|
|
51
|
+
* @property {string|null} [sendAuthorityOverride] - "review" or "autopilot" to override the profile's default for this subgroup; null clears the override so the deployment inherits the profile default.
|
|
52
|
+
* @property {boolean} [enabled] - Whether this deployment is live (defaults to true).
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A deployment of a group-level agent to a subgroup, as returned by the server.
|
|
57
|
+
* @typedef {Object} AgentDeployment
|
|
58
|
+
* @property {string} agentDeploymentId - The deployment id.
|
|
59
|
+
* @property {string} groupId - The group that owns the agent and the subgroup.
|
|
60
|
+
* @property {string} subgroupId - The subgroup the agent is deployed to.
|
|
61
|
+
* @property {string} agentProfileId - The deployed agent.
|
|
62
|
+
* @property {string|null} sendAuthorityOverride - "review", "autopilot", or null (inherit the profile default).
|
|
63
|
+
* @property {string|null} sendAuthorityChangedBy - userId of whoever last changed the override.
|
|
64
|
+
* @property {string|null} sendAuthorityChangedAt - When the override last changed.
|
|
65
|
+
* @property {boolean} enabled - Whether this deployment is live.
|
|
66
|
+
* @property {string} createdAt - Creation timestamp.
|
|
67
|
+
* @property {string} updatedAt - Last-update timestamp.
|
|
25
68
|
*/
|
|
26
69
|
|
|
27
70
|
/**
|
|
@@ -361,6 +404,94 @@ export class Agents {
|
|
|
361
404
|
return this.client(`/agent/profiles/${safeId}/channels/${safeChannel}`, { method: "DELETE", ...options });
|
|
362
405
|
}
|
|
363
406
|
|
|
407
|
+
/**
|
|
408
|
+
* List a group-level agent's deployments to subgroups.
|
|
409
|
+
* @async
|
|
410
|
+
* @roles api, admin, developer, billing, user
|
|
411
|
+
* @param {Object} params - The parameters for listing deployments.
|
|
412
|
+
* @param {string} params.agentProfileId - The agent whose deployments to list.
|
|
413
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
414
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
415
|
+
* @returns {Promise<SdkResponse<AgentDeployment[]>>} - The agent's deployments returned from the server.
|
|
416
|
+
*/
|
|
417
|
+
async getAgentDeployments({ agentProfileId, options = {} }) {
|
|
418
|
+
this.client._require({ agentProfileId });
|
|
419
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
420
|
+
return this.client(`/agent/profiles/${safeId}/deployments`, { method: "GET", ...options });
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Deploy a group-level agent to a subgroup, or change that deployment (upsert). One row per
|
|
425
|
+
* (agent, subgroup); the subgroup is taken from the path, the fields from deploymentData.
|
|
426
|
+
* @async
|
|
427
|
+
* @roles api, admin, developer
|
|
428
|
+
* @param {Object} params - The parameters for the upsert.
|
|
429
|
+
* @param {string} params.agentProfileId - The agent to deploy.
|
|
430
|
+
* @param {string} params.subgroupId - The subgroup to deploy to (at least 8 characters, starts with 'S').
|
|
431
|
+
* @param {AgentDeploymentData} [params.deploymentData] - The fields to set.
|
|
432
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
433
|
+
* @throws {Error} Throws an error if agentProfileId or subgroupId is missing.
|
|
434
|
+
* @returns {Promise<SdkResponse<AgentDeployment>>} - The created or updated deployment returned from the server.
|
|
435
|
+
*/
|
|
436
|
+
async upsertAgentDeployment({ agentProfileId, subgroupId, deploymentData = {}, options = {} }) {
|
|
437
|
+
this.client._require({ agentProfileId, subgroupId });
|
|
438
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
439
|
+
const safeSubgroupId = encodeURIComponent(subgroupId);
|
|
440
|
+
return this.client(`/agent/profiles/${safeId}/deployments/${safeSubgroupId}`, { method: "PUT", body: deploymentData, ...options });
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Remove an agent's deployment from a subgroup.
|
|
445
|
+
* @async
|
|
446
|
+
* @roles api, admin, developer
|
|
447
|
+
* @param {Object} params - The parameters for the delete.
|
|
448
|
+
* @param {string} params.agentProfileId - The deployed agent.
|
|
449
|
+
* @param {string} params.subgroupId - The subgroup to remove the deployment from.
|
|
450
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
451
|
+
* @throws {Error} Throws an error if agentProfileId or subgroupId is missing.
|
|
452
|
+
* @returns {Promise<SdkResponse<AgentDeployment>>} - The removed deployment returned from the server.
|
|
453
|
+
*/
|
|
454
|
+
async deleteAgentDeployment({ agentProfileId, subgroupId, options = {} }) {
|
|
455
|
+
this.client._require({ agentProfileId, subgroupId });
|
|
456
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
457
|
+
const safeSubgroupId = encodeURIComponent(subgroupId);
|
|
458
|
+
return this.client(`/agent/profiles/${safeId}/deployments/${safeSubgroupId}`, { method: "DELETE", ...options });
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Publish an agent profile, setting its `publishStatus` to "published" and stamping
|
|
463
|
+
* `publishedAt`. The server rejects the call with 400 when the agent has no enabled
|
|
464
|
+
* deployment, and with 409 when the agent is inactive.
|
|
465
|
+
* @async
|
|
466
|
+
* @roles api, admin, developer
|
|
467
|
+
* @param {Object} params - The parameters for publishing.
|
|
468
|
+
* @param {string} params.agentProfileId - The agent profile to publish.
|
|
469
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
470
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
471
|
+
* @returns {Promise<SdkResponse<AgentProfile>>} - The published agent profile returned from the server.
|
|
472
|
+
*/
|
|
473
|
+
async publishAgentProfile({ agentProfileId, options = {} }) {
|
|
474
|
+
this.client._require({ agentProfileId });
|
|
475
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
476
|
+
return this.client(`/agent/profiles/${safeId}/publish`, { method: "POST", ...options });
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Return an agent profile to draft, setting its `publishStatus` to "draft".
|
|
481
|
+
* @async
|
|
482
|
+
* @roles api, admin, developer
|
|
483
|
+
* @param {Object} params - The parameters for unpublishing.
|
|
484
|
+
* @param {string} params.agentProfileId - The agent profile to unpublish.
|
|
485
|
+
* @param {RequestOptions} [params.options] - Additional options for the request.
|
|
486
|
+
* @throws {Error} Throws an error if the agentProfileId parameter is missing.
|
|
487
|
+
* @returns {Promise<SdkResponse<AgentProfile>>} - The unpublished agent profile returned from the server.
|
|
488
|
+
*/
|
|
489
|
+
async unpublishAgentProfile({ agentProfileId, options = {} }) {
|
|
490
|
+
this.client._require({ agentProfileId });
|
|
491
|
+
const safeId = encodeURIComponent(agentProfileId);
|
|
492
|
+
return this.client(`/agent/profiles/${safeId}/unpublish`, { method: "POST", ...options });
|
|
493
|
+
}
|
|
494
|
+
|
|
364
495
|
/**
|
|
365
496
|
* Read the tenant AI settings for a scope (group, or a subgroup within it) — brand, tone,
|
|
366
497
|
* timezone, business hours, and after-hours message. Returns the scope's own row only (no
|
package/src/domains/Auth.js
CHANGED
|
@@ -63,13 +63,17 @@ export class Auth {
|
|
|
63
63
|
* @param {boolean} [params.acceptedTermsOfService] - Whether the user accepted the Terms of Service
|
|
64
64
|
* @param {string} [params.psXid] - PartnerStack click id (ps_xid) captured from a referral link
|
|
65
65
|
* @param {string} [params.psPartnerKey] - PartnerStack partner key (ps_partner_key) captured from a referral link
|
|
66
|
+
* @param {Object} [params.attribution] - Marketing attribution captured at signup
|
|
67
|
+
* @param {string} [params.attribution.posthogDistinctId] - PostHog distinct id of the registering visitor
|
|
68
|
+
* @param {Object} [params.attribution.firstTouch] - First-ever visit: utmSource, utmMedium, utmCampaign, utmTerm, utmContent, gclid, fbclid, referrer, landingUrl
|
|
69
|
+
* @param {Object} [params.attribution.lastTouch] - Visit that registered, same keys as firstTouch
|
|
66
70
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
67
71
|
* @returns {Promise<SdkResponse<any>>} The response from the server (contains the JWT token)
|
|
68
72
|
*/
|
|
69
|
-
async register({ businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, options = {} }) {
|
|
73
|
+
async register({ businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, attribution, options = {} }) {
|
|
70
74
|
return this.client(`/auth/register`, {
|
|
71
75
|
method: "POST",
|
|
72
|
-
body: { businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey },
|
|
76
|
+
body: { businessName, fullName, email, password, phone, dialCode, country, volume, products, acceptedTermsOfService, psXid, psPartnerKey, attribution },
|
|
73
77
|
...options,
|
|
74
78
|
});
|
|
75
79
|
}
|
package/src/domains/Brands.js
CHANGED
|
@@ -140,11 +140,64 @@ export class Brands {
|
|
|
140
140
|
* @param {number} [params.limit] - The number of items per page
|
|
141
141
|
* @param {string} [params.status] - The status of the brand to filter by (PENDING_CREATION, PENDING_APPROVAL, UNVERIFIED, VERIFIED, VETTED_VERIFIED, PENDING_DELETE, DELETED)
|
|
142
142
|
* @param {string} [params.registrationType] - Filter by registration type ("TEN_DLC", "TOLL_FREE", or "SHORT_CODE")
|
|
143
|
+
* @param {string} [params.search] - Staff-only (no id/subgroupId/groupId): case-insensitive substring over brandId, names, EIN, email, group, subgroup and reference ID
|
|
144
|
+
* @param {string} [params.sortBy] - Staff-only: createdAt, brandId, displayName, groupId, subgroupId, status, entityType or country
|
|
145
|
+
* @param {"asc"|"desc"} [params.sortOrder] - Staff-only: sort direction (default asc)
|
|
146
|
+
* @param {string} [params.entityType] - Staff-only: exact entity type filter
|
|
147
|
+
* @param {string} [params.ein] - Staff-only: EIN substring filter
|
|
148
|
+
* @param {string} [params.email] - Staff-only: support email substring filter
|
|
149
|
+
* @param {string} [params.referenceId] - Staff-only: reference ID substring filter
|
|
150
|
+
* @param {string|Array<string>} [params.groupIds] - Staff-only: restrict to these group IDs (sent comma-separated)
|
|
151
|
+
* @param {string} [params.createdFrom] - Staff-only: inclusive createdAt lower bound (ISO date)
|
|
152
|
+
* @param {string} [params.createdTo] - Staff-only: inclusive createdAt upper bound (ISO date)
|
|
153
|
+
* @param {boolean} [params.excludeDeleted] - Staff-only: hide DELETED brands when no status is given
|
|
154
|
+
* @param {boolean} [params.includeTotal] - Staff-only: with page and limit, return `{ data, total, page, limit, totalPages }` instead of the array
|
|
143
155
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
144
|
-
* @returns {Promise<SdkResponse<Array<{ _id: string, brandId: string|null, status: string, registrationType: string, [key: string]: any }
|
|
156
|
+
* @returns {Promise<SdkResponse<Array<{ _id: string, brandId: string|null, status: string, registrationType: string, [key: string]: any }>|{ data: Array<Object>, total: number, page: number, limit: number, totalPages: number }>>} Brand records. For 10DLC brands in PENDING_CREATION (or rejected before carrier assignment), brandId is null — poll by _id until status advances and brandId is assigned. The staff-only list (no id/subgroupId/groupId) returns the `{ data, total, page, limit, totalPages }` envelope only when includeTotal is sent with page and limit.
|
|
145
157
|
*/
|
|
146
|
-
async getBrands({
|
|
147
|
-
|
|
158
|
+
async getBrands({
|
|
159
|
+
id,
|
|
160
|
+
subgroupId,
|
|
161
|
+
groupId,
|
|
162
|
+
page,
|
|
163
|
+
limit,
|
|
164
|
+
status,
|
|
165
|
+
registrationType,
|
|
166
|
+
search,
|
|
167
|
+
sortBy,
|
|
168
|
+
sortOrder,
|
|
169
|
+
entityType,
|
|
170
|
+
ein,
|
|
171
|
+
email,
|
|
172
|
+
referenceId,
|
|
173
|
+
groupIds,
|
|
174
|
+
createdFrom,
|
|
175
|
+
createdTo,
|
|
176
|
+
excludeDeleted,
|
|
177
|
+
includeTotal,
|
|
178
|
+
options = {},
|
|
179
|
+
}) {
|
|
180
|
+
const filters = {
|
|
181
|
+
id,
|
|
182
|
+
subgroupId,
|
|
183
|
+
groupId,
|
|
184
|
+
page,
|
|
185
|
+
limit,
|
|
186
|
+
status,
|
|
187
|
+
registrationType,
|
|
188
|
+
search,
|
|
189
|
+
sortBy,
|
|
190
|
+
sortOrder,
|
|
191
|
+
entityType,
|
|
192
|
+
ein,
|
|
193
|
+
email,
|
|
194
|
+
referenceId,
|
|
195
|
+
groupIds: Array.isArray(groupIds) ? (groupIds.length ? groupIds.join(',') : undefined) : groupIds,
|
|
196
|
+
createdFrom,
|
|
197
|
+
createdTo,
|
|
198
|
+
excludeDeleted,
|
|
199
|
+
includeTotal,
|
|
200
|
+
};
|
|
148
201
|
const queryString = this.client._getQueryString(filters);
|
|
149
202
|
return this.client(`/brand${queryString}`, { method: 'GET', ...options });
|
|
150
203
|
}
|
package/src/domains/Messages.js
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Serialise regionScopes for the query string: an array of branches becomes JSON, a string is passed through.
|
|
9
|
+
* @param {Object} filters - Query filters that may carry regionScopes
|
|
10
|
+
* @returns {Object} - The filters with regionScopes JSON-encoded when present
|
|
11
|
+
*/
|
|
12
|
+
function withRegionScopes(filters) {
|
|
13
|
+
if (filters.regionScopes === undefined) return filters;
|
|
14
|
+
const regionScopes = typeof filters.regionScopes === "string" ? filters.regionScopes : JSON.stringify(filters.regionScopes);
|
|
15
|
+
return { ...filters, regionScopes };
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export class Messages {
|
|
8
19
|
constructor(client, multipartClient, enableAdmin) {
|
|
9
20
|
this.client = client;
|
|
@@ -12,10 +23,13 @@ export class Messages {
|
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
/**
|
|
15
|
-
* Estimate
|
|
16
|
-
* recipients, and is unavailable unless Canada is enabled for the environment.
|
|
26
|
+
* Estimate regional SMS/MMS retail cost; no charge or send. A Canadian sender requires a Ready Canadian sender and
|
|
27
|
+
* Canadian or US recipients, and is unavailable unless Canada is enabled for the environment. A +44 (UK) sender
|
|
28
|
+
* estimates SMS to GB mobiles only and returns region "GB"; while UK sending is disabled for the environment a UK
|
|
29
|
+
* sender is refused with a 400. The sender may also be a READY alphanumeric sender ID (e.g. "ACME"; UK recipients,
|
|
30
|
+
* SMS only); its estimate counts the "\nOpt out: sihou.io/o/{code}" footer the server appends to every such message.
|
|
17
31
|
* @async
|
|
18
|
-
* @param {Object} params - Sender, up to 100 recipients, messageBody and request options.
|
|
32
|
+
* @param {Object} params - Sender, up to 100 recipients (10-15 digits each), messageBody and request options.
|
|
19
33
|
* @returns {Promise<SdkResponse<any>>} - Per-recipient rates and total in microdollars; unknown carriers use the upper fallback.
|
|
20
34
|
*/
|
|
21
35
|
async estimateMessage({ senderPhoneNumber, recipientPhoneNumbers, messageBody, messageType = "SMS", options = {} }) {
|
|
@@ -32,17 +46,20 @@ export class Messages {
|
|
|
32
46
|
* @param {string} [params.brandId] - Filter messages by the ID of the associated brand
|
|
33
47
|
* @param {string} [params.subgroupId] - Filter messages by the ID of the associated subgroup
|
|
34
48
|
* @param {string} [params.groupId] - Filter messages by the ID of the associated group
|
|
49
|
+
* @param {string|string[]} [params.registrationId] - Filter to messages attributed to these registrations. Cannot be combined with campaignId; each id must belong to the group. Accepts a single value or an array.
|
|
35
50
|
* @param {string} [params.status] - Filter messages by their status (ENQUEUED, DEQUEUED, SENT, FAILED, DELIVERED)
|
|
36
51
|
* @param {string} [params.direction] - Filter messages by their direction (INBOUND, OUTBOUND)
|
|
37
52
|
* @param {string|string[]} [params.messageType] - Filter messages by their type. Accepts a single value or an array (e.g. ["SMS", "MMS"]). Allowed values: SMS, MMS, RCS, WHATSAPP, VIBER, P2P. When omitted, defaults to all non-P2P types.
|
|
38
53
|
* @param {string|string[]} [params.channel] - Filter messages by channel. Accepts a single value or an array. Allowed values: tenDLC, virtualLongCode, tollFree, shortCode, p2p. Each message records its channel when it is saved, and this filters on that stored value; older messages from before this feature have no channel and count as tenDLC. Ignored when matchAny is true (matchAny takes precedence).
|
|
54
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Accepted whether or not the environment serves hourly analytics.
|
|
55
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Accepted whether or not the environment serves hourly analytics.
|
|
39
56
|
* @param {boolean} [params.matchAny] - When true, the provided campaignId/brandId/phoneNumber filters are OR'd (a message matches ANY of them) instead of the default most-specific-single behavior. subgroupId stays an AND scope. Opt-in/additive.
|
|
40
57
|
* @param {string} [params.carrier] - Filter messages by the carrier used for sending
|
|
41
58
|
* @param {string|string[]} [params.sentimentLabel] - Filter messages by sentiment bucket. Accepts a single value or an array (e.g. ["positive", "negative"]). Allowed values: positive, neutral, negative. Applied as the sentimentScore range the ±25 label threshold produces, so unscored messages match no bucket and outbound messages (never scored) are excluded.
|
|
42
59
|
* @param {string|string[]} [params.errorCode] - Filter FAILED messages by Signal House error code (single value or array). "OUT" is the campaign opt-out, displayed as RECIPIENT_OPTED_OUT. Carrier codes are not filterable here; they live inside successOrFailureReason.
|
|
43
60
|
* @param {string|string[]} [params.phoneNumber] - Filter messages by a business number on either side of the message. Accepts a single value or an array; OR'd with campaignId/brandId when matchAny is true
|
|
44
|
-
* @param {string} [params.senderPhoneNumber] - Filter messages by the sender's 5-6 digit Short Code or 10+ digit phone number
|
|
45
|
-
* @param {string} [params.recipientPhoneNumber] - Filter messages by the recipient's phone number
|
|
61
|
+
* @param {string} [params.senderPhoneNumber] - Filter messages by the sender's 5-6 digit Short Code or 10+ digit phone number. Use % as a wildcard for a partial match (e.g. "%1234" matches numbers ending in 1234); a plain value is an exact match. 3-15 digits required alongside any %.
|
|
62
|
+
* @param {string} [params.recipientPhoneNumber] - Filter messages by the recipient's phone number. Use % as a wildcard for a partial match (e.g. "%1234" matches numbers ending in 1234); a plain value is an exact match. 3-15 digits required alongside any %.
|
|
46
63
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode
|
|
47
64
|
* @param {string} [params.endDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back
|
|
48
65
|
* @param {string} [params.sortField] - The field to sort the messages by (createdAt, segmentCount, status, sentimentScore)
|
|
@@ -61,6 +78,7 @@ export class Messages {
|
|
|
61
78
|
brandId,
|
|
62
79
|
subgroupId,
|
|
63
80
|
groupId,
|
|
81
|
+
registrationId,
|
|
64
82
|
phoneNumber,
|
|
65
83
|
senderPhoneNumber,
|
|
66
84
|
recipientPhoneNumber,
|
|
@@ -68,6 +86,8 @@ export class Messages {
|
|
|
68
86
|
direction,
|
|
69
87
|
messageType,
|
|
70
88
|
channel,
|
|
89
|
+
region,
|
|
90
|
+
regionScopes,
|
|
71
91
|
matchAny,
|
|
72
92
|
carrier,
|
|
73
93
|
sentimentLabel,
|
|
@@ -81,8 +101,8 @@ export class Messages {
|
|
|
81
101
|
dateBounds,
|
|
82
102
|
options = {},
|
|
83
103
|
}) {
|
|
84
|
-
const filters = { id, campaignId, brandId, subgroupId, groupId, phoneNumber, senderPhoneNumber, recipientPhoneNumber, status, direction, messageType, channel, matchAny, carrier, sentimentLabel, errorCode, startDate, endDate, sortField, sortOrder, page, limit, dateBounds };
|
|
85
|
-
const queryString = this.client._getQueryString(filters);
|
|
104
|
+
const filters = { id, campaignId, brandId, subgroupId, groupId, registrationId, phoneNumber, senderPhoneNumber, recipientPhoneNumber, status, direction, messageType, channel, region, regionScopes, matchAny, carrier, sentimentLabel, errorCode, startDate, endDate, sortField, sortOrder, page, limit, dateBounds };
|
|
105
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
86
106
|
return this.client(`/message${queryString}`, { method: "GET", ...options });
|
|
87
107
|
}
|
|
88
108
|
|
|
@@ -115,6 +135,7 @@ export class Messages {
|
|
|
115
135
|
* @param {string|string[]} [params.subgroupId] - Filter analytics by the ID of the associated subgroup. Accepts a single value, an array, or a comma-separated string.
|
|
116
136
|
* @param {string|string[]} [params.brandId] - Filter analytics by the ID of the associated brand. Accepts a single value, an array, or a comma-separated string.
|
|
117
137
|
* @param {string|string[]} [params.campaignId] - Filter analytics by the ID of the associated campaign. Accepts a single value, an array, or a comma-separated string.
|
|
138
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
118
139
|
* @param {string|string[]} [params.phoneNumber] - Filter analytics by the phone number involved in the messages. Accepts a single value, an array, or a comma-separated string.
|
|
119
140
|
* @param {string|string[]} [params.carrier] - Filter analytics by the carrier used for sending. Accepts a single value, an array, or a comma-separated string.
|
|
120
141
|
* @param {string|string[]} [params.carrierFamily] - Filter analytics by the recipient's resolved carrier family (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless). Accepts a single value, an array, or a comma-separated string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -123,6 +144,8 @@ export class Messages {
|
|
|
123
144
|
* @param {boolean} [params.matchAny] - When true, the provided campaignId/brandId/phoneNumber filters are OR'd (match ANY) instead of the default most-specific-single behavior. subgroupId stays an AND scope. Opt-in/additive.
|
|
124
145
|
* @param {(string|string[])} [params.messageType] - Message type(s) the SENTIMENT figures are scoped to: SMS, MMS or P2P (single value, array, or comma-separated string). Omit for all scored types. Does NOT narrow the message counts, which are always returned split per type (smsInbound/mmsInbound/p2pInbound) and have no filterable type dimension.
|
|
125
146
|
* @param {string|string[]} [params.channel] - Filter analytics by channel (tenDLC, virtualLongCode, tollFree, shortCode, p2p). Filters on the stored channel column; a tenDLC selection also includes older messages that have no channel, and p2p is a real channel here (matched by carrier). Accepts a single value or an array. Ignored when matchAny is true (matchAny takes precedence).
|
|
147
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
148
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
126
149
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
127
150
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
128
151
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the analytics data. Also includes inbound-message
|
|
@@ -134,9 +157,9 @@ export class Messages {
|
|
|
134
157
|
* summed or re-averaged across types, rows or responses. To weight a subset of message types, pass
|
|
135
158
|
* messageType and read sentimentScore.
|
|
136
159
|
*/
|
|
137
|
-
async getAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, matchAny, dateBounds, options = {} }) {
|
|
138
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, matchAny, dateBounds };
|
|
139
|
-
const queryString = this.client._getQueryString(filters);
|
|
160
|
+
async getAnalytics({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, matchAny, dateBounds, options = {} }) {
|
|
161
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, matchAny, dateBounds };
|
|
162
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
140
163
|
return this.client(`/message/analytics${queryString}`, { method: "GET", ...options });
|
|
141
164
|
}
|
|
142
165
|
|
|
@@ -149,6 +172,7 @@ export class Messages {
|
|
|
149
172
|
* @param {string|string[]} [params.subgroupId] - Filter analytics by the ID of the associated subgroup. Accepts a single value, an array, or a comma-separated string.
|
|
150
173
|
* @param {string|string[]} [params.brandId] - Filter analytics by the ID of the associated brand. Accepts a single value, an array, or a comma-separated string.
|
|
151
174
|
* @param {string|string[]} [params.campaignId] - Filter analytics by the ID of the associated campaign. Accepts a single value, an array, or a comma-separated string.
|
|
175
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
152
176
|
* @param {string|string[]} [params.phoneNumber] - Filter analytics by the phone number involved in the messages. Accepts a single value, an array, or a comma-separated string.
|
|
153
177
|
* @param {string|string[]} [params.carrier] - Filter analytics by the carrier used for sending. Accepts a single value, an array, or a comma-separated string.
|
|
154
178
|
* @param {string|string[]} [params.carrierFamily] - Filter analytics by the recipient's resolved carrier family (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless). Accepts a single value, an array, or a comma-separated string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -156,6 +180,8 @@ export class Messages {
|
|
|
156
180
|
* @param {string} [params.endDate] - ISO-8601 date or timestamp. At day granularity it is bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back; at hour granularity it is honoured as given.
|
|
157
181
|
* @param {(string|string[])} [params.messageType] - Message type(s) the SENTIMENT figures are scoped to: SMS, MMS or P2P (single value, array, or comma-separated string). Omit for all scored types. Does NOT narrow the message counts, which are always returned split per type (smsInbound/mmsInbound/p2pInbound) and have no filterable type dimension.
|
|
158
182
|
* @param {string|string[]} [params.channel] - Filter analytics by channel (tenDLC, virtualLongCode, tollFree, shortCode, p2p). Filters on the stored channel column; a tenDLC selection also includes older messages that have no channel, and p2p is a real channel here. Accepts a single value or an array.
|
|
183
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
184
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
159
185
|
* @param {("day"|"hour")} [params.granularity] - Time-bucket grain of the byDate rows. Omit for day (each row's _id is a "YYYY-MM-DD" date). "hour" buckets by hour (each row's _id is a "YYYY-MM-DD HH:MM:SS" UTC hour) and is capped to a 7-day span. Only accepted where the environment serves hourly analytics; elsewhere any value, including "day", is rejected with a 400 -- omit the parameter unless hour grain is wanted.
|
|
160
186
|
* @param {("carrier"|"carrierFamily")} [params.breakdown] - Adds a byBreakdown time × dimension series to the response ({ dimension, rows }: each row is one byDate bucket (_id) for one carrier or carrier family (key), over the top 50 keys by volume, 10DLC only) and caps the span at 31 days. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
161
187
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
@@ -168,9 +194,9 @@ export class Messages {
|
|
|
168
194
|
* score is divided server-side and the raw sums are never returned: a score is an average and must never be
|
|
169
195
|
* summed or re-averaged across types, rows or responses.
|
|
170
196
|
*/
|
|
171
|
-
async getAnalyticsDetail({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, granularity, breakdown, dateBounds, options = {} }) {
|
|
172
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, messageType, granularity, breakdown, dateBounds };
|
|
173
|
-
const queryString = this.client._getQueryString(filters);
|
|
197
|
+
async getAnalyticsDetail({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, granularity, breakdown, dateBounds, options = {} }) {
|
|
198
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, channel, region, regionScopes, messageType, granularity, breakdown, dateBounds };
|
|
199
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
174
200
|
return this.client(`/message/analytics/detail${queryString}`, { method: "GET", ...options });
|
|
175
201
|
}
|
|
176
202
|
|
|
@@ -186,6 +212,7 @@ export class Messages {
|
|
|
186
212
|
* @param {string} params.groupId - The group to scope the read to (required)
|
|
187
213
|
* @param {string|string[]} [params.brandId] - Brand scope. Accepts a single value, an array, or a comma-separated string.
|
|
188
214
|
* @param {string|string[]} [params.campaignId] - Campaign scope; wins over brandId. Accepts a single value, an array, or a comma-separated string.
|
|
215
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). Accepts a single value or an array.
|
|
189
216
|
* @param {string|string[]} [params.carrierFamily] - Carrier-family filter (ATT, TMobile, Verizon, USCellular, ...). Accepts a single value, an array, or a comma-separated string.
|
|
190
217
|
* @param {string} params.startDate - ISO-8601 date or timestamp. It is bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode, then floored to the start of its hour at hour granularity and of its minute at day granularity (the cube is keyed by minute).
|
|
191
218
|
* @param {string} params.endDate - ISO-8601 date or timestamp. At hour granularity it is honoured as given; at day granularity it is bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back. The span is capped at 35 days (the retention of the per-minute data).
|
|
@@ -195,8 +222,8 @@ export class Messages {
|
|
|
195
222
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
196
223
|
* @returns {Promise<SdkResponse<any>>} - `{ totals, byDate, byCarrierFamily, byBreakdown: { dimension: "carrierFamily", rows } }`. Every row carries segments, messages, peakSegmentsPerMinute, peakMessagesPerMinute, peakMinute (UTC "YYYY-MM-DD HH:MM:SS", null when no traffic), sendingMinutes, averageSegmentsPerSendingMinute and minutesAtCeiling.
|
|
197
224
|
*/
|
|
198
|
-
async getAnalyticsThroughput({ groupId, brandId, campaignId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds, options = {} }) {
|
|
199
|
-
const filters = { groupId, brandId, campaignId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds };
|
|
225
|
+
async getAnalyticsThroughput({ groupId, brandId, campaignId, registrationId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds, options = {} }) {
|
|
226
|
+
const filters = { groupId, brandId, campaignId, registrationId, carrierFamily, startDate, endDate, granularity, ceiling, dateBounds };
|
|
200
227
|
const queryString = this.client._getQueryString(filters);
|
|
201
228
|
return this.client(`/message/analytics/throughput${queryString}`, { method: "GET", ...options });
|
|
202
229
|
}
|
|
@@ -208,11 +235,12 @@ export class Messages {
|
|
|
208
235
|
* @roles api, admin, developer, billing, user
|
|
209
236
|
* @param {Object} params - The parameters for getting analytics filter options
|
|
210
237
|
* @param {string} params.groupId - The ID of the group whose filter options to load
|
|
238
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
211
239
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
212
|
-
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to { subgroups, brands, campaigns, phoneNumbers }
|
|
240
|
+
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to { subgroups, brands, campaigns, phoneNumbers }. Each phone number carries type (TOLL_FREE, SHORT_CODE, ALPHANUMERIC, VIRTUAL_LONG_NUMBER, ...) and country (ISO-2), null when unknown: TOLL_FREE, SHORT_CODE and ALPHANUMERIC are channels by type; any other US number is 10DLC and a non-US one is a Virtual Long Code.
|
|
213
241
|
*/
|
|
214
|
-
async getAnalyticsFilterOptions({ groupId, options = {} }) {
|
|
215
|
-
const filters = { groupId };
|
|
242
|
+
async getAnalyticsFilterOptions({ groupId, region, options = {} }) {
|
|
243
|
+
const filters = { groupId, region };
|
|
216
244
|
const queryString = this.client._getQueryString(filters);
|
|
217
245
|
return this.client(`/message/analytics/filter-options${queryString}`, { method: "GET", ...options });
|
|
218
246
|
}
|
|
@@ -227,6 +255,7 @@ export class Messages {
|
|
|
227
255
|
* @param {string|string[]} [params.subgroupId]
|
|
228
256
|
* @param {string|string[]} [params.brandId]
|
|
229
257
|
* @param {string|string[]} [params.campaignId]
|
|
258
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
230
259
|
* @param {string|string[]} [params.phoneNumber]
|
|
231
260
|
* @param {string|string[]} [params.carrier]
|
|
232
261
|
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless); single value, array, or comma-separated. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -237,13 +266,15 @@ export class Messages {
|
|
|
237
266
|
* @param {("tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p"|"both")|Array<"tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p">} [params.channel="both"] - Filter and rank rows by the stored channel column. "both" (default) means all activity. tenDLC/virtualLongCode/tollFree/shortCode/p2p (single value or array) limit to the selected channel(s).
|
|
238
267
|
* @param {(string|string[])} [params.messageType] - Message type(s) the SENTIMENT figures are scoped to: SMS, MMS or P2P (single value, array, or comma-separated string). Omit for all scored types. Does NOT narrow the message counts, which are always returned split per type (smsInbound/mmsInbound/p2pInbound) and have no filterable type dimension.
|
|
239
268
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
269
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
270
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
240
271
|
* @param {RequestOptions} [params.options]
|
|
241
272
|
* @returns {Promise<SdkResponse<any>>} - { rows, totalCount, page, limit }. Each row carries sms/mms/p2p metric columns plus `smsOptOuts` and `mmsOptOuts` from the DNC analytics MV (P2P has no opt-outs).
|
|
242
273
|
* Each row also carries that subgroup's inbound-message sentiment: `sentimentScore` (volume-weighted average of every scored inbound message in that subgroup, -100..100, null when nothing was scored), `sentimentLabel`, `sentimentScoredCount`, `sentimentPositive`, `sentimentNeutral`, `sentimentNegative`, plus the same six per message type under `smsSentiment*`, `mmsSentiment*` and `p2pSentiment*` prefixes. The score is derived server-side and must never be re-averaged across rows — combine the counts, not the scores.
|
|
243
274
|
*/
|
|
244
|
-
async getAnalyticsBySubgroup({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, messageType, dateBounds, options = {} }) {
|
|
245
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, messageType, dateBounds };
|
|
246
|
-
const queryString = this.client._getQueryString(filters);
|
|
275
|
+
async getAnalyticsBySubgroup({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, messageType, dateBounds, options = {} }) {
|
|
276
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, messageType, dateBounds };
|
|
277
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
247
278
|
return this.client(`/message/analytics/by-subgroup${queryString}`, { method: "GET", ...options });
|
|
248
279
|
}
|
|
249
280
|
|
|
@@ -257,6 +288,7 @@ export class Messages {
|
|
|
257
288
|
* @param {string|string[]} [params.subgroupId]
|
|
258
289
|
* @param {string|string[]} [params.brandId]
|
|
259
290
|
* @param {string|string[]} [params.campaignId]
|
|
291
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
260
292
|
* @param {string|string[]} [params.phoneNumber]
|
|
261
293
|
* @param {string|string[]} [params.carrier]
|
|
262
294
|
* @param {string|string[]} [params.carrierFamily] - Resolved carrier family of the recipient (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, P2P, Standard, IceWireless); single value, array, or comma-separated. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400 -- omit the parameter unless it is wanted.
|
|
@@ -266,12 +298,14 @@ export class Messages {
|
|
|
266
298
|
* @param {number} [params.limit=50] - max 50 per page
|
|
267
299
|
* @param {("tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p"|"both")|Array<"tenDLC"|"virtualLongCode"|"tollFree"|"shortCode"|"p2p">} [params.channel="both"] - Filter and rank rows by the stored channel column. "both" (default) means every code. tenDLC/virtualLongCode/tollFree/shortCode/p2p (single value or array) limit to the selected channel(s); when one channel is selected, totalErrors reflects only that channel.
|
|
268
300
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
301
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
302
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
269
303
|
* @param {RequestOptions} [params.options]
|
|
270
304
|
* @returns {Promise<SdkResponse<any>>} - { rows, totalCount, totalErrors: { sms, mms, p2p, all }, page, limit }
|
|
271
305
|
*/
|
|
272
|
-
async getAnalyticsByErrorCode({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, dateBounds, options = {} }) {
|
|
273
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, dateBounds };
|
|
274
|
-
const queryString = this.client._getQueryString(filters);
|
|
306
|
+
async getAnalyticsByErrorCode({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, dateBounds, options = {} }) {
|
|
307
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, carrierFamily, startDate, endDate, page, limit, channel, region, regionScopes, dateBounds };
|
|
308
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
275
309
|
return this.client(`/message/analytics/by-error-code${queryString}`, { method: "GET", ...options });
|
|
276
310
|
}
|
|
277
311
|
|
|
@@ -284,18 +318,21 @@ export class Messages {
|
|
|
284
318
|
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
285
319
|
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
286
320
|
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
321
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
287
322
|
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
288
323
|
* @param {string} [params.carrier] - Filter by the carrier
|
|
289
324
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode
|
|
290
325
|
* @param {string} [params.endDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode. In "exact" mode day buckets align to the UTC offset this bound carries, so a client that sends its own midnights gets its own calendar dates back
|
|
291
326
|
* @param {string|string[]} [params.channel] - Filter by channel (tenDLC, virtualLongCode, tollFree, shortCode). Opt-outs are A2P-only, so p2p applies no filter. Filters on the stored channel column; a tenDLC selection also includes older opt-outs that have no channel.
|
|
292
327
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
328
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
329
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
293
330
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
294
331
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the DNC analytics data (totals, byDate, byPhoneNumber, bySenderNumber, byCampaign, bySubgroup, byType, byCarrier, byKeyword). bySenderNumber ({ senderPhoneNumber, total, sms, mms }) attributes each opt-out to the first business number that received it, so it is unchanged by later campaign moves and START replies. byCampaign ({ campaignId, ... }) counts campaign-scoped opt-outs only, by the campaign at the time of the STOP; subgroup-scoped opt-outs (non-US recipients) are never attributed to a campaign and appear under bySubgroup ({ subgroupId, ... }) instead. byType ({ messageType, total }) splits SMS/MMS. byKeyword breaks opt-outs down by the normalized keyword that revoked consent ({ optOutKeyword, total, sms, mms }); opt-outs recorded before keyword capture shipped appear as a single optOutKeyword: null bucket ("not recorded"). The distinct keyword set is open-ended (campaigns register their own keywords beyond the mandatory floor) — render top-N plus Other, never a fixed list.
|
|
295
332
|
*/
|
|
296
|
-
async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, channel, dateBounds, options = {} }) {
|
|
297
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, channel, dateBounds };
|
|
298
|
-
const queryString = this.client._getQueryString(filters);
|
|
333
|
+
async getDncAnalytics({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, channel, region, regionScopes, dateBounds, options = {} }) {
|
|
334
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, channel, region, regionScopes, dateBounds };
|
|
335
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
299
336
|
return this.client(`/message/dnc/analytics${queryString}`, { method: "GET", ...options });
|
|
300
337
|
}
|
|
301
338
|
|
|
@@ -308,6 +345,7 @@ export class Messages {
|
|
|
308
345
|
* @param {string} [params.subgroupId] - Filter by the ID of the associated subgroup
|
|
309
346
|
* @param {string} [params.brandId] - Filter by the ID of the associated brand
|
|
310
347
|
* @param {string} [params.campaignId] - Filter by the ID of the associated campaign
|
|
348
|
+
* @param {string|string[]} [params.registrationId] - Filter to traffic attributed to these registrations (hourly analytics only; a 400 while hourly reads are off). A phoneNumber filter takes precedence. Accepts a single value or an array.
|
|
311
349
|
* @param {string} [params.phoneNumber] - Filter by the phone number
|
|
312
350
|
* @param {string} [params.carrier] - Filter by the carrier
|
|
313
351
|
* @param {string} [params.startDate] - ISO-8601 date or timestamp; bound per dateBounds: a bare date is always that whole UTC day (inclusive); a timestamp is widened to its whole UTC day in "day" mode and bound as the instant it names, in whatever offset it was written, in "exact" mode
|
|
@@ -318,12 +356,14 @@ export class Messages {
|
|
|
318
356
|
* @param {string} [params.sortOrder] - Sort direction (asc, desc)
|
|
319
357
|
* @param {string|string[]} [params.channel] - Filter by channel (tenDLC, virtualLongCode, tollFree, shortCode). Opt-outs are A2P-only, so p2p applies no filter. Filters on the stored channel column; a tenDLC selection also includes older opt-outs that have no channel.
|
|
320
358
|
* @param {("day"|"exact")} [params.dateBounds] - Which contract binds startDate/endDate. "day": each bound is widened to its whole UTC day. "exact": a timestamp is bound as the instant it names and a bare date is its whole UTC day. Omitted: "day".
|
|
359
|
+
* @param {string|string[]} [params.region] - ISO-2 country filter: US, GB or CA (any case of UK/GB/GBR/United Kingdom is accepted for GB); one value, an array, or a comma-separated string; omitted = every region. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
360
|
+
* @param {Object[]|string} [params.regionScopes] - Array of OR-ed branches `{ region, channels, brandId?, campaignId?, phoneNumber? }` (channels among tenDLC, virtualLongCode, tollFree, shortCode, p2p); `[]` matches nothing. Sent as JSON unless already a string. Only accepted where the environment serves hourly analytics; elsewhere any value is rejected with a 400.
|
|
321
361
|
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
322
362
|
* @returns {Promise<SdkResponse<any>>} - A promise that resolves to the paginated DNC records. Each record carries senderPhoneNumber — the first business number that received the opt-out (set once, never changed by a later STOP or a campaign move; the same value as phoneNumber) — optOutKeyword — the normalized keyword that revoked consent (e.g. "stop", "opt out"; a repeat opt-out records the most recent word), null for opt-outs recorded before keyword capture shipped — and carrierFamily, the resolved carrier family of the recipient number (Default, ATT, TMobile, Verizon, USCellular, GoogleVoice, ClearSky, Interop, RogueMobile, Standard, IceWireless), copied from the inbound message that triggered the opt-out. campaignId is null on subgroup-scoped records (non-US recipients).
|
|
323
363
|
*/
|
|
324
|
-
async getDncRecords({ groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, dateBounds, options = {} }) {
|
|
325
|
-
const filters = { groupId, subgroupId, brandId, campaignId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, dateBounds };
|
|
326
|
-
const queryString = this.client._getQueryString(filters);
|
|
364
|
+
async getDncRecords({ groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, region, regionScopes, dateBounds, options = {} }) {
|
|
365
|
+
const filters = { groupId, subgroupId, brandId, campaignId, registrationId, phoneNumber, carrier, startDate, endDate, page, limit, sortField, sortOrder, channel, region, regionScopes, dateBounds };
|
|
366
|
+
const queryString = this.client._getQueryString(withRegionScopes(filters));
|
|
327
367
|
return this.client(`/message/dnc${queryString}`, { method: "GET", ...options });
|
|
328
368
|
}
|
|
329
369
|
|
|
@@ -342,7 +382,7 @@ export class Messages {
|
|
|
342
382
|
* @async
|
|
343
383
|
* @roles api, admin, developer, billing, user
|
|
344
384
|
* @param {Object} params - The parameters for sending an SMS message
|
|
345
|
-
* @param {string} params.senderPhoneNumber - The 5-6 digit Short Code or 10+ digit phone number to send the message from
|
|
385
|
+
* @param {string} params.senderPhoneNumber - The 5-6 digit Short Code or 10+ digit phone number to send the message from, or a READY alphanumeric sender ID (e.g. "ACME"; UK recipients and SMS only). Every message from an alphanumeric sender gets "\nOpt out: sihou.io/o/{code}" appended by the server, counted in segments.
|
|
346
386
|
* @param {string|string[]} params.recipientPhoneNumbers - The 10+ digit phone number(s) to send the message to. A Short Code sender permits exactly one recipient, and it must be a +1 (US/Canada) number; a bare 10-digit number is treated as +1. The API rejects Short Code sends with multiple recipients or a non-+1 recipient.
|
|
347
387
|
* @param {string} params.messageBody - The body of the SMS message
|
|
348
388
|
* @param {string} [params.statusCallbackUrl] - The URL to receive status callbacks
|
package/src/domains/Numbers.js
CHANGED
|
@@ -77,6 +77,7 @@ export class Numbers {
|
|
|
77
77
|
* @param {Object} params - The parameters for filtering the phone numbers
|
|
78
78
|
* @param {string} [params.phoneNumber] - Filter by phone number (partial match)
|
|
79
79
|
* @param {string} [params.campaignId] - Filter by campaign ID
|
|
80
|
+
* @param {string} [params.registrationId] - Filter to numbers provisioned under this registration.
|
|
80
81
|
* @param {string} [params.brandId] - Filter by brand ID
|
|
81
82
|
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
82
83
|
* @param {string} [params.groupId] - Filter by group ID
|
|
@@ -102,8 +103,8 @@ export class Numbers {
|
|
|
102
103
|
* or GET /campaign/health.
|
|
103
104
|
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the list of phone numbers
|
|
104
105
|
*/
|
|
105
|
-
async getPhoneNumbers({ phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit, options = {} }) {
|
|
106
|
-
const filters = { phoneNumber, campaignId, brandId, subgroupId, groupId, page, limit };
|
|
106
|
+
async getPhoneNumbers({ phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, page, limit, options = {} }) {
|
|
107
|
+
const filters = { phoneNumber, campaignId, registrationId, brandId, subgroupId, groupId, page, limit };
|
|
107
108
|
const queryString = this.client._getQueryString(filters);
|
|
108
109
|
return this.client(`/number${queryString}`, { method: 'GET', ...options });
|
|
109
110
|
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/** @typedef {import('../SignalHouseSDK.js').RequestOptions} RequestOptions */
|
|
2
|
+
/**
|
|
3
|
+
* @template T
|
|
4
|
+
* @typedef {import('../SignalHouseSDK.js').SdkResponse<T>} SdkResponse
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Sender registrations for every jurisdiction and type: the catalog of what a region offers, retail quotes,
|
|
9
|
+
* customer submissions and staff review operations. `type` selects the shape of `data`
|
|
10
|
+
* (for VIRTUAL_LONG_CODE: quantity, useCases and the optional voice dossier; for GB ALPHANUMERIC_SENDER_ID: requestedSenderId,
|
|
11
|
+
* trafficOrigin, trafficType and the company details).
|
|
12
|
+
*/
|
|
13
|
+
export class Registrations {
|
|
14
|
+
constructor(client, enableAdmin) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.enableAdmin = enableAdmin;
|
|
17
|
+
|
|
18
|
+
if (enableAdmin) {
|
|
19
|
+
this.admin = {
|
|
20
|
+
/**
|
|
21
|
+
* Approve or reject a registration awaiting Signal House review (signalhouse only)
|
|
22
|
+
* @async
|
|
23
|
+
* @roles signalhouse
|
|
24
|
+
* @param {Object} params - The parameters for the review decision
|
|
25
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
26
|
+
* @param {("APPROVE"|"REJECT")} params.action - The review decision
|
|
27
|
+
* @param {string} [params.reason] - Why the registration was rejected; required when action is REJECT
|
|
28
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
29
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
30
|
+
*/
|
|
31
|
+
reviewRegistration: async ({ registrationId, action, reason, options = {} }) => {
|
|
32
|
+
this.client._require({ registrationId, action });
|
|
33
|
+
const safeId = encodeURIComponent(registrationId);
|
|
34
|
+
return this.client(`/registration/${safeId}/review`, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
body: { action, reason },
|
|
37
|
+
...options,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Save corrections to the type's correctable fields for a registration the provider sent back for
|
|
43
|
+
* more information; owner, quantity, bundle and provider order never change (signalhouse only)
|
|
44
|
+
* @async
|
|
45
|
+
* @roles signalhouse
|
|
46
|
+
* @param {Object} params - The parameters for the correction
|
|
47
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
48
|
+
* @param {string} params.reason - Why the registration was corrected
|
|
49
|
+
* @param {Object} params.data - The type's correctable fields (for VIRTUAL_LONG_CODE: useCases and, for SMS + Voice, voice)
|
|
50
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
51
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
52
|
+
*/
|
|
53
|
+
correctRegistration: async ({ registrationId, reason, data, options = {} }) => {
|
|
54
|
+
this.client._require({ registrationId, reason, data });
|
|
55
|
+
const safeId = encodeURIComponent(registrationId);
|
|
56
|
+
return this.client(`/registration/${safeId}/corrections`, {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: { reason, data },
|
|
59
|
+
...options,
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Allocate a provider-owned number to a registration through the staff recovery path (signalhouse only)
|
|
65
|
+
* @async
|
|
66
|
+
* @roles signalhouse
|
|
67
|
+
* @param {Object} params - The parameters for the allocation
|
|
68
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
69
|
+
* @param {string} params.phoneNumber - The E.164 number (10-15 digits, optional leading +) to allocate
|
|
70
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
71
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
72
|
+
*/
|
|
73
|
+
addNumber: async ({ registrationId, phoneNumber, options = {} }) => {
|
|
74
|
+
this.client._require({ registrationId, phoneNumber });
|
|
75
|
+
const safeId = encodeURIComponent(registrationId);
|
|
76
|
+
return this.client(`/registration/${safeId}/numbers`, {
|
|
77
|
+
method: "POST",
|
|
78
|
+
body: { phoneNumber },
|
|
79
|
+
...options,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Link an existing provider order to a registration parked in RECONCILIATION_REQUIRED (signalhouse only)
|
|
85
|
+
* @async
|
|
86
|
+
* @roles signalhouse
|
|
87
|
+
* @param {Object} params - The parameters for the reconciliation
|
|
88
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
89
|
+
* @param {string} params.externalId - The provider's identifier for the existing order
|
|
90
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
91
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the updated registration
|
|
92
|
+
*/
|
|
93
|
+
reconcile: async ({ registrationId, externalId, options = {} }) => {
|
|
94
|
+
this.client._require({ registrationId, externalId });
|
|
95
|
+
const safeId = encodeURIComponent(registrationId);
|
|
96
|
+
return this.client(`/registration/${safeId}/reconcile`, {
|
|
97
|
+
method: "POST",
|
|
98
|
+
body: { externalId },
|
|
99
|
+
...options,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Download the completed carrier application as DOCX bytes (signalhouse only)
|
|
105
|
+
* @async
|
|
106
|
+
* @roles signalhouse
|
|
107
|
+
* @param {Object} params - The parameters for the download
|
|
108
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
109
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
110
|
+
* @returns {Promise<SdkResponse<ArrayBuffer>>} A promise that resolves to the DOCX document as an ArrayBuffer
|
|
111
|
+
*/
|
|
112
|
+
getApplication: async ({ registrationId, options = {} }) => {
|
|
113
|
+
this.client._require({ registrationId });
|
|
114
|
+
const safeId = encodeURIComponent(registrationId);
|
|
115
|
+
return this.client(`/registration/${safeId}/application`, {
|
|
116
|
+
method: "GET",
|
|
117
|
+
responseType: "arraybuffer",
|
|
118
|
+
...options,
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get the registration types a region offers and whether each can be acquired right now
|
|
127
|
+
* @async
|
|
128
|
+
* @roles api, admin, developer, billing, user
|
|
129
|
+
* @param {Object} params - The parameters for the catalog
|
|
130
|
+
* @param {string} params.region - ISO-2 jurisdiction (US, GB or CA; any case of UK/GB/GBR/United Kingdom is accepted for GB)
|
|
131
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
132
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { region, jurisdiction, sendingRequiresRegistration, registeredThrough, provisioning, types }
|
|
133
|
+
*/
|
|
134
|
+
async getCatalog({ region, options = {} }) {
|
|
135
|
+
this.client._require({ region });
|
|
136
|
+
const queryString = this.client._getQueryString({ region });
|
|
137
|
+
return this.client(`/registration/catalog${queryString}`, { method: "GET", ...options });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get retail quotes for a registration type: one quote per capability bundle with per-number setupAmount
|
|
142
|
+
* and monthlyAmount, the totals for the quantity (integer microdollars) and etaDays. GB ALPHANUMERIC_SENDER_ID
|
|
143
|
+
* quotes one ["SMS"] bundle (6000000 setup and 6000000 monthly by default).
|
|
144
|
+
* Unavailable (400) while the type cannot be acquired in the region.
|
|
145
|
+
* @async
|
|
146
|
+
* @roles api, admin, developer, billing, user
|
|
147
|
+
* @param {Object} params - The parameters for the quote
|
|
148
|
+
* @param {string} params.region - ISO-2 jurisdiction (any case of UK/GB/GBR/United Kingdom is accepted for GB)
|
|
149
|
+
* @param {string} params.type - Registration type (e.g. VIRTUAL_LONG_CODE, or ALPHANUMERIC_SENDER_ID for GB)
|
|
150
|
+
* @param {number} [params.quantity=1] - Number of numbers to quote (1-100)
|
|
151
|
+
* @param {string} [params.groupId] - Group to price for; staff only
|
|
152
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
153
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { data: [quotes] }
|
|
154
|
+
*/
|
|
155
|
+
async getQuotes({ region, type, quantity = 1, groupId, options = {} }) {
|
|
156
|
+
this.client._require({ region, type });
|
|
157
|
+
const queryString = this.client._getQueryString({ region, type, quantity, groupId });
|
|
158
|
+
return this.client(`/registration/quotes${queryString}`, { method: "GET", ...options });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* List registrations for an authorized group; staff may omit groupId to read the review queue
|
|
163
|
+
* @async
|
|
164
|
+
* @roles api, admin, developer, billing, user
|
|
165
|
+
* @param {Object} [params] - The parameters for filtering the registrations
|
|
166
|
+
* @param {string} [params.groupId] - Filter by group ID
|
|
167
|
+
* @param {string} [params.subgroupId] - Filter by subgroup ID
|
|
168
|
+
* @param {string|string[]} [params.region] - Filter by one ISO-2 jurisdiction or a list
|
|
169
|
+
* @param {string} [params.type] - Filter by registration type
|
|
170
|
+
* @param {string} [params.kind] - Filter by kind (identity, program, sender)
|
|
171
|
+
* @param {string|string[]} [params.status] - Filter by one registration status or a list
|
|
172
|
+
* @param {string} [params.parentRegistrationId] - Filter by the parent registration ID
|
|
173
|
+
* @param {string} [params.phoneNumber] - Filter to registrations holding this phone number
|
|
174
|
+
* @param {string} [params.sortBy] - Sort field: createdAt (default), subgroupId, registrationId, region or status
|
|
175
|
+
* @param {string} [params.sortOrder] - Sort direction: asc or desc (default)
|
|
176
|
+
* @param {number} [params.page] - Page number (default 1)
|
|
177
|
+
* @param {number} [params.limit] - Registrations per page (default 25, max 100)
|
|
178
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
179
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to { data: [registrations], totalCount, page, limit }
|
|
180
|
+
*/
|
|
181
|
+
async getRegistrations({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, sortBy, sortOrder, page, limit, options = {} } = {}) {
|
|
182
|
+
const queryString = this.client._getQueryString({ groupId, subgroupId, region, type, kind, status, parentRegistrationId, phoneNumber, sortBy, sortOrder, page, limit });
|
|
183
|
+
return this.client(`/registration${queryString}`, { method: "GET", ...options });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get a single registration with its review outcome, the type's public data and its status history
|
|
188
|
+
* @async
|
|
189
|
+
* @roles api, admin, developer, billing, user
|
|
190
|
+
* @param {Object} params - The parameters for getting the registration
|
|
191
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
192
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
193
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the registration
|
|
194
|
+
*/
|
|
195
|
+
async getRegistration({ registrationId, options = {} }) {
|
|
196
|
+
this.client._require({ registrationId });
|
|
197
|
+
const safeId = encodeURIComponent(registrationId);
|
|
198
|
+
return this.client(`/registration/${safeId}`, { method: "GET", ...options });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Cancel a registration. Allowed from SIGNAL_HOUSE_REVIEW, SIGNAL_HOUSE_APPROVED, PENDING_PROVIDER, NEEDS_INFORMATION,
|
|
203
|
+
* PAYMENT_REQUIRED and APPROVED (409 otherwise). Numbers already allocated stay on the account and stop sending.
|
|
204
|
+
* @async
|
|
205
|
+
* @roles api, admin, developer, user
|
|
206
|
+
* @param {Object} params - The parameters for cancelling the registration
|
|
207
|
+
* @param {string} params.registrationId - The registration ID (e.g. GB8T9GTD5AZY)
|
|
208
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
209
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the cancelled registration
|
|
210
|
+
*/
|
|
211
|
+
async cancelRegistration({ registrationId, options = {} }) {
|
|
212
|
+
this.client._require({ registrationId });
|
|
213
|
+
const safeId = encodeURIComponent(registrationId);
|
|
214
|
+
return this.client(`/registration/${safeId}`, { method: "DELETE", ...options });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Submit a registration. `type` selects the shape of `data`: for VIRTUAL_LONG_CODE it is { quantity (1-100),
|
|
219
|
+
* useCases (1-10 descriptions), voice? } where voice is required exactly when capabilities include VOICE. For GB
|
|
220
|
+
* ALPHANUMERIC_SENDER_ID (capabilities ["SMS"]) it is { requestedSenderId (3-11 letters/digits/space/dot/dash,
|
|
221
|
+
* at least one letter), trafficOrigin (LOCAL | INTERNATIONAL), trafficType (TRANSACTIONAL | PROMOTIONAL),
|
|
222
|
+
* companyName, companyCountry, companyWebsite, industry, messageExample, senderRelationship? } where
|
|
223
|
+
* senderRelationship is required when requestedSenderId differs from companyName; quantity is always 1 and
|
|
224
|
+
* data.phoneNumbers carries the granted sender (e.g. ["ACME"]) once APPROVED.
|
|
225
|
+
* Reuse the same clientRequestId only when retrying an identical payload (409 otherwise).
|
|
226
|
+
* Unavailable (400) while the type cannot be acquired in the region.
|
|
227
|
+
* @async
|
|
228
|
+
* @roles api, admin, developer, billing, user
|
|
229
|
+
* @param {Object} params - The parameters for the registration
|
|
230
|
+
* @param {string} params.region - ISO-2 jurisdiction (any case of UK/GB/GBR/United Kingdom is accepted for GB)
|
|
231
|
+
* @param {string} params.type - Registration type (e.g. VIRTUAL_LONG_CODE, or ALPHANUMERIC_SENDER_ID for GB)
|
|
232
|
+
* @param {string} params.subgroupId - Subgroup that will own the registration and any allocated numbers
|
|
233
|
+
* @param {string} params.clientRequestId - Idempotency key (UUID)
|
|
234
|
+
* @param {string[]} params.capabilities - One of the type's bundles, e.g. ["SMS"] or ["SMS", "VOICE"]
|
|
235
|
+
* @param {Object} params.data - The type's submission fields
|
|
236
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
237
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to the created registration
|
|
238
|
+
*/
|
|
239
|
+
async createRegistration({ region, type, subgroupId, clientRequestId, capabilities, data, options = {} }) {
|
|
240
|
+
this.client._require({ region, type, subgroupId, clientRequestId, capabilities, data });
|
|
241
|
+
return this.client("/registration", {
|
|
242
|
+
method: "POST",
|
|
243
|
+
body: { region, type, subgroupId, clientRequestId, capabilities, data },
|
|
244
|
+
...options,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -25,6 +25,36 @@ export class Shortlinks {
|
|
|
25
25
|
return this.client(`/shortlink/redirect/${safeShortlinkId}`, { method: "GET", ...options });
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Get the recipient opt-out details behind an alphanumeric-sender opt-out link (sihou.io/o/{code})
|
|
30
|
+
* @async
|
|
31
|
+
* @roles public
|
|
32
|
+
* @param {Object} params - The parameters for getting the opt-out details
|
|
33
|
+
* @param {string} params.code - The opt-out code from the link
|
|
34
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
35
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ code, senderName, maskedRecipient, optedOut }`
|
|
36
|
+
*/
|
|
37
|
+
async getOptOut({ code, options = {} }) {
|
|
38
|
+
this.client._require({ code });
|
|
39
|
+
const safeCode = encodeURIComponent(code);
|
|
40
|
+
return this.client(`/shortlink/optout/${safeCode}`, { method: "GET", ...options });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Confirm the recipient opt-out behind an alphanumeric-sender opt-out link; idempotent
|
|
45
|
+
* @async
|
|
46
|
+
* @roles public
|
|
47
|
+
* @param {Object} params - The parameters for confirming the opt-out
|
|
48
|
+
* @param {string} params.code - The opt-out code from the link
|
|
49
|
+
* @param {RequestOptions} [params.options] - Additional options for the request
|
|
50
|
+
* @returns {Promise<SdkResponse<any>>} A promise that resolves to `{ code, senderName, maskedRecipient, optedOut: true }`
|
|
51
|
+
*/
|
|
52
|
+
async confirmOptOut({ code, options = {} }) {
|
|
53
|
+
this.client._require({ code });
|
|
54
|
+
const safeCode = encodeURIComponent(code);
|
|
55
|
+
return this.client(`/shortlink/optout/${safeCode}`, { method: "POST", ...options });
|
|
56
|
+
}
|
|
57
|
+
|
|
28
58
|
/**
|
|
29
59
|
* Get details of a shortlink by its ID, with optional filters
|
|
30
60
|
* @async
|