# KakaoTalk sender

To create a KakaoTalk sender, you need a valid `plusFriendId` and some information about the sender you intend to create. In order to successfully configure a KakaoTalk sender for use with the Conversation API, you must:

1. [Creating](#creating-a-sender) a KakaoTalk sender.
2. [Verifying](#verifying-the-sender) the KakaoTalk sender you created.


Note that, for this guide, we provide **Node.js** code samples. However, the principles apply to any language you use to make requests to the API.

## Creating a sender

The following code sample [creates a KakaoTalk sender](/docs/provisioning-api/api-reference/provisioning-api/kakaotalk-senders/kakaotalksenderscontroller_createsender_v1) using the Provisioning API:

```javascript

import fetch from 'node-fetch';

async function createSender() {
  const resp = await fetch(
    `https://provisioning.api.sinch.com/v1/projects/${PROJECT_ID}/kakaotalk/senders`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization:
          'Basic ' +
          Buffer.from(ACCESS_KEY + ':' + ACCESS_SECRET).toString('base64'),
      },
      body: JSON.stringify({
        plusFriendId: 'plusFriendId',
        details: {
          adminPhoneNo: '+48777777777',
          name: 'Test Name',
          topLevelCategoryCode: '019',
          midLevelCategoryCode: '0006',
          subLevelCategoryCode: '0001',
        },
      }),
    }
  );

  const data = await resp.json();
  return data;
}
```

After creating the sender, you'll need to [verify](#verifying-the-sender) it.

Note:
Once created, the sender's status will be set to `IN_PROGRESS`. Note that, after a review, the sender could be rejected. If the sender is rejected, the status of the sender will be set to `REJECTED`. The notifications endpoint can be used to see if there is any comment explaining the reason for rejection. If rejected, the sender can be edited and submitted again.

## Verifying the sender

Once the sender reaches the `PENDING_VERIFICATION` status, the phone number needs to be verified. Start the process by triggering the [Register sender](/docs/provisioning-api/api-reference/provisioning-api/kakaotalk-senders/senderscontroller_registersender_v1) endpoint:

```javascript

import fetch from 'node-fetch';

async function registerSender() {
  const resp = await fetch(
    `https://provisioning.api.sinch.com/v1/projects/${PROJECT_ID}/kakaotalk/senders/${PLUS_FRIEND_ID}/register`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization:
          'Basic ' +
          Buffer.from(ACCESS_KEY + ':' + ACCESS_SECRET).toString('base64'),
      },
    }
  );

  const data = await resp.json();
  return data;
}
```

This will send a one time passcode (OTP) to the phone number used to populate the `adminPhoneNo` field referenced in the [previous section](#creating-a-sender).

Once the OTP code has been received, verify the sender, using the [Verify sender](/docs/provisioning-api/api-reference/provisioning-api/kakaotalk-senders/senderscontroller_verifysender_v1) endpoint, with the following code:

```javascript

import fetch from 'node-fetch';

async function verifySender() {
  const resp = await fetch(
    `https://provisioning.api.sinch.com/v1/projects/${PROJECT_ID}/kakaotalk/senders/${PLUS_FRIEND_ID}/verify`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization:
          'Basic ' +
          Buffer.from(ACCESS_KEY + ':' + ACCESS_SECRET).toString('base64'),
      },
      body: JSON.stringify({
        code: '123456',
      }),
    }
  );

  const data = await resp.json();
  return data;
}
```

The sender will continue through the state transitions and eventually become `ACTIVE`. A notification will be triggered once the status changes to `ACTIVE`, at which point you can create [templates](/docs/provisioning-api/getting-started/kakaotalk/templates) for the sender.