Authentication

POST: https://services.tochat.be/api/login_check

Authentication is via the JSON Web Tokens (JWT) system. You can read more here in the official documentation.

The credentias are send in json format:

{"username":"yourusername","password":"yourpassword"}

And the token is returned

{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1Nzg5MDQyNjYsImV4cCI6MTU3ODkwNzg2Niwicm9sZXMiOlsiUk9MRV9VU0VSIl0sInVzZXJuYW1lIjoid2FyZGF6b0BnbWFpbC5jb20ifQ.hBO_KERLPV_2LJsVksVfNHVxNB98X_DTRApEHcXvIGJGaSpNs0o7ucas2bZ59ev5eIC5KFUPOXqRvIGD0c0JFxc8jVKzBH94jijmIWkJ_VbWdGMuU-ulmVaV6WljrjVZ9Kxg5GSbUWNPXvP9Ml-kHlckoPP5xsh4PEK7XZqPQvzLTovAk5d5kNYoG6MVa88Mc9bmRAkBjzuHsuctTaa1ncP-qXwkQy_W4ZZMBT3IGredyf8U0k3r1IxrE8UsHstbmiuA6GktsWKIZY83hOzZZNYiMgKROjjegA4fHq8iNtKbo7AfaxEj5HgL4kHIXJxkOUy9sTjaOsBZxgWr74nj256cZNvQ1DK7Qg95yZmOix3SN_0TgP5JKafKn4m-2E_akzsc1jaihwMcgC1cHenyzRkpTfRhEzO1FXhSMX3wHB0lYjWUwxFEc099Q3CP56T7GIkVdj2sXawztfmBbKhbvGvZnS_gfZbOyhO4brJ19Cq4bTaa12aWTxcH9_98k6KoJWPunwJ9yFD5bzwL780AP0jyPZ0LX81EURQsSHQmoAWd9m-M8k3oMt8gRoLBKhLsO6n_stxc_RLx3TpwLuKpJni57pcmSXNG_FWkjZoH8QP73WMy2HO4sQJTjT8YZcrxl65J7wyyFVL7z8K0y7OpqYZoOgPziV_AAMx1RtHa2mE"
}

This token must be attached to the header in future calls. Note, it is time limited - it does not last forever. Also note the the content type application/json must be specified in the header

CURL

We have provided an example in curt to get you started:

curl -X POST \
  https://services.tochat.be/api/login_check \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: d3452f00-12bc-4f41-94d2-2810e157e7e2' \
  -H 'cache-control: no-cache' \
  -d '{"username":"username","password":"password"}'

Inserting a new clients and whatsapps

POST https://services.tochat.be/api/business/insert/

A json object in the following format must be sent via POST

{
    "name": "e765765",
    "whatsapps": [
        {
            "number": "34622814642",
            "name": "xxxxxxx",

            "optimes":[
            	{"day":"MO","availableFrom":"22:00:00","availableUntil":"22:00:00"},
            	{"day":"TU","availableFrom":"22:00:00","availableUntil":"22:00:00"}
            	],
            "id": "o132f4a76-56b9-413e-8501-0f53df025b0-ogg",
            "active": true,
            "iconUrl": "https://www.xxx.com/x.jpg",
            "post": "myjob"

        },
        {
            "number": "34622814642",
            "name": "sdsd",
            "optimes":[
            	{"day":"MO","availableFrom":"22:00:00","availableUntil":"22:00:00"},
            	{"day":"TU","availableFrom":"22:00:00","availableUntil":"22:00:00"}
            	],
            "active": true,
            "iconUrl": "https://www.xxx.com/x.jpg",
            "post": "myjob"
        }
    ],
    "color": "#ffffff",
    "textColor": "#ffffff",
    "rightpos": true,
    "active": true,
    "isopen": false,
    "buttonMessage": "wqew",
    "widgetMessage": "qwe",
    "iconUrl": "https://www.xxx.com/x.jpg"
}
            

We have provided an example in curt to get you started:

  curl -X POST \
  https://services.tochat.be/api/business/insert \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhGciOiJSUzI1NiJ9.eyJpYXQiOjE1ODAxMTE4NjAsImV4cCI6MTU4MDExNTQ2MCwicm9sZXMiOlsiUk9MRV9VU0VSIiwiUk9MRV9BRE1JTiJdLCJ1c2VybmFtZSI6IndhcmRhem9AZ21haWwuY29tIn0.CHsNcCHOecggVsBIf4AkP_qcb6RPKmRkKF42tWHs48aFl4ojNNDxxtMWYHqMJzFvWqbKC5MYyHeydbCxmkRIYgrLbCbaTHNVEnALPVdkaQ6RSDMnTRLix9F3hJB4ky1QmV2130GKBLdwIbIq0FQActcEH71asPeeLPPTRrgfLH2JPUXpZGWpijmqYsy4nWeTLc3WxFpiwqKogK_ybMcfM6b7JYDvWIZtKKqBBUzR1aRjtRiyZ9zNih5tVmNLOBAq7oeXOAABww_1dHLHMIT_IYrVMjTWbVVJL1w1P3b_zaDAF2-QU2iKQR4i_XXEP4mm5X-c879kjCBCMTXalqMGXXVZOUEA2MryiNq-LVtgUNtz-g1W3KT0xoBKJ5JFFC5gCCXb-uIMMMp32Qz5Smroonux7ntWk14Usqi2qePQ66vRvJZb07rNERUHMQzc4Oljk_sJfabucuYQ4GrIyRtkbKBM6f6MY8Gap-l7TKR0b0r23rVbllNWmXCNC3JL8j2JbogqUC3XiXqdWPV9te2wCmZR8XKc115yPeEM1CAZ0Mm7PRgiJiQI-jlLpDmtMst_FOoEqip7kMNgFlMREPv8b6lTpjJCLOdWVfizCFtutioq6gZbpUOkftRomIaY2aQbFPxLnGSnaV1axGlA8dtA1Nt6KpLT6VdQViZj4089sUo' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 2593a616-b46b-4321-ba5d-de7c03b5f9e0' \
  -H 'cache-control: no-cache' \
  -d '{
    "name": "e765765",
    "whatsapps": [
        {
            "number": "34622814642",
            "name": "xxxxxxx",

            "optimes":[
            	{"day":"MO","availableFrom":"22:00:00","availableUntil":"22:00:00"},
            	{"day":"TU","availableFrom":"22:00:00","availableUntil":"22:00:00"}
            	],
            "id": "o132f4a76-56b9-413e-8501-0f53df025b0-ogg",
            "active": true,
            "iconUrl": "https://www.xxx.com/x.jpg",
            "post": "myjob"

        },
        {
            "number": "34622814642",
            "name": "sdsd",
            "optimes":[
            	{"day":"MO","availableFrom":"22:00:00","availableUntil":"22:00:00"},
            	{"day":"TU","availableFrom":"22:00:00","availableUntil":"22:00:00"}
            	],
            "active": true,
            "iconUrl": "https://www.xxx.com/x.jpg",
            "post": "myjob"
        }
    ],
    "color": "#ffffff",
    "textColor": "#ffffff",
    "rightpos": true,
    "active": true,
    "isopen": false,
    "buttonMessage": "wqew",
    "widgetMessage": "qwe",
    "iconUrl": "https://www.xxx.com/x.jpg"
}'
                

Please note that the reponse incudes the UUID of the business (ACCOUNT:ID) and the whatsapp operators. You will need both these for updating the entity

{
    {
    "status": true,
    "data": {
        "id": "36a3f584-9c18-4b52-8c50-9849414dd415",
        "name": "e765765",
        "whatsapps": [
            {
                "id": "9dccde29-79d8-46f4-8801-e41589484614",
                "number": "34622814642",
                "name": "xxxxxxx",
                "active": true,
                "iconUrl": "https://www.xxx.com/x.jpg",
                "post": "myjob",
                "optimes": [
                    {
                        "day": "MO",
                        "availableFrom": "22:00:00",
                        "availableUntil": "22:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "22:00:00"
                    }
                ]
            },
            {
                "id": "14495743-4a6b-424f-8dfc-ef013d3509aa",
                "number": "34622814642",
                "name": "sdsd",
                "active": true,
                "iconUrl": "https://www.xxx.com/x.jpg",
                "post": "myjob",
                "optimes": [
                    {
                        "day": "MO",
                        "availableFrom": "22:00:00",
                        "availableUntil": "22:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "22:00:00"
                    }
                ]
            }
        ],
        "color": "#ffffff",
        "rightpos": true,
        "active": true,
        "isopen": false,
        "buttonMessage": "wqew",
        "widgetMessage": "qwe",
        "iconUrl": "https://www.xxx.com/x.jpg",
        "textColor": "#ffffff"
    }
}
}

Updating

PUT https://services.tochat.be/api/business/update/ACCOUT_ID

A json object in the following format must be sent via PUT

{   "id": "uuid"
    "name": "Business name",
    "whatsapps": [
        {
            "number": telephone number,
            "name": "operator name",
            "optimes": [
                {
                    "day": "MO,TU,WE,TH,FR,SA or SU",
                    "availableFrom": "availability from in time format 'HH:MM:SS",
                    "availableUntil": "availability until in time format 'HH:MM:SS"
                },
                {
                    "day": "MO,TU,WE,TH,FR,SA or SU",
                    "availableFrom": "availability from in time format 'HH:MM:SS",
                    "availableUntil": "availability from untill time format 'HH:MM:SS"
                }
            ]
            "id": "operator ID - obilgatory if updating. Leave blank for new operators.",
            "active": true/false,
            "icon_url": "Icon url  - must be valid URL"

        },
    ],
    "color": "the background color in hex format #ffffff",
    "rightpos": true/false - position to the right or left,
    "active": true/false - is active or inactive,
    "isopen": true/false - widget os open or closed by default,
    "buttonMessage": "The message on the button",
    "widgetMessage": "The message on the widget",
    "iconUrl": "Icon url  - must be valid URL"
}
            

Note, the authentification token must be sent as a bearer token in the header. For a complete example please refer to the curl example below

CURL

We have provided an example in curt to get you started:

  curl -X PUT \
  https://services.tochat.be/api/business/update/948b6088-42cf-4eb3-9df4-da26175c27aa \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1ODAxMTE4NjAsImV4cCI6MTU4MDExNTQ2MCwicm9sZXMiOlsiUk9MRV9VU0VSIiwiUk9MRV9BRE1JTiJdLCJ1c2VybmFtZSI6IndhcmRhem9AZ21haWwuY29tIn0.CHsNcCHOecggVsBIf4AkP_qcb6RPKmRkKF42tWHs48aFl4ojNNDxxtMWYHqMJzFvWqbKC5MYyHeydbCxmkRIYgrLbCbaTHNVEnALPVdkaQ6RSDMnTRLix9F3hJB4ky1QmV2130GKBLdwIbIq0FQActcEH71asPeeLPPTRrgfLH2JPUXpZGWpijmqYsy4nWeTLc3WxFpiwqKogK_ybMcfM6b7JYDvWIZtKKqBBUzR1aRjtRiyZ9zNih5tVmNLOBAq7oeXOAABww_1dHLHMIT_IYrVMjTWbVVJL1w1P3b_zaDAF2-QU2iKQR4i_XXEP4mm5X-c879kjCBCMTXalqMGXXVZOUEA2MryiNq-LVtgUNtz-g1W3KT0xoBKJ5JFFC5gCCXb-uIMMMp32Qz5Smroonux7ntWk14Usqi2qePQ66vRvJZb07rNERUHMQzc4Oljk_sJfabucuYQ4GrIyRtkbKBM6f6MY8Gap-l7TKR0b0r23rVbllNWmXCNC3JL8j2JbogqUC3XiXqdWPV9te2wCmZR8XKc115yPeEM1CAZ0Mm7PRgiJiQI-jlLpDmtMst_FOoEqip7kMNgFlMREPv8b6lTpjJCLOdWVfizCFtutioq6gZbpUOkftRomIaY2aQbFPxLnGSnaV1axGlA8dtA1Nt6KpLT6VdQViZj4089sUo' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 473aa85e-f427-4937-9e23-c7282f9441f8' \
  -H 'cache-control: no-cache' \
  -d '{
        "id": "cfe47029-4a85-4253-854c-d21f8a892ce2",
        "name": "Acme Ltd",
        "whatsapps": [
            {
                "id": "7653e135-530f-4963-8e17-8319090207c3",
                "number": "34622814642",
                "name": "Ms Y",
                "active": true,
                "iconUrl": "https://widget.tochat.be/face.png",
                "post": "Sales",
                "optimes": [
                    {
                        "day": "MO",
                        "availableFrom": "22:00:00",
                        "availableUntil": "23:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "00:00:00"
                    }
                ]
            },
            {
                "id": "82b76720-a646-4066-a475-dfb2a66950d7",
                "number": "34622814642",
                "name": "MR X",
                "active": true,
                "iconUrl": "https://widget.tochat.be/face.png",
                "post": "RRHH",
                "optimes": [
                    {
                        "day": "SA",
                        "availableFrom": "14:00:00",
                        "availableUntil": "23:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "00:00:00"
                    }
                ]
            }
        ],
        "color": "#25d366",
        "rightpos": true,
        "active": true,
        "isopen": false,
        "buttonMessage": "Click to whatsapp",
        "widgetMessage": "Hola!",
        "iconUrl": "https://widget.tochat.be/face.png",
        "textColor": "#ffffff"
    }'
                

Response - ok:

{
    "status": true,
    "data": {
        "id": "948b6088-42cf-4eb3-9df4-da26175c27aa",
        "name": "Acme Ltd",
        "whatsapps": [
            {
                "id": "a602b203-bdf0-46d6-a443-1149dcda09ef",
                "number": "34622814642",
                "name": "Ms Y",
                "active": true,
                "iconUrl": "https://widget.tochat.be/face.png",
                "post": "Sales",
                "optimes": [
                    {
                        "day": "MO",
                        "availableFrom": "22:00:00",
                        "availableUntil": "23:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "00:00:00"
                    }
                ]
            },
            {
                "id": "719ec638-dc05-4542-8761-d91529ccd265",
                "number": "34622814642",
                "name": "MR X",
                "active": true,
                "iconUrl": "https://widget.tochat.be/face.png",
                "post": "RRHH",
                "optimes": [
                    {
                        "day": "SA",
                        "availableFrom": "14:00:00",
                        "availableUntil": "23:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "00:00:00"
                    }
                ]
            }
        ],
        "color": "#25d366",
        "rightpos": true,
        "active": true,
        "isopen": false,
        "buttonMessage": "Click to whatsapp",
        "widgetMessage": "Hola!",
        "iconUrl": "https://widget.tochat.be/face.png",
        "textColor": "#ffffff"
    }
}
                

In the event of an error status is false and an error filed is included. For example if a non hex value color is given:

{
    "status": false,
    "error": "Object(App\\Entity\\Business).color:\n    This value is not valid. (code de1e3db3-5ed4-4941-aae4-59f3667cc3a3)\n"
}
                

Viewing your data

GET https://services.tochat.be/api/business/get/ACCOUT_ID
Note , this is a public api and is the same api that the widget consumes and displays to the public. It therefore does not require autentification
{
    "status": true,
    "data": {
        "id": "948b6088-42cf-4eb3-9df4-da26175c27aa",
        "name": "Acme Ltd",
        "whatsapps": [
            {
                "id": "719ec638-dc05-4542-8761-d91529ccd265",
                "number": "34622814642",
                "name": "MR X",
                "active": true,
                "iconUrl": "https://widget.tochat.be/face.png",
                "post": "RRHH",
                "optimes": [
                    {
                        "day": "SA",
                        "availableFrom": "14:00:00",
                        "availableUntil": "23:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "00:00:00"
                    }
                ]
            },
            {
                "id": "a602b203-bdf0-46d6-a443-1149dcda09ef",
                "number": "34622814642",
                "name": "Ms Y",
                "active": true,
                "iconUrl": "https://widget.tochat.be/face.png",
                "post": "Sales",
                "optimes": [
                    {
                        "day": "MO",
                        "availableFrom": "22:00:00",
                        "availableUntil": "23:00:00"
                    },
                    {
                        "day": "TU",
                        "availableFrom": "22:00:00",
                        "availableUntil": "00:00:00"
                    }
                ]
            }
        ],
        "color": "#25d366",
        "rightpos": true,
        "active": true,
        "isopen": false,
        "buttonMessage": "Click to whatsapp",
        "widgetMessage": "Hola!",
        "iconUrl": "https://widget.tochat.be/face.png",
        "textColor": "#ffffff"
    }
}
                
CURL

We have provided an example in curt to get you started:

  curl -X GET \
  https://services.tochat.be/api/business/get/948b6088-42cf-4eb3-9df4-da26175c27aa \
  -H 'Postman-Token: f5fb9fa9-0162-447c-910a-d6501a9adaa2' \
  -H 'cache-control: no-cache'
        

The following code should be installed jest before the closing body tag. The account Id is what was received after inserting

  <script defer data-key="CLIENT_ID" src="https://widget.tochat.be/bundle.js"></script>
        

Using POSTMAN

A Postman exportable con be downloaded from here: https://services.tochat.be/tochat.postman_collection.json. Note you will have to generate your own token with your email and password for it to work.

Validations

{
    "name": string(2 - 255) required,
    "whatsapps": [
        {
            "number": string (255) required,
            "name": string (2 - 255) required,

            "optimes":[
            	{
                      "day":string (2) format (MO,TUY,WE,TH,FR,SA,SU) required,
                      "availableFrom":string (8) format HH:MM:SS required,
                      "availableUntil":string (8) format HH:MM:SS} required,
            	],
            "id": string  - valid uuid
            "active": boolean required,
            "iconUrl": string (255) - format /^https:[\-_A-Za-z0-9\/\.]+\.(jpg|png|gif)$/ ,
            "post": string (0-255)

        },
    ],
    "color": string (7) format: /^#[0-9a-fA-F]{6}/,
    "textColor": string (7) forma /^#[0-9a-fA-F]{6}/
    "rightpos": boolean,
    "active": boolean,
    "isopen": boolean,
    "buttonMessage": string (2 - 255),
    "widgetMessage": string (2 - 255),
    "iconUrl": string (255) - format /^https:[\-_A-Za-z0-9\/\.]+\.(jpg|png|gif)$/
}
        



Use our Widget with ZOHO CRM, JOFORM or HUBSPOT - Connect your WhatsApp users and clients with your ZOHO CRM and HUBSPOT

Create Polls for WhatsApp | Share polls with your WhatsApp Group

CHATWITH.IO SOLUCIONES SL | MADRID-ESPAÑA | NIF: B42935981 | Contact us with WhatsApp link 34627524218
Privacy policy | Terms and conditions | Política de cancelación/devolución: No se admiten devoluciones.
Tus derechos: Derecho de desistimiento.

Whatsapp API Documentation | Whatsapp API Signup
The WhatsApp trademark, as well as WhatsApp’s Logo and other services marks and logos are owned by WhatsApp LLC. We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp LLC.
Copied to clipboard