@sentdm/sentdm 0.38.0 → 0.39.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/CHANGELOG.md +7 -0
- package/client.d.mts +2 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +2 -2
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/templates.d.mts +153 -13
- package/resources/templates.d.mts.map +1 -1
- package/resources/templates.d.ts +153 -13
- package/resources/templates.d.ts.map +1 -1
- package/resources/templates.js +28 -2
- package/resources/templates.js.map +1 -1
- package/resources/templates.mjs +28 -2
- package/resources/templates.mjs.map +1 -1
- package/resources/webhooks.d.mts +313 -22
- package/resources/webhooks.d.mts.map +1 -1
- package/resources/webhooks.d.ts +313 -22
- package/resources/webhooks.d.ts.map +1 -1
- package/src/client.ts +8 -0
- package/src/resources/index.ts +4 -0
- package/src/resources/templates.ts +154 -13
- package/src/resources/webhooks.ts +347 -21
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -12,7 +12,9 @@ export declare class Templates extends APIResource {
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new message template with header, body, footer, and buttons. The
|
|
14
14
|
* template can be submitted for review immediately or saved as draft for later
|
|
15
|
-
* submission.
|
|
15
|
+
* submission. There is no `name` field on create — the display name is derived
|
|
16
|
+
* from the template's content and can be changed afterwards with
|
|
17
|
+
* `PUT /v3/templates/{id}`.
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
20
|
* ```ts
|
|
@@ -34,7 +36,31 @@ export declare class Templates extends APIResource {
|
|
|
34
36
|
retrieve(id: string, params?: TemplateRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<APIResponseTemplate>;
|
|
35
37
|
/**
|
|
36
38
|
* Updates an existing template's name, category, language, definition, or submits
|
|
37
|
-
* it for review.
|
|
39
|
+
* it for review. While the template is in review (status PENDING, or any channel
|
|
40
|
+
* awaiting a verdict) its definition, category and language are frozen and a
|
|
41
|
+
* resubmission is refused — those requests answer 409 CONFLICT_006. The display
|
|
42
|
+
* name stays editable throughout.
|
|
43
|
+
*
|
|
44
|
+
* `definition`, `category` and `language` are editable only from status DRAFT,
|
|
45
|
+
* REJECTED or APPROVED. An edit to any of them on a template in another state
|
|
46
|
+
* (PAUSED, DISABLED or REVOKED) is refused with 400 VALIDATION_001 and the detail
|
|
47
|
+
* "Template (except display name) cannot be updated unless it is in draft or
|
|
48
|
+
* rejected status"; `name` stays editable in every state. `submit_for_review` on a
|
|
49
|
+
* PAUSED, DISABLED or REVOKED template is accepted and answers 200, but opens no
|
|
50
|
+
* review and does not move the status — only the reviewer can reinstate it.
|
|
51
|
+
*
|
|
52
|
+
* Editing an APPROVED template is a live edit: the new content is stored
|
|
53
|
+
* immediately, and sending `submit_for_review: true` re-opens review, which
|
|
54
|
+
* returns the affected channels to PENDING so they stop sending until they are
|
|
55
|
+
* approved again. The previously approved content is never sent during re-review.
|
|
56
|
+
* Watch the per-channel `templates` webhook events rather than assuming the
|
|
57
|
+
* template-level status.
|
|
58
|
+
*
|
|
59
|
+
* Templates provisioned by Sent (light-onboarding templates, whose names carry the
|
|
60
|
+
* reserved `sent_` prefix) are read-only: every field is refused with 400
|
|
61
|
+
* VALIDATION*001 and the detail "This template is read-only. Only 'submit for
|
|
62
|
+
* review' is allowed.", and only `submit_for_review` is accepted. A `name`
|
|
63
|
+
* starting with `sent*` is refused for the same reason — the prefix is reserved.
|
|
38
64
|
*
|
|
39
65
|
* @example
|
|
40
66
|
* ```ts
|
|
@@ -120,12 +146,38 @@ export interface Template {
|
|
|
120
146
|
* Unique template identifier
|
|
121
147
|
*/
|
|
122
148
|
id?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Which consent keyword this template answers, when it is one of Sent's
|
|
151
|
+
* auto-replies: OPT_IN, OPT_OUT, HELP, or OTHER for a customer-defined keyword.
|
|
152
|
+
* Null for an ordinary template, and omitted from the response, so its presence is
|
|
153
|
+
* the answer to "is this an auto-reply".
|
|
154
|
+
*
|
|
155
|
+
* Deliberately not required, unlike CustomerId, even though the same "no single
|
|
156
|
+
* mapper" argument applies: NJsonSchema publishes a C# required member in the
|
|
157
|
+
* schema's required array, so the contract would have advertised a field this
|
|
158
|
+
* response omits for every ordinary template, and a generated client could refuse
|
|
159
|
+
* the common case. A compile-time guard is not worth a wrong published contract.
|
|
160
|
+
* Every mapping site sets it explicitly, and TemplateResponseSchemaTests pins the
|
|
161
|
+
* field as optional so it cannot be reintroduced.
|
|
162
|
+
*/
|
|
163
|
+
auto_reply_action?: string | null;
|
|
123
164
|
/**
|
|
124
165
|
* Template category: MARKETING, UTILITY, AUTHENTICATION
|
|
125
166
|
*/
|
|
126
167
|
category?: string;
|
|
127
168
|
/**
|
|
128
|
-
*
|
|
169
|
+
* The channels this template's definition can render on, in canonical order: sms,
|
|
170
|
+
* whatsapp, rcs.
|
|
171
|
+
*
|
|
172
|
+
* Derived from the definition's body, mirroring each channel's send-time fallback
|
|
173
|
+
* chain, so a channel is listed only when a real body would be produced for it:
|
|
174
|
+
* SMS reads sms ?? multiChannel, WhatsApp reads whatsapp ?? multiChannel, and RCS
|
|
175
|
+
* reads rcs ?? multiChannel ?? sms. A multiChannel body therefore reports all
|
|
176
|
+
* three, and the extra SMS fallback on RCS is why an sms/whatsapp pair reports RCS
|
|
177
|
+
* too.
|
|
178
|
+
*
|
|
179
|
+
* This says what the content can render on, not what may be sent: sending also
|
|
180
|
+
* needs the template approved for that channel.
|
|
129
181
|
*/
|
|
130
182
|
channels?: Array<string> | null;
|
|
131
183
|
/**
|
|
@@ -145,7 +197,8 @@ export interface Template {
|
|
|
145
197
|
*/
|
|
146
198
|
name?: string;
|
|
147
199
|
/**
|
|
148
|
-
* Template status:
|
|
200
|
+
* Template status: DRAFT, PENDING, APPROVED, REJECTED. A template created with
|
|
201
|
+
* submit_for_review: false starts as DRAFT and stays there until it is submitted.
|
|
149
202
|
*/
|
|
150
203
|
status?: string;
|
|
151
204
|
/**
|
|
@@ -158,31 +211,73 @@ export interface Template {
|
|
|
158
211
|
variables?: Array<string> | null;
|
|
159
212
|
}
|
|
160
213
|
/**
|
|
161
|
-
* Body section of a message template
|
|
214
|
+
* Body section of a message template.
|
|
215
|
+
*
|
|
216
|
+
* A body picks one of two authoring strategies, and mixing them is refused
|
|
217
|
+
* (TemplateDefinitionValidator.HaveValidChannelConfiguration): a shared
|
|
218
|
+
* multiChannel body on its own, or an explicit sms + whatsapp pair, both present.
|
|
219
|
+
*
|
|
220
|
+
* multiChannel together with sms or whatsapp is rejected, and so is sms or
|
|
221
|
+
* whatsapp on its own — every template is expected to be deliverable on every
|
|
222
|
+
* channel. rcs is the one true override: it may accompany either strategy to vary
|
|
223
|
+
* the copy, but cannot stand alone.
|
|
162
224
|
*/
|
|
163
225
|
export interface TemplateBody {
|
|
164
226
|
/**
|
|
165
|
-
*
|
|
166
|
-
* channel-specific content is provided
|
|
227
|
+
* The shared body, used for every channel. One half of the choice described above.
|
|
167
228
|
*/
|
|
168
229
|
multiChannel?: TemplateBodyContent | null;
|
|
169
230
|
/**
|
|
170
|
-
* RCS-specific
|
|
231
|
+
* RCS-specific copy that overrides the chosen strategy for RCS only. The one true
|
|
232
|
+
* override: optional on top of either strategy, but it cannot be the only body
|
|
233
|
+
* present. Its length cap is the higher one described on Template.
|
|
171
234
|
*/
|
|
172
235
|
rcs?: TemplateBodyContent | null;
|
|
173
236
|
/**
|
|
174
|
-
* SMS
|
|
237
|
+
* The SMS body. It does not override multiChannel, it replaces it.
|
|
175
238
|
*/
|
|
176
239
|
sms?: TemplateBodyContent | null;
|
|
177
240
|
/**
|
|
178
|
-
* WhatsApp
|
|
179
|
-
* messages
|
|
241
|
+
* The WhatsApp body. It does not override multiChannel, it replaces it.
|
|
180
242
|
*/
|
|
181
243
|
whatsapp?: TemplateBodyContent | null;
|
|
182
244
|
}
|
|
183
245
|
export interface TemplateBodyContent {
|
|
246
|
+
/**
|
|
247
|
+
* The body copy, with variables written as {{index:variable}}.
|
|
248
|
+
*
|
|
249
|
+
* Length cap depends on which channel this body belongs to:
|
|
250
|
+
* TemplateContentLimits.MaxBodyLength (1024) for multiChannel, sms and whatsapp —
|
|
251
|
+
* Meta's BODY limit, which a multiChannel body may be delivered under — and
|
|
252
|
+
* TemplateContentLimits.MaxRcsBodyLength (3072) for an rcs body, which never
|
|
253
|
+
* reaches Meta. The maxLength advertised on this schema is the 1024 one, because
|
|
254
|
+
* all four channel bodies share this single schema — an rcs body between the two
|
|
255
|
+
* is accepted.
|
|
256
|
+
*
|
|
257
|
+
* Meta requires every variable to carry surrounding context, so a body is refused
|
|
258
|
+
* unless it also satisfies all of the following (enforced by
|
|
259
|
+
* TemplateDefinitionValidator): At least one letter before the first variable and
|
|
260
|
+
* after the last — trailing punctuation such as "... {{1:variable}}." does not
|
|
261
|
+
* count. At least (2 × variable count) + 1 words once the placeholders are
|
|
262
|
+
* removed. No two variables adjacent with only whitespace between them. No leading
|
|
263
|
+
* or trailing newline, no more than two consecutive line breaks, and no more than
|
|
264
|
+
* four consecutive spaces.
|
|
265
|
+
*
|
|
266
|
+
* Example: "Hello {{0:variable}}! Welcome to {{1:variable}}. We are glad to have
|
|
267
|
+
* you on board." — two variables, so at least five words are required, and the
|
|
268
|
+
* copy after the final variable contains letters.
|
|
269
|
+
*/
|
|
184
270
|
template: string;
|
|
271
|
+
/**
|
|
272
|
+
* The type of body content — send "text". It is dropped from the stored definition
|
|
273
|
+
* when null, so a body posted without it is saved with no type key at all and the
|
|
274
|
+
* template editor has nothing to render the block from.
|
|
275
|
+
*/
|
|
185
276
|
type?: string | null;
|
|
277
|
+
/**
|
|
278
|
+
* The variables referenced by the body copy, one entry per {{index:variable}}
|
|
279
|
+
* placeholder.
|
|
280
|
+
*/
|
|
186
281
|
variables?: Array<TemplateVariable> | null;
|
|
187
282
|
}
|
|
188
283
|
/**
|
|
@@ -198,7 +293,13 @@ export interface TemplateButton {
|
|
|
198
293
|
*/
|
|
199
294
|
type: string;
|
|
200
295
|
/**
|
|
201
|
-
* The
|
|
296
|
+
* The button's identifier (1-based index), unique within the template.
|
|
297
|
+
*
|
|
298
|
+
* Omitting it is only safe for a template holding a single button. The field is a
|
|
299
|
+
* non-nullable int, so every button that leaves it out defaults to 0, and two such
|
|
300
|
+
* buttons are refused by the unique-id rule ("Button IDs must be unique"). Number
|
|
301
|
+
* them from 1 in the order they should appear — order matters on RCS, where only
|
|
302
|
+
* the first four buttons render.
|
|
202
303
|
*/
|
|
203
304
|
id?: number;
|
|
204
305
|
}
|
|
@@ -208,6 +309,19 @@ export interface TemplateButtonProps {
|
|
|
208
309
|
offerCode: string;
|
|
209
310
|
phoneNumber: string;
|
|
210
311
|
quickReplyType: string;
|
|
312
|
+
/**
|
|
313
|
+
* The button's label. Required for every button type, and capped at
|
|
314
|
+
* TemplateContentLimits.MaxButtonTextLength (25) characters.
|
|
315
|
+
*
|
|
316
|
+
* Meta accepts only static text here, so a label is refused when it contains a
|
|
317
|
+
* {{...}} variable placeholder, a newline, an emoji, or WhatsApp formatting markup
|
|
318
|
+
* (\*, \_, ~) — enforced by ApplyButtonLabelContentRules in
|
|
319
|
+
* TemplateButtonValidator. Meta reports all four as one error: "Buttons can't have
|
|
320
|
+
* any variables, newlines, emojis, or formatting characters."
|
|
321
|
+
*
|
|
322
|
+
* AUTHENTICATION OTP buttons are the exception: Meta auto-localizes their label
|
|
323
|
+
* from the template language, and the converter drops whatever text was sent.
|
|
324
|
+
*/
|
|
211
325
|
text: string;
|
|
212
326
|
url: string;
|
|
213
327
|
urlType: string;
|
|
@@ -228,7 +342,16 @@ export interface TemplateButtonProps {
|
|
|
228
342
|
*/
|
|
229
343
|
export interface TemplateDefinition {
|
|
230
344
|
/**
|
|
231
|
-
* Body section of a message template
|
|
345
|
+
* Body section of a message template.
|
|
346
|
+
*
|
|
347
|
+
* A body picks one of two authoring strategies, and mixing them is refused
|
|
348
|
+
* (TemplateDefinitionValidator.HaveValidChannelConfiguration): a shared
|
|
349
|
+
* multiChannel body on its own, or an explicit sms + whatsapp pair, both present.
|
|
350
|
+
*
|
|
351
|
+
* multiChannel together with sms or whatsapp is rejected, and so is sms or
|
|
352
|
+
* whatsapp on its own — every template is expected to be deliverable on every
|
|
353
|
+
* channel. rcs is the one true override: it may accompany either strategy to vary
|
|
354
|
+
* the copy, but cannot stand alone.
|
|
232
355
|
*/
|
|
233
356
|
body: TemplateBody;
|
|
234
357
|
/**
|
|
@@ -288,9 +411,26 @@ export interface TemplateHeader {
|
|
|
288
411
|
variables?: Array<TemplateVariable> | null;
|
|
289
412
|
}
|
|
290
413
|
export interface TemplateVariable {
|
|
414
|
+
/**
|
|
415
|
+
* The variable's name, and the key callers use for it in a send request's
|
|
416
|
+
* parameters object. Must start with a letter and hold only letters, digits and
|
|
417
|
+
* underscores.
|
|
418
|
+
*/
|
|
291
419
|
name: string;
|
|
292
420
|
props: TemplateVariable.Props;
|
|
421
|
+
/**
|
|
422
|
+
* One of variable, link or media. Decides which Props fields are required.
|
|
423
|
+
*/
|
|
293
424
|
type: string;
|
|
425
|
+
/**
|
|
426
|
+
* The variable's index, and the number its {{index:variable}} placeholder refers
|
|
427
|
+
* to.
|
|
428
|
+
*
|
|
429
|
+
* Omitting it is only safe for a section holding a single variable. The field is a
|
|
430
|
+
* non-nullable int, so every variable that leaves it out defaults to 0, and a
|
|
431
|
+
* section with two such variables is refused by the unique-id rule ("variables
|
|
432
|
+
* must have unique IDs"). Number them from 0 in the order they appear.
|
|
433
|
+
*/
|
|
294
434
|
id?: number;
|
|
295
435
|
}
|
|
296
436
|
export declare namespace TemplateVariable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.mts","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAC/C,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EAAE,UAAU,EAAE,gCAA4B;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,+BAA2B;AAE1F,OAAO,EAAE,cAAc,EAAE,wCAAoC;AAG7D;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC
|
|
1
|
+
{"version":3,"file":"templates.d.mts","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,6BAAyB;AAC/C,OAAO,KAAK,WAAW,uBAAmB;AAC1C,OAAO,EAAE,UAAU,EAAE,gCAA4B;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,+BAA2B;AAE1F,OAAO,EAAE,cAAc,EAAE,wCAAoC;AAG7D;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;IAe/F;;;;;;;;;;OAUG;IACH,QAAQ,CACN,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,sBAAsB,GAAG,IAAI,GAAG,SAAc,EACtD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,mBAAmB,CAAC;IAWlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,MAAM,CACJ,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,mBAAmB,CAAC;IAelC;;;;;;;;;;;OAWG;IACH,IAAI,CACF,MAAM,GAAE,kBAAkB,GAAG,IAAI,GAA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AAK,cAAc,IAAI,cAAc,EACrC,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,oBAAoB,IAAI,oBAAoB,GAClD,CAAC;CACH"}
|
package/resources/templates.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export declare class Templates extends APIResource {
|
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new message template with header, body, footer, and buttons. The
|
|
14
14
|
* template can be submitted for review immediately or saved as draft for later
|
|
15
|
-
* submission.
|
|
15
|
+
* submission. There is no `name` field on create — the display name is derived
|
|
16
|
+
* from the template's content and can be changed afterwards with
|
|
17
|
+
* `PUT /v3/templates/{id}`.
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
20
|
* ```ts
|
|
@@ -34,7 +36,31 @@ export declare class Templates extends APIResource {
|
|
|
34
36
|
retrieve(id: string, params?: TemplateRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<APIResponseTemplate>;
|
|
35
37
|
/**
|
|
36
38
|
* Updates an existing template's name, category, language, definition, or submits
|
|
37
|
-
* it for review.
|
|
39
|
+
* it for review. While the template is in review (status PENDING, or any channel
|
|
40
|
+
* awaiting a verdict) its definition, category and language are frozen and a
|
|
41
|
+
* resubmission is refused — those requests answer 409 CONFLICT_006. The display
|
|
42
|
+
* name stays editable throughout.
|
|
43
|
+
*
|
|
44
|
+
* `definition`, `category` and `language` are editable only from status DRAFT,
|
|
45
|
+
* REJECTED or APPROVED. An edit to any of them on a template in another state
|
|
46
|
+
* (PAUSED, DISABLED or REVOKED) is refused with 400 VALIDATION_001 and the detail
|
|
47
|
+
* "Template (except display name) cannot be updated unless it is in draft or
|
|
48
|
+
* rejected status"; `name` stays editable in every state. `submit_for_review` on a
|
|
49
|
+
* PAUSED, DISABLED or REVOKED template is accepted and answers 200, but opens no
|
|
50
|
+
* review and does not move the status — only the reviewer can reinstate it.
|
|
51
|
+
*
|
|
52
|
+
* Editing an APPROVED template is a live edit: the new content is stored
|
|
53
|
+
* immediately, and sending `submit_for_review: true` re-opens review, which
|
|
54
|
+
* returns the affected channels to PENDING so they stop sending until they are
|
|
55
|
+
* approved again. The previously approved content is never sent during re-review.
|
|
56
|
+
* Watch the per-channel `templates` webhook events rather than assuming the
|
|
57
|
+
* template-level status.
|
|
58
|
+
*
|
|
59
|
+
* Templates provisioned by Sent (light-onboarding templates, whose names carry the
|
|
60
|
+
* reserved `sent_` prefix) are read-only: every field is refused with 400
|
|
61
|
+
* VALIDATION*001 and the detail "This template is read-only. Only 'submit for
|
|
62
|
+
* review' is allowed.", and only `submit_for_review` is accepted. A `name`
|
|
63
|
+
* starting with `sent*` is refused for the same reason — the prefix is reserved.
|
|
38
64
|
*
|
|
39
65
|
* @example
|
|
40
66
|
* ```ts
|
|
@@ -120,12 +146,38 @@ export interface Template {
|
|
|
120
146
|
* Unique template identifier
|
|
121
147
|
*/
|
|
122
148
|
id?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Which consent keyword this template answers, when it is one of Sent's
|
|
151
|
+
* auto-replies: OPT_IN, OPT_OUT, HELP, or OTHER for a customer-defined keyword.
|
|
152
|
+
* Null for an ordinary template, and omitted from the response, so its presence is
|
|
153
|
+
* the answer to "is this an auto-reply".
|
|
154
|
+
*
|
|
155
|
+
* Deliberately not required, unlike CustomerId, even though the same "no single
|
|
156
|
+
* mapper" argument applies: NJsonSchema publishes a C# required member in the
|
|
157
|
+
* schema's required array, so the contract would have advertised a field this
|
|
158
|
+
* response omits for every ordinary template, and a generated client could refuse
|
|
159
|
+
* the common case. A compile-time guard is not worth a wrong published contract.
|
|
160
|
+
* Every mapping site sets it explicitly, and TemplateResponseSchemaTests pins the
|
|
161
|
+
* field as optional so it cannot be reintroduced.
|
|
162
|
+
*/
|
|
163
|
+
auto_reply_action?: string | null;
|
|
123
164
|
/**
|
|
124
165
|
* Template category: MARKETING, UTILITY, AUTHENTICATION
|
|
125
166
|
*/
|
|
126
167
|
category?: string;
|
|
127
168
|
/**
|
|
128
|
-
*
|
|
169
|
+
* The channels this template's definition can render on, in canonical order: sms,
|
|
170
|
+
* whatsapp, rcs.
|
|
171
|
+
*
|
|
172
|
+
* Derived from the definition's body, mirroring each channel's send-time fallback
|
|
173
|
+
* chain, so a channel is listed only when a real body would be produced for it:
|
|
174
|
+
* SMS reads sms ?? multiChannel, WhatsApp reads whatsapp ?? multiChannel, and RCS
|
|
175
|
+
* reads rcs ?? multiChannel ?? sms. A multiChannel body therefore reports all
|
|
176
|
+
* three, and the extra SMS fallback on RCS is why an sms/whatsapp pair reports RCS
|
|
177
|
+
* too.
|
|
178
|
+
*
|
|
179
|
+
* This says what the content can render on, not what may be sent: sending also
|
|
180
|
+
* needs the template approved for that channel.
|
|
129
181
|
*/
|
|
130
182
|
channels?: Array<string> | null;
|
|
131
183
|
/**
|
|
@@ -145,7 +197,8 @@ export interface Template {
|
|
|
145
197
|
*/
|
|
146
198
|
name?: string;
|
|
147
199
|
/**
|
|
148
|
-
* Template status:
|
|
200
|
+
* Template status: DRAFT, PENDING, APPROVED, REJECTED. A template created with
|
|
201
|
+
* submit_for_review: false starts as DRAFT and stays there until it is submitted.
|
|
149
202
|
*/
|
|
150
203
|
status?: string;
|
|
151
204
|
/**
|
|
@@ -158,31 +211,73 @@ export interface Template {
|
|
|
158
211
|
variables?: Array<string> | null;
|
|
159
212
|
}
|
|
160
213
|
/**
|
|
161
|
-
* Body section of a message template
|
|
214
|
+
* Body section of a message template.
|
|
215
|
+
*
|
|
216
|
+
* A body picks one of two authoring strategies, and mixing them is refused
|
|
217
|
+
* (TemplateDefinitionValidator.HaveValidChannelConfiguration): a shared
|
|
218
|
+
* multiChannel body on its own, or an explicit sms + whatsapp pair, both present.
|
|
219
|
+
*
|
|
220
|
+
* multiChannel together with sms or whatsapp is rejected, and so is sms or
|
|
221
|
+
* whatsapp on its own — every template is expected to be deliverable on every
|
|
222
|
+
* channel. rcs is the one true override: it may accompany either strategy to vary
|
|
223
|
+
* the copy, but cannot stand alone.
|
|
162
224
|
*/
|
|
163
225
|
export interface TemplateBody {
|
|
164
226
|
/**
|
|
165
|
-
*
|
|
166
|
-
* channel-specific content is provided
|
|
227
|
+
* The shared body, used for every channel. One half of the choice described above.
|
|
167
228
|
*/
|
|
168
229
|
multiChannel?: TemplateBodyContent | null;
|
|
169
230
|
/**
|
|
170
|
-
* RCS-specific
|
|
231
|
+
* RCS-specific copy that overrides the chosen strategy for RCS only. The one true
|
|
232
|
+
* override: optional on top of either strategy, but it cannot be the only body
|
|
233
|
+
* present. Its length cap is the higher one described on Template.
|
|
171
234
|
*/
|
|
172
235
|
rcs?: TemplateBodyContent | null;
|
|
173
236
|
/**
|
|
174
|
-
* SMS
|
|
237
|
+
* The SMS body. It does not override multiChannel, it replaces it.
|
|
175
238
|
*/
|
|
176
239
|
sms?: TemplateBodyContent | null;
|
|
177
240
|
/**
|
|
178
|
-
* WhatsApp
|
|
179
|
-
* messages
|
|
241
|
+
* The WhatsApp body. It does not override multiChannel, it replaces it.
|
|
180
242
|
*/
|
|
181
243
|
whatsapp?: TemplateBodyContent | null;
|
|
182
244
|
}
|
|
183
245
|
export interface TemplateBodyContent {
|
|
246
|
+
/**
|
|
247
|
+
* The body copy, with variables written as {{index:variable}}.
|
|
248
|
+
*
|
|
249
|
+
* Length cap depends on which channel this body belongs to:
|
|
250
|
+
* TemplateContentLimits.MaxBodyLength (1024) for multiChannel, sms and whatsapp —
|
|
251
|
+
* Meta's BODY limit, which a multiChannel body may be delivered under — and
|
|
252
|
+
* TemplateContentLimits.MaxRcsBodyLength (3072) for an rcs body, which never
|
|
253
|
+
* reaches Meta. The maxLength advertised on this schema is the 1024 one, because
|
|
254
|
+
* all four channel bodies share this single schema — an rcs body between the two
|
|
255
|
+
* is accepted.
|
|
256
|
+
*
|
|
257
|
+
* Meta requires every variable to carry surrounding context, so a body is refused
|
|
258
|
+
* unless it also satisfies all of the following (enforced by
|
|
259
|
+
* TemplateDefinitionValidator): At least one letter before the first variable and
|
|
260
|
+
* after the last — trailing punctuation such as "... {{1:variable}}." does not
|
|
261
|
+
* count. At least (2 × variable count) + 1 words once the placeholders are
|
|
262
|
+
* removed. No two variables adjacent with only whitespace between them. No leading
|
|
263
|
+
* or trailing newline, no more than two consecutive line breaks, and no more than
|
|
264
|
+
* four consecutive spaces.
|
|
265
|
+
*
|
|
266
|
+
* Example: "Hello {{0:variable}}! Welcome to {{1:variable}}. We are glad to have
|
|
267
|
+
* you on board." — two variables, so at least five words are required, and the
|
|
268
|
+
* copy after the final variable contains letters.
|
|
269
|
+
*/
|
|
184
270
|
template: string;
|
|
271
|
+
/**
|
|
272
|
+
* The type of body content — send "text". It is dropped from the stored definition
|
|
273
|
+
* when null, so a body posted without it is saved with no type key at all and the
|
|
274
|
+
* template editor has nothing to render the block from.
|
|
275
|
+
*/
|
|
185
276
|
type?: string | null;
|
|
277
|
+
/**
|
|
278
|
+
* The variables referenced by the body copy, one entry per {{index:variable}}
|
|
279
|
+
* placeholder.
|
|
280
|
+
*/
|
|
186
281
|
variables?: Array<TemplateVariable> | null;
|
|
187
282
|
}
|
|
188
283
|
/**
|
|
@@ -198,7 +293,13 @@ export interface TemplateButton {
|
|
|
198
293
|
*/
|
|
199
294
|
type: string;
|
|
200
295
|
/**
|
|
201
|
-
* The
|
|
296
|
+
* The button's identifier (1-based index), unique within the template.
|
|
297
|
+
*
|
|
298
|
+
* Omitting it is only safe for a template holding a single button. The field is a
|
|
299
|
+
* non-nullable int, so every button that leaves it out defaults to 0, and two such
|
|
300
|
+
* buttons are refused by the unique-id rule ("Button IDs must be unique"). Number
|
|
301
|
+
* them from 1 in the order they should appear — order matters on RCS, where only
|
|
302
|
+
* the first four buttons render.
|
|
202
303
|
*/
|
|
203
304
|
id?: number;
|
|
204
305
|
}
|
|
@@ -208,6 +309,19 @@ export interface TemplateButtonProps {
|
|
|
208
309
|
offerCode: string;
|
|
209
310
|
phoneNumber: string;
|
|
210
311
|
quickReplyType: string;
|
|
312
|
+
/**
|
|
313
|
+
* The button's label. Required for every button type, and capped at
|
|
314
|
+
* TemplateContentLimits.MaxButtonTextLength (25) characters.
|
|
315
|
+
*
|
|
316
|
+
* Meta accepts only static text here, so a label is refused when it contains a
|
|
317
|
+
* {{...}} variable placeholder, a newline, an emoji, or WhatsApp formatting markup
|
|
318
|
+
* (\*, \_, ~) — enforced by ApplyButtonLabelContentRules in
|
|
319
|
+
* TemplateButtonValidator. Meta reports all four as one error: "Buttons can't have
|
|
320
|
+
* any variables, newlines, emojis, or formatting characters."
|
|
321
|
+
*
|
|
322
|
+
* AUTHENTICATION OTP buttons are the exception: Meta auto-localizes their label
|
|
323
|
+
* from the template language, and the converter drops whatever text was sent.
|
|
324
|
+
*/
|
|
211
325
|
text: string;
|
|
212
326
|
url: string;
|
|
213
327
|
urlType: string;
|
|
@@ -228,7 +342,16 @@ export interface TemplateButtonProps {
|
|
|
228
342
|
*/
|
|
229
343
|
export interface TemplateDefinition {
|
|
230
344
|
/**
|
|
231
|
-
* Body section of a message template
|
|
345
|
+
* Body section of a message template.
|
|
346
|
+
*
|
|
347
|
+
* A body picks one of two authoring strategies, and mixing them is refused
|
|
348
|
+
* (TemplateDefinitionValidator.HaveValidChannelConfiguration): a shared
|
|
349
|
+
* multiChannel body on its own, or an explicit sms + whatsapp pair, both present.
|
|
350
|
+
*
|
|
351
|
+
* multiChannel together with sms or whatsapp is rejected, and so is sms or
|
|
352
|
+
* whatsapp on its own — every template is expected to be deliverable on every
|
|
353
|
+
* channel. rcs is the one true override: it may accompany either strategy to vary
|
|
354
|
+
* the copy, but cannot stand alone.
|
|
232
355
|
*/
|
|
233
356
|
body: TemplateBody;
|
|
234
357
|
/**
|
|
@@ -288,9 +411,26 @@ export interface TemplateHeader {
|
|
|
288
411
|
variables?: Array<TemplateVariable> | null;
|
|
289
412
|
}
|
|
290
413
|
export interface TemplateVariable {
|
|
414
|
+
/**
|
|
415
|
+
* The variable's name, and the key callers use for it in a send request's
|
|
416
|
+
* parameters object. Must start with a letter and hold only letters, digits and
|
|
417
|
+
* underscores.
|
|
418
|
+
*/
|
|
291
419
|
name: string;
|
|
292
420
|
props: TemplateVariable.Props;
|
|
421
|
+
/**
|
|
422
|
+
* One of variable, link or media. Decides which Props fields are required.
|
|
423
|
+
*/
|
|
293
424
|
type: string;
|
|
425
|
+
/**
|
|
426
|
+
* The variable's index, and the number its {{index:variable}} placeholder refers
|
|
427
|
+
* to.
|
|
428
|
+
*
|
|
429
|
+
* Omitting it is only safe for a section holding a single variable. The field is a
|
|
430
|
+
* non-nullable int, so every variable that leaves it out defaults to 0, and a
|
|
431
|
+
* section with two such variables is refused by the unique-id rule ("variables
|
|
432
|
+
* must have unique IDs"). Number them from 0 in the order they appear.
|
|
433
|
+
*/
|
|
294
434
|
id?: number;
|
|
295
435
|
}
|
|
296
436
|
export declare namespace TemplateVariable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,KAAK,WAAW,sBAAmB;AAC1C,OAAO,EAAE,UAAU,EAAE,+BAA4B;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,8BAA2B;AAE1F,OAAO,EAAE,cAAc,EAAE,uCAAoC;AAG7D;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,4BAAyB;AAC/C,OAAO,KAAK,WAAW,sBAAmB;AAC1C,OAAO,EAAE,UAAU,EAAE,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AI,CAAC;IAEvC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,OAAO,EACL,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,QAAQ,IAAI,QAAQ,EACzB,KAAK,YAAY,IAAI,YAAY,EACjC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,gBAAgB,IAAI,gBAAgB,EACzC,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,oBAAoB,IAAI,oBAAoB,GAClD,CAAC;CACH"}
|
package/resources/templates.js
CHANGED
|
@@ -15,7 +15,9 @@ class Templates extends resource_1.APIResource {
|
|
|
15
15
|
/**
|
|
16
16
|
* Creates a new message template with header, body, footer, and buttons. The
|
|
17
17
|
* template can be submitted for review immediately or saved as draft for later
|
|
18
|
-
* submission.
|
|
18
|
+
* submission. There is no `name` field on create — the display name is derived
|
|
19
|
+
* from the template's content and can be changed afterwards with
|
|
20
|
+
* `PUT /v3/templates/{id}`.
|
|
19
21
|
*
|
|
20
22
|
* @example
|
|
21
23
|
* ```ts
|
|
@@ -59,7 +61,31 @@ class Templates extends resource_1.APIResource {
|
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Updates an existing template's name, category, language, definition, or submits
|
|
62
|
-
* it for review.
|
|
64
|
+
* it for review. While the template is in review (status PENDING, or any channel
|
|
65
|
+
* awaiting a verdict) its definition, category and language are frozen and a
|
|
66
|
+
* resubmission is refused — those requests answer 409 CONFLICT_006. The display
|
|
67
|
+
* name stays editable throughout.
|
|
68
|
+
*
|
|
69
|
+
* `definition`, `category` and `language` are editable only from status DRAFT,
|
|
70
|
+
* REJECTED or APPROVED. An edit to any of them on a template in another state
|
|
71
|
+
* (PAUSED, DISABLED or REVOKED) is refused with 400 VALIDATION_001 and the detail
|
|
72
|
+
* "Template (except display name) cannot be updated unless it is in draft or
|
|
73
|
+
* rejected status"; `name` stays editable in every state. `submit_for_review` on a
|
|
74
|
+
* PAUSED, DISABLED or REVOKED template is accepted and answers 200, but opens no
|
|
75
|
+
* review and does not move the status — only the reviewer can reinstate it.
|
|
76
|
+
*
|
|
77
|
+
* Editing an APPROVED template is a live edit: the new content is stored
|
|
78
|
+
* immediately, and sending `submit_for_review: true` re-opens review, which
|
|
79
|
+
* returns the affected channels to PENDING so they stop sending until they are
|
|
80
|
+
* approved again. The previously approved content is never sent during re-review.
|
|
81
|
+
* Watch the per-channel `templates` webhook events rather than assuming the
|
|
82
|
+
* template-level status.
|
|
83
|
+
*
|
|
84
|
+
* Templates provisioned by Sent (light-onboarding templates, whose names carry the
|
|
85
|
+
* reserved `sent_` prefix) are read-only: every field is refused with 400
|
|
86
|
+
* VALIDATION*001 and the detail "This template is read-only. Only 'submit for
|
|
87
|
+
* review' is allowed.", and only `submit_for_review` is accepted. A `name`
|
|
88
|
+
* starting with `sent*` is refused for the same reason — the prefix is reserved.
|
|
63
89
|
*
|
|
64
90
|
* @example
|
|
65
91
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,sDAA0F;AAC1F,oDAAmD;AAEnD,oDAA8C;AAE9C;;;;GAIG;AACH,MAAa,SAAU,SAAQ,sBAAW;IACxC
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/resources/templates.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,sDAA0F;AAC1F,oDAAmD;AAEnD,oDAA8C;AAE9C;;;;GAIG;AACH,MAAa,SAAU,SAAQ,sBAAW;IACxC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAA4B,EAAE,OAAwB;QAC3D,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC1F,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE;YACxC,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC;gBACpB;oBACE,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;oBAC/E,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;iBACrE;gBACD,OAAO,EAAE,OAAO;aACjB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CACN,EAAU,EACV,SAAoD,EAAE,EACtD,OAAwB;QAExB,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,MA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