📖 Help Docs
🆕 ChatDaddy App Updates
📞 Contact Us
Table of content
🆕 Getting Started With ChatDaddy API
Read full REST API docs by clicking HERE
This is a language-neutral tutorial and the same requests can be incorporated into any framework using REST API calls. If you are using NodeJS or the browser, we’d recommend using the official typescript client, which you can find here
Step 1: Authenticating the APIs
Our API utilizes the refresh token/access token flow, very similar to o-auth. Refresh tokens are long-lived tokens & are immune to password changes, they prevent you from ever needing to enter the password in plaintext or store it in your code.
Note: The refresh token automatically becomes invalid after 14 Days of inactivity.
Using the refresh token, one can generate access tokens. These are JWT tokens and are valid for 1 hour. All of ChatDaddy's APIs can be accessed using this short-lived JWT access token. The access token's schema can be read about here.
❓FAQ
Step 2: Obtaining a refresh token
A refresh token can be generated using the API using your phone number & password, which you can find here. If you do not want to use the API, you can generate the refresh token from the ChatDaddy app too:
- Login & open ChatDaddy App from
https://app.chatdaddy.tech
- Navigate to `App Store & API` and then `API`, or you can click here
- Click the “Generate Refresh Token” button
- Enter your password in the modal and you should see your new refresh token. It would look something like:
2fe11749-5e25-45b6-b679-d4395bcb2252
- Also, make note of the team ID on the page — you will need it to generate access tokens. It would like
f52fc4a7-e27d-40dc-abb8-b601ec45gf4e
You can store this refresh token as a secret in your project, and use it to generate access tokens for all your ChatDaddy API calls now
Step 3: Generating access tokens
With your refresh token & team ID, you can now make a request to the ChatDaddy servers and generate an access token:
curl --request POST \
--url https://api-teams.chatdaddy.tech/token \
--header 'Content-Type: application/json' \
--data '{
"refreshToken": "2fe11749-5e25-45b6-b679-d4395bcb2252",
"teamId": "f52fc4a7-e27d-40dc-abb8-b601ec45gf4e"
}'
Of course, you would replace the “refreshToken” & “teamId” fields here with your own
The response would look something like:
{
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzY2..."
}
This access token can now be used to access the APIs, the token will last for a short while before you will have to generate a new token.
Step 4 : Accessing the API via Stoplight
- Using the access token, you can make API calls via Stoplight or use cURL or any framework of your choice
- Let’s look at how to send a message via stoplight
- Navigate to the “Send a message” page, or click here
- In the Auth section, input “Token” as “Bearer <access token here>”
- Now, we’ll fill in the other parameters, the important parameters are:
- accountId: ChatDaddy allows multiple WhatsApp channels in a single team, this account ID takes in the ID of the channel you want to send the message from. Set to “random” to use any channel in your account.
- To find the ID of a channel, go to https://app.chatdaddy.tech
- Expand the nav bar & click on your name in the top right corner; Click “Manage Channels”
- You will find all the channels there and can copy the ID from there. The ID of the channel would look like
acc_23552c45-7bbd-5033-c1_0000
- Alternatively, you can use the API to fetch all channels in your account. See here for the API
- chatId: ID of the person you want to send the message to, which can be a phone number. Country code required
- Body: In the request body, a sample “Hello there” text has been provided. Feel free to change to something of your choice. The full message request schema can be found on the API page itself
An example request looks like this:
Other Cases
- I have more than 1 channel