Requests
See how to send messages, and query informations
After you got a token to request, you can start to sending requests.
All requests happen in a single endpoint changing the method and params in the body.
Let's start with a simple request to send a text message.
There's a lib for nodejs here: Click here
Important Information
All our endpoints expect and returns JSONs, you can test it using a tool like Postman or Insominia.
Endpoint: [POST] https://api.whats2api.com/connections/request
Headers:
- Content-Type: application/json
- Accept: application/json
- Authorization: Bearer YOUR_TOKEN_HERE
Body:
{ "connectionId": "The id of the connection you want to send the message", "method": "sendMessage", "params": [ "[email protected]", { "text": "Hi! This was sent using Whats2API" } ] }
Response
Which you will want to use 'accessToken as your token'
{ "error": false, "sucess": true, "result": { "messageStubParameters": [], "labels": [], "userReceipt": [], "reactions": [], "pollUpdates": [], "key": { "remoteJid": "[email protected]", "fromMe": true, "id": "THE_MESSAGE_ID" }, "message": { "extendedTextMessage": { "text": "Hi! This was sent using Whats2API" } }, "messageTimestamp": { "low": 1702671627, "high": 0, "unsigned": true }, "status": 1 } }
You problably want to save the ID in the message, to execute delete, query, edit, reply and others.
Explanation
The method, is what the connection will execute, and the parameters are each of the expected arguments which the function expects.
The method, is what the connection will execute, and the parameters are each of the expected arguments which the function expects.
More examples and methods
There's a lot which can be done using your connection, here's a list of all the methods, and it's expected parameters.