# Whatsapp Verification

### Introduction

WhatApp Verification (SendTalk 2.0) is a method of verification that requires a customer to send a WhatsApp message to SendTalk’s WhatsApp Official Business Account to trigger the verification process for the customer.

Below is the sample process that we recommend our clients to use if they are planning on using WhatApp Verification as a verification method for their applications.

<figure><img src="https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LfVupFSqh_qZAY9OiCO%2Fuploads%2FtTN7s3tDinuIeDAsyXka%2Ftelegram-cloud-document-5-6242282137744051102.jpg?alt=media&#x26;token=26caa713-50a0-49d5-b04a-72a1f99552f2" alt=""><figcaption></figcaption></figure>

Recommended Verification Flow:

1. User Login\
   User initiates a login on client's application using phone number that is registered to WhatsApp.
2. Request Verification\
   Client's application will trigger client's backend server to request create verification to SendTalk's server through API call.
3. Return Payload\
   Once SendTalk's server receive an API call from client's server, SendTalk will process the verification request and return a payload containing:

   1. Verification ID
   2. WhatsApp message link
   3. WhatsApp message
   4. QR code

   We suggest clients to save this verification ID to their own database along with a verification status.
4. WhatsApp Message Link\
   WhatsApp message link is a link that can be accessed by a customer to redirect them to a chatroom in their WhatsApp application where the recipient will be SendTalk's WhatsApp Official Business Account and a predefined message template will show up on their text composer. \
   \
   After receiving the WhatsApp Message Link from SendTalk's server, we suggest clients to redirect their users to this link. \
   \
   Try creating your own Deep Link with these documentations:\
   iOS : <https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-ios/deep-linking> \
   Android : <https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-android/deep-linking>
5. Send WhatsApp Message\
   After users are redirected to the link and to WhatsApp, users must send the message without changing the content to trigger the verification checking from SendTalk.\
   There is an instruction in the template message that ask the users to go back to the application that triggered the verification process.
6. Validate\
   SendTalk will validate every message received in SendTalk's WhatsApp Official Business  Account.
7. Webhook URL\
   SendTalk will send a Webhook call to registered Webhook URL if a verification succeeded. Clients can update the verification status on their database based on the payload from Webhook.
8. Verification Status\
   Client can trigger a verification check to their database right after the user went back to the application.

### Setup

Go to <https://sendtalk.taptalk.io> and login if you already have an account.

Browse to "WhatsApp Verification" > "Verification Config" and click "Edit" to enable your WhatsApp Verification.

&#x20;

<figure><img src="https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LfVupFSqh_qZAY9OiCO%2Fuploads%2Fk4DS4oVnzPCgsu37M45o%2Fimage.png?alt=media&#x26;token=2b4a241d-0f1b-44da-a089-4a73eaba91e0" alt=""><figcaption></figcaption></figure>

Enable the WhatsApp Verification, input your Webhook URL ans click "Save Changes".

Once saved, a Secret key will be generated and you can use this as a validator for this webhook call. WhatsApp Verification is ready to use.

<figure><img src="https://4266585843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LfVupFSqh_qZAY9OiCO%2Fuploads%2Fmx7Xa1eCz5VEmSRyGG87%2Fimage.png?alt=media&#x26;token=b0e322ef-f619-4da4-b1c3-5dc891437b30" alt=""><figcaption></figcaption></figure>

### API Documentation

## Request Create WhatsApp Verification

<mark style="color:green;">`POST`</mark> `https://sendtalk-api.taptalk.io/api/v1/verification/create_whatsapp_verification`

#### Parameter

<table><thead><tr><th width="201">Field</th><th width="90">Type</th><th>Description</th></tr></thead><tbody><tr><td>userPhone</td><td>string</td><td>The phone number to be verified.</td></tr><tr><td>languageCode</td><td>string</td><td>Language code for the generated verification message. Values: <code>"en"</code>, "id".</td></tr><tr><td>expiryMinutes</td><td>integer</td><td>(Optional) The expiry duration in minutes.</td></tr><tr><td>appURL</td><td>string</td><td>(Optional) App link/URL to be included in the generated verification message.</td></tr></tbody></table>

{% tabs %}
{% tab title="Request Example" %}

```
{
    "userPhone": "6281212345678",
    "languageCode": "id",
    "expiryMinutes": 10,
    "appURL": "https://web.taptalk.io"
}
```

{% endtab %}
{% endtabs %}

#### Success 200

<table><thead><tr><th width="167">Field</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td>success</td><td>boolean</td><td>If created successfully.</td></tr><tr><td>message</td><td>string</td><td>The success or error message.</td></tr><tr><td>reason</td><td>string</td><td>Failure reason ("invalid_recipient", "insufficient_balance", "config_disabled").</td></tr><tr><td>verification</td><td>object</td><td>The created verification, if successful.</td></tr><tr><td>     id</td><td>string</td><td>The verification ID.</td></tr><tr><td>     waLink</td><td>string</td><td>WhatsApp link containing recipient number and generated message.</td></tr><tr><td>     waMessage</td><td>string</td><td>The generated message.</td></tr><tr><td>     qrCode</td><td>string</td><td>QR code for the WhatsApp link.</td></tr></tbody></table>

{% tabs %}
{% tab title="Success Response" %}

```
HTTP/1.1 200 OK
{
  "status": 200,
  "error": {
    "code": "",
    "message": "",
    "field": ""
  },
  "data": {
    "success": true,
    "message": "WhatsApp verification created successfully",
    "reason": "",
    "verification": {
      "id": "3f35ec07-77f1-4fa0-9416-8ef019e52189",
      "waLink": "https://wa.me/6281212345678?text=Mohon+jangan+ubah+teks+verifikasi+ini.%0A%0AKode+Verifikasi%3A+TTJZek5XVmpNRGN0TnpkbU1TMDBabUV3TFRrME1UWXRPR1ZtTURFNVpUVXlNVGc1T25kS1RXSlhlWGhhY0hKS1IzVmFkbm89%0ABerlaku+sampai+dengan%3A+16%3A09%3A00+19-06-2023%0A%0A%2APastikan+nomor+WhatsApp+ini+sama+dengan+nomor+yang+Anda+gunakan.%2A%0A%0AKirim+teks+ini+tanpa+mengubah+isinya%2C+lalu+silakan+kembali+ke+aplikasi.",
      "waMessage": "Mohon jangan ubah teks verifikasi ini.\n\nKode Verifikasi: TTJZek5XVmpNRGN0TnpkbU1TMDBabUV3TFRrME1UWXRPR1ZtTURFNVpUVXlNVGc1T25kS1RXSlhlWGhhY0hKS1IzVmFkbm89\nBerlaku sampai dengan: 16:09:00 19-06-2023\n\n*Pastikan nomor WhatsApp ini sama dengan nomor yang Anda gunakan.*\n\nKirim teks ini tanpa mengubah isinya, lalu silakan kembali ke aplikasi.",
      "qrCode": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAABlBMVEX///8AAABVwtN+AAAF7UlEQVR42uzZPY7rrBoH8L9FQRc2gMI2KCKxJaebKuBqunhLSFN4G0RsAHcUyP8r8vGe29tndK..."
    }
  }
}
```

{% endtab %}
{% endtabs %}

#### Error 4xx

| Name                   | Description                           |
| ---------------------- | ------------------------------------- |
| ParamValidationFailed  | The parameter validation failed.      |
| HeaderValidationFailed | The request header validation failed. |

{% tabs %}
{% tab title="Param Validation Failed" %}

```json
HTTP/1.1 200 OK
{
  "status": 400,
  "error": {
    "code": "40002",
    "message": "User phone is required",
    "field": "userPhone"
  },
  "data": {}
}
```

{% endtab %}

{% tab title="Header Validation Failed" %}

```json
HTTP/1.1 200 OK
{
  "status": 400,
  "error": {
    "code": "40001",
    "message": "Request headers are required (API-Key)",
    "field": ""
  },
  "data": {}
}
```

{% endtab %}
{% endtabs %}

### Webhook Payload

Below document will describe the details of a WhatsApp Verification Webhook payload that will be sent every time a verification has been verified via a POST API Call to client's Webhook URL.

<table><thead><tr><th width="159">Field</th><th width="82">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>string</td><td>The ID of the verification.</td></tr><tr><td>userPhone</td><td>string</td><td>The phone number to be verified.</td></tr><tr><td>status</td><td>string</td><td>The verification status ("verified").</td></tr><tr><td>verifiedTime</td><td>long</td><td>The verified time, in Unix milliseconds.</td></tr></tbody></table>

{% tabs %}
{% tab title="Payload Example" %}

```
{
    "id": "fc0977f2-baa9-476d-8a3d-128c622d5ff6",
    "userPhone": "628124630350",
    "status": "verified",
    "verifiedTime": 1692847205385
}
```

{% endtab %}
{% endtabs %}

### Client Example

To help you implement WhatsApp Verification smoothly, you can check our Client Examples for using SendTalk by clicking this link  <https://github.com/taptalk-io/sendtalk-client-example/tree/main>

For more information feel free to contact us via **<support@taptalk.io>** or simply click the link below to chat from [**WhatsApp**](https://api.whatsapp.com/send/?phone=6282180885808\&text=Halo+TapTalk.io%2C+Saya+ingin+bertanya+terkait+integrasi+channel+saya)**.**
