# How to Add SMS Authentication for Signers

To add SMS authentication to signature requests which verifies the signer with the SMS OTP, you need to include `AuthenticationType` as `SMSOTP`. It is also mandatory to add `CountryCode` and `Number` for SMS authentication.

To enable SMS verification, you need to include the above parameters to the following endpoints:

1. `v1/document/send`
2. `v1/document/createEmbeddedRequestUrl`

If you are sending a document using template, you need to include those parameters to the following endpoints:

1. `v1/template/send`
2. `v1/template/createEmbeddedRequestUrl`

{% highlight %} It's important to note that SMS authentication can be added to the document only for paid plans.{% /highlight %}

## Sending a document to the signer with SMS authentication

To send a document to the signer with SMS authentication, follow these steps:

Use one of the example code snippets below, depending on your preferred programming language.

### Code Snippet

{% codetab %}

cURL

```shell 
curl -X 'POST' \
  'https://api.boldsign.com/v1/document/send' \
  -H 'accept: application/json' \
  -H 'X-API-KEY: {your API key}' \
  -H 'Content-Type: multipart/form-data' \
  -F 'Signers={
  "name": "hanky",
  "emailAddress": "hankyWhites@gmail.com",
  "signerType": "Signer",
  "signerRole": "Signer",
  "authenticationType": "SMSOTP",
  "phoneNumber": {
    "countryCode": "{Signer country code}",
    "number": "{Signer phone number}"
  },
  "formFields": [
    {
      "id": "signature",
      "name": "signature",
      "fieldType": "Signature",
      "pageNumber": 1,
      "bounds": {
        "x": 100,
        "y": 100,
        "width": 200,
        "height": 200
      },
      "isRequired": true
}
  ],
  "locale": "EN"
}' \
  -F 'Files=@{your file}' \
  -F 'Title={title}' \
```

C#

```csharp
var apiClient = new ApiClient("https://api.boldsign.com", "{Your API key}");
var documentClient = new DocumentClient(apiClient);

var documentFilePath = new DocumentFilePath
{
    ContentType = "application/pdf",
    FilePath = "{Your File path}"
};

var filesToUpload = new List<IDocumentFile>
{
    documentFilePath,
};

var signatureField = new FormField(
    id: "sign",
    isRequired: true,
    type: FieldType.Signature,
    pageNumber: 1,
    bounds: new Rectangle(x: 100, y: 100, width: 100, height: 50));

var formFieldCollections = new List<FormField>()
{
    signatureField
};

var signer = new DocumentSigner(
    name: "David",
    emailAddress: "david@cubeflakes.com",
    authenticationType: AuthenticationType.SMSOTP,
    phoneNumber: new PhoneNumber(
        countryCode: "{Signer country code}",
        number: "{Signer phone number}"),
    formFields: formFieldCollections,
    locale: Locales.EN);

var documentSigners = new List<DocumentSigner>()
{
    signer
};

var sendForSign = new SendForSign()
{
    Title = "Agreement",
    Signers = documentSigners,
    Files = filesToUpload,
};
var documentCreated = documentClient.SendDocument(sendForSign);
Console.WriteLine(documentCreated.DocumentId);
```

Python

```python
import requests
import json

url = "https://api.boldsign.com/v1/document/send"

signer_data = {
    "name": "hanky",
    "emailAddress": "hankyWhites@gmail.com",
    "signerType": "Signer",
    "signerRole": "Signer",
    "authenticationType": "SMSOTP",
    "phoneNumber": {
        "countryCode": "{Signer country code}",
        "number": "{Signer phone number}"
    },
    "formFields": [
        {
            "id": "signature",
            "name": "signature",
            "fieldType": "Signature",
            "pageNumber": 1,
            "bounds": {
                "x": 100,
                "y": 100,
                "width": 200,
                "height": 200
            },
            "isRequired": True
        }
    ],
    "locale": "EN"
}

payload = {
    'Signers': json.dumps(signer_data),
    'Title': '{title}'
}

files = [
    ('Files', ('{Your file name}', open('{Your file path}', 'rb'), 'application/pdf'))
]

headers = {
    'accept': 'application/json',
    'X-API-KEY': '{Your API key}'
}

response = requests.post(url, headers=headers, data=payload, files=files)

print(response.text)
```

NodeJS

```js
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();

const signerData = {
  name: 'hanky',
  emailAddress: 'hankyWhites@gmail.com',
  signerType: 'Signer',
  signerRole: 'Signer',
  authenticationType: 'SMSOTP',
  phoneNumber: {
    countryCode: '{Signer country code}',
    number: '{Signer phone number}'
  },
  formFields: [
    {
      id: 'signature',
      name: 'signature',
      fieldType: 'Signature',
      pageNumber: 1,
      bounds: {
        x: 100,
        y: 100,
        width: 200,
        height: 200
      },
      isRequired: true
    }
  ],
  locale: 'EN'
};

data.append('Signers', JSON.stringify(signerData));
data.append('Files', fs.createReadStream('{Your file path}'));
data.append('Title', '{title}');

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.boldsign.com/v1/document/send',
  headers: {
    accept: 'application/json',
    'X-API-KEY': '{Your API key}',
    ...data.getHeaders()
  },
  data: data
};

axios.request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });
```

{% /codetab %}

Replace the values (`Files,` `Signers,` etc.) with the actual values. Set the value for `authenticationType` as `SMSOTP,` and provide values for `countryCode` and `number` with the signer's country code and phone number.

Upon execution, the document will be created with SMS athentication, and a document ID will be generated.

## Accessing the SMS authenticated document
- When the signer opens the document link, they will see a "Send OTP" button. Clicking this button will trigger the sending of an OTP to the signer via SMS.

  ![Step 1](/static/images/guides/sms-otp/step1.webp)

- After the signer enters the OTP and clicks the "Verify" button, the document will open, and the signer can start the signing process.

  ![Step 2](/static/images/guides/sms-otp/step2.webp)
