@raylongsolutions/saaselixir 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/openapi.yaml ADDED
@@ -0,0 +1,360 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: SaasElixir API
4
+ version: 1.0.0
5
+ description: |
6
+ Send WhatsApp template messages, build chatbots and automations by describing them, and receive delivery callbacks from your own software.
7
+ Make a key on the API page of your account. Keys start with `sxe_`. Keep them on your server.
8
+ A message sent twice with the same `reference` goes out once, so it is always safe to repeat a send after a timeout.
9
+ contact: { name: Raylong Solutions, email: support@raylongsolutions.com }
10
+ license: { name: MIT }
11
+ servers:
12
+ - url: https://saaselixir.com
13
+ security:
14
+ - bearer: []
15
+ paths:
16
+ /api/v1/messages:
17
+ get:
18
+ operationId: getMessageByReference
19
+ summary: Where one message stands, by the reference you sent it with
20
+ parameters: [ { name: reference, in: query, required: true, schema: { type: string } } ]
21
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' } }
22
+ post:
23
+ operationId: sendMessage
24
+ summary: Send a template message, or words to a chat that is open
25
+ description: Needs the Growth plan. Opt-outs, the allowed list and the daily limit apply. Quiet hours do not.
26
+ requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/SendMessage' } } } }
27
+ responses:
28
+ '200': { description: Accepted, content: { application/json: { schema: { $ref: '#/components/schemas/SendResult' } } } }
29
+ '401': { $ref: '#/components/responses/Error' }
30
+ '402': { $ref: '#/components/responses/Error' }
31
+ '403': { $ref: '#/components/responses/Error' }
32
+ '409': { $ref: '#/components/responses/Error' }
33
+ '422': { $ref: '#/components/responses/Error' }
34
+ /api/v1/templates:
35
+ get:
36
+ operationId: listTemplates
37
+ summary: Your number's templates
38
+ parameters:
39
+ - { name: channelId, in: query, schema: { type: string } }
40
+ - { name: status, in: query, schema: { type: string, example: APPROVED } }
41
+ responses: { '200': { description: OK }, '422': { $ref: '#/components/responses/Error' } }
42
+ /api/v1/balance:
43
+ get:
44
+ operationId: getBalance
45
+ summary: What each number holds and whether it can send
46
+ responses: { '200': { description: OK } }
47
+ /api/v1/messages/{id}:
48
+ get:
49
+ operationId: getMessage
50
+ summary: Where one message stands
51
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
52
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' } }
53
+ /api/v1/contacts:
54
+ get:
55
+ operationId: listOrFindContacts
56
+ summary: One contact by phone, or a page of contacts
57
+ parameters:
58
+ - { name: phone, in: query, schema: { type: string } }
59
+ - { name: tag, in: query, schema: { type: string } }
60
+ - { name: limit, in: query, schema: { type: integer, maximum: 100, default: 50 } }
61
+ - { name: after, in: query, schema: { type: integer } }
62
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' } }
63
+ post:
64
+ operationId: addContact
65
+ summary: Add a contact, or find the one already there
66
+ description: Tags given are added either way. An existing name is left as it is. Safe to repeat.
67
+ responses: { '200': { description: Already there }, '201': { description: Added }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
68
+ /api/v1/contacts/{id}:
69
+ get:
70
+ operationId: getContact
71
+ summary: One contact
72
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
73
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' } }
74
+ /api/v1/contacts/{id}/tags:
75
+ post:
76
+ operationId: changeContactTags
77
+ summary: Add and remove tags by name
78
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
79
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
80
+ /api/v1/optouts:
81
+ get:
82
+ operationId: checkOptOut
83
+ summary: Has this person asked not to be messaged
84
+ parameters: [ { name: phone, in: query, required: true, schema: { type: string } } ]
85
+ responses: { '200': { description: OK } }
86
+ post:
87
+ operationId: addOptOut
88
+ summary: Record that someone does not want messages
89
+ description: Every send to them is refused from then on. It cannot be undone through the API.
90
+ responses: { '200': { description: Recorded } }
91
+ /api/v1/audiences:
92
+ get:
93
+ operationId: listAudiences
94
+ summary: Your saved lists of people
95
+ responses: { '200': { description: OK } }
96
+ post:
97
+ operationId: createAudience
98
+ summary: Save a list of people to send campaigns to
99
+ description: Up to 5000 people a call; add the rest with the members call. `consent` must be true, confirming these people agreed to receive WhatsApp messages from you.
100
+ requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/AudienceCreate' } } } }
101
+ responses: { '201': { description: Saved }, '413': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
102
+ /api/v1/audiences/{id}:
103
+ get:
104
+ operationId: getAudience
105
+ summary: One list
106
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
107
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' } }
108
+ /api/v1/audiences/{id}/members:
109
+ post:
110
+ operationId: addAudienceMembers
111
+ summary: Add people to a list
112
+ description: Someone already in the list is updated, not repeated. `consent` must be true.
113
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
114
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
115
+ /api/v1/broadcasts:
116
+ get:
117
+ operationId: listBroadcasts
118
+ summary: Campaigns sent to a list
119
+ description: "Called broadcasts because campaigns in this API already means a label for single sends."
120
+ responses: { '200': { description: OK } }
121
+ post:
122
+ operationId: createBroadcast
123
+ summary: Make a campaign draft from a template and a list. Nothing is sent.
124
+ requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/BroadcastInput' } } } }
125
+ responses: { '201': { description: Draft made }, '404': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
126
+ /api/v1/broadcasts/preview:
127
+ post:
128
+ operationId: previewBroadcast
129
+ summary: Who would get it, what it costs and how it reads, without making it
130
+ requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/BroadcastInput' } } } }
131
+ responses: { '200': { description: OK } }
132
+ /api/v1/broadcasts/{id}:
133
+ get:
134
+ operationId: getBroadcast
135
+ summary: How a campaign is going
136
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
137
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' } }
138
+ /api/v1/broadcasts/{id}/recipients:
139
+ get:
140
+ operationId: listBroadcastRecipients
141
+ summary: The people of a campaign and what happened to each
142
+ parameters:
143
+ - { name: id, in: path, required: true, schema: { type: integer } }
144
+ - { name: state, in: query, schema: { type: string, enum: [pending, sent, delivered, read, failed, left_out] } }
145
+ - { name: limit, in: query, schema: { type: integer, maximum: 500, default: 100 } }
146
+ - { name: after, in: query, schema: { type: integer } }
147
+ responses: { '200': { description: OK } }
148
+ /api/v1/broadcasts/{id}/send:
149
+ post:
150
+ operationId: sendBroadcast
151
+ summary: Send a draft now
152
+ description: "`confirmCount` is required: the number of people you checked. If the list changed since, nothing is sent (code count_mismatch). A campaign can be sent once."
153
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
154
+ responses: { '200': { description: Sending }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
155
+ /api/v1/broadcasts/{id}/schedule:
156
+ post:
157
+ operationId: scheduleBroadcast
158
+ summary: Send at a later time
159
+ description: "`at` is a time between one minute and 60 days from now. `confirmCount` is required."
160
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
161
+ responses: { '200': { description: Scheduled }, '422': { $ref: '#/components/responses/Error' } }
162
+ /api/v1/broadcasts/{id}/pause:
163
+ post:
164
+ operationId: pauseBroadcast
165
+ summary: Pause a campaign that is sending
166
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
167
+ responses: { '200': { description: Paused } }
168
+ /api/v1/broadcasts/{id}/resume:
169
+ post:
170
+ operationId: resumeBroadcast
171
+ summary: Resume a paused campaign
172
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
173
+ responses: { '200': { description: Sending } }
174
+ /api/v1/broadcasts/{id}/cancel:
175
+ post:
176
+ operationId: cancelBroadcast
177
+ summary: Stop a campaign for good
178
+ description: Nobody not yet sent to will be. Messages already sent stay sent.
179
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
180
+ responses: { '200': { description: Cancelled } }
181
+ /api/v1/campaigns/{code}/send:
182
+ post:
183
+ operationId: sendInCampaign
184
+ summary: Send under an API campaign
185
+ description: The campaign is made on the API page. A paused campaign answers `paused`.
186
+ parameters: [ { name: code, in: path, required: true, schema: { type: string } } ]
187
+ requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/SendMessage' } } } }
188
+ responses:
189
+ '200': { description: Accepted, content: { application/json: { schema: { $ref: '#/components/schemas/SendResult' } } } }
190
+ '404': { $ref: '#/components/responses/Error' }
191
+ '409': { $ref: '#/components/responses/Error' }
192
+ /api/v1/chatbots:
193
+ get:
194
+ operationId: listChatbots
195
+ summary: List chatbots
196
+ responses: { '200': { description: OK } }
197
+ post:
198
+ operationId: createChatbot
199
+ summary: Build a chatbot from a description
200
+ description: Charged to the AI wallet.
201
+ requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/BuildInput' } } } }
202
+ responses: { '201': { description: Created } }
203
+ /api/v1/chatbots/{id}:
204
+ get:
205
+ operationId: getChatbot
206
+ summary: One chatbot
207
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
208
+ responses: { '200': { description: OK }, '404': { $ref: '#/components/responses/Error' } }
209
+ /api/v1/chatbots/{id}/edit:
210
+ post:
211
+ operationId: editChatbot
212
+ summary: Change a chatbot by describing the change
213
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
214
+ responses: { '200': { description: OK } }
215
+ /api/v1/chatbots/{id}/publish:
216
+ post:
217
+ operationId: publishChatbot
218
+ summary: Make the draft live
219
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
220
+ responses: { '200': { description: Published }, '422': { description: Unfinished, with a list of problems } }
221
+ /api/v1/automations:
222
+ get:
223
+ operationId: listAutomations
224
+ summary: List automations
225
+ responses: { '200': { description: OK } }
226
+ post:
227
+ operationId: createAutomation
228
+ summary: Build an automation from a description
229
+ requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/BuildInput' } } } }
230
+ responses: { '201': { description: Created } }
231
+ /api/v1/automations/{id}/edit:
232
+ post:
233
+ operationId: editAutomation
234
+ summary: Change an automation by describing the change
235
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
236
+ responses: { '200': { description: OK } }
237
+ /api/v1/automations/{id}/publish:
238
+ post:
239
+ operationId: publishAutomation
240
+ summary: Make the draft live
241
+ parameters: [ { name: id, in: path, required: true, schema: { type: integer } } ]
242
+ responses: { '200': { description: Published }, '422': { description: Unfinished, with a list of problems } }
243
+ webhooks:
244
+ messageEvent:
245
+ post:
246
+ summary: A message moved on
247
+ description: |
248
+ Sent to the address saved on the API page. Header `x-saaselixir-signature` is the hex SHA-256 HMAC of the raw body, made with your `whsec_` secret.
249
+ A call that is not answered with 2xx is tried again over about a day.
250
+ requestBody: { content: { application/json: { schema: { $ref: '#/components/schemas/MessageEvent' } } } }
251
+ responses: { '200': { description: Got it } }
252
+ customerReply:
253
+ post:
254
+ summary: A customer wrote to you
255
+ description: |
256
+ Sent only when customer replies are switched on beside your address on the API page. Same signature as message events.
257
+ It can arrive more than once; `wamid` is the same each time.
258
+ requestBody: { content: { application/json: { schema: { $ref: '#/components/schemas/ReplyEvent' } } } }
259
+ responses: { '200': { description: Got it } }
260
+ components:
261
+ securitySchemes:
262
+ bearer: { type: http, scheme: bearer, description: 'Your API key, sxe_...' }
263
+ responses:
264
+ Error: { description: Refused, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
265
+ schemas:
266
+ Error:
267
+ type: object
268
+ properties:
269
+ error: { type: string }
270
+ code: { type: string, description: 'For example no_balance, opted_out, template_not_found, plan_expired, plan_feature, bad_number, bad_reference, bad_message, no_number, paused, no_campaign.' }
271
+ SendMessage:
272
+ type: object
273
+ required: [to]
274
+ properties:
275
+ to: { type: string, example: '919876543210' }
276
+ template: { type: string }
277
+ language: { type: string, default: en }
278
+ values: { type: array, items: { type: string } }
279
+ header: { type: string }
280
+ buttons: { type: object, additionalProperties: { type: string } }
281
+ text: { type: string }
282
+ reference: { type: string, maxLength: 60 }
283
+ channelId: { type: string }
284
+ SendResult:
285
+ type: object
286
+ properties:
287
+ messageId: { type: integer }
288
+ status: { type: string }
289
+ reference: { type: string }
290
+ repeated: { type: boolean }
291
+ BuildInput:
292
+ type: object
293
+ required: [description]
294
+ properties:
295
+ description: { type: string, minLength: 10, maxLength: 4000 }
296
+ name: { type: string }
297
+ channelId: { type: string }
298
+ publish: { type: boolean }
299
+ AudienceCreate:
300
+ type: object
301
+ required: [name, consent, members]
302
+ properties:
303
+ name: { type: string }
304
+ consent: { type: boolean, enum: [true] }
305
+ country: { type: string, default: '91' }
306
+ members:
307
+ type: array
308
+ maxItems: 5000
309
+ items:
310
+ type: object
311
+ required: [phone]
312
+ properties:
313
+ phone: { type: string }
314
+ name: { type: string }
315
+ fields: { type: object, additionalProperties: { type: string } }
316
+ BroadcastInput:
317
+ type: object
318
+ required: [title, template, audienceId, mapping]
319
+ properties:
320
+ title: { type: string, maxLength: 100 }
321
+ channelId: { type: string }
322
+ template: { type: object, required: [name], properties: { name: { type: string }, language: { type: string, default: en } } }
323
+ audienceId: { type: integer }
324
+ trackClicks: { type: boolean }
325
+ mapping:
326
+ type: object
327
+ properties:
328
+ body: { type: array, description: 'One value for each blank of the template body.', items: { $ref: '#/components/schemas/Value' } }
329
+ button: { $ref: '#/components/schemas/Value' }
330
+ header: { type: object, properties: { link: { type: string }, text: { $ref: '#/components/schemas/Value' } } }
331
+ Value:
332
+ type: object
333
+ description: A detail of each person (`field`, with an optional `fallback`), or the same `text` for everyone.
334
+ properties:
335
+ field: { type: string }
336
+ text: { type: string }
337
+ fallback: { type: string }
338
+ ReplyEvent:
339
+ type: object
340
+ properties:
341
+ event: { type: string, enum: [message.received] }
342
+ wamid: { type: string }
343
+ from: { type: string }
344
+ name: { type: string }
345
+ channelId: { type: string }
346
+ type: { type: string }
347
+ text: { type: string }
348
+ button: { type: object, properties: { id: { type: string }, title: { type: string } } }
349
+ mediaId: { type: string }
350
+ replyToMessageId: { type: integer }
351
+ replyToReference: { type: string }
352
+ at: { type: string, format: date-time }
353
+ MessageEvent:
354
+ type: object
355
+ properties:
356
+ event: { type: string, enum: [message.sent, message.delivered, message.read, message.failed] }
357
+ messageId: { type: integer }
358
+ reference: { type: string }
359
+ at: { type: string, format: date-time }
360
+ error: { type: string }
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "@raylongsolutions/saaselixir",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "Node.js SDK for SaasElixir: send WhatsApp template messages, build chatbots and automations, and verify delivery callbacks from your own software.",
5
+ "keywords": [
6
+ "whatsapp",
7
+ "whatsapp business",
8
+ "whatsapp api",
9
+ "template message",
10
+ "chatbot",
11
+ "automation",
12
+ "webhook",
13
+ "india",
14
+ "saaselixir"
15
+ ],
16
+ "homepage": "https://git.raylongsolutions.com/raylongsolutions/saaselixir-node",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://git.raylongsolutions.com/raylongsolutions/saaselixir-node.git"
20
+ },
21
+ "bugs": {
22
+ "email": "support@raylongsolutions.com"
23
+ },
24
+ "author": "Raylong Solutions <support@raylongsolutions.com>",
25
+ "license": "MIT",
26
+ "type": "module",
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "sideEffects": false,
31
+ "main": "./dist/cjs/index.js",
32
+ "module": "./dist/esm/index.js",
33
+ "types": "./dist/esm/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "import": {
37
+ "types": "./dist/esm/index.d.ts",
38
+ "default": "./dist/esm/index.js"
39
+ },
40
+ "require": {
41
+ "types": "./dist/cjs/index.d.ts",
42
+ "default": "./dist/cjs/index.js"
43
+ }
44
+ }
45
+ },
46
+ "files": [
47
+ "dist",
48
+ "README.md",
49
+ "LICENSE",
50
+ "CHANGELOG.md",
51
+ "openapi.yaml"
52
+ ],
53
+ "scripts": {
54
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && tsc -p tsconfig.build.json --module commonjs --moduleResolution node10 --outDir dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
55
+ "test": "vitest run",
56
+ "typecheck": "tsc -p tsconfig.json",
57
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
58
+ },
59
+ "devDependencies": {
60
+ "@types/node": "^22.0.0",
61
+ "typescript": "^5.6.0",
62
+ "vitest": "^2.1.0"
63
+ }
64
+ }