> For the complete documentation index, see [llms.txt](https://developer.nilvera.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.nilvera.com/en/api/e-expense-api/sms-verification.md).

# SMS Verification

When issuing an E-Expense Voucher, the recipient's approval can be obtained via SMS. The endpoints in this section send a 6-digit, one-time verification code to the recipient's phone number and verify the code received from the recipient. The verified code is added to the `VerificationInfo` field of the expense voucher and sent together with the document.

### SMS Verification Owner

Who performs the SMS verification is set with the [Changes E-Expense SMS Verification Owner](https://developer.nilvera.com/en/api/general-api/mail-transactions/changes-e-expense-sms-verification-owner) endpoint under the General API. This endpoint accepts two values:

* `Integrator`: Verification is performed by Nilvera (the integrator). Sending and verifying the code are done with the endpoints in this section. In this case, the `ServiceProviderInfo` field is not sent in the document.
* `Customer`: Verification is performed by the customer using its own infrastructure or SMS provider. In this case, the `ServiceProviderInfo` field must be filled in the document.

{% hint style="info" %}
If the SMS verification owner is not set in the mail settings, verification is performed **by the integrator by default** (`Integrator`).
{% endhint %}

{% hint style="warning" %}
When the SMS verification owner is set to `Customer`, sending the SMS, obtaining the code from the recipient, verifying it and sending the verification details correctly in the document are **entirely the customer's responsibility**. In this case, Nilvera does not check whether the code was actually verified; it only expects the `VerificationInfo` fields to be sent completely and correctly. The `ServiceProviderInfo` field must be filled with the title and tax number of the provider offering the verification service.
{% endhint %}

### Verification Flow

SMS verification performed by the integrator consists of three steps:

1. **The code is sent:** The expense voucher's `UUID` and the recipient's phone number (`Phone`) are sent to the [Sends Verification Code](https://developer.nilvera.com/en/api/e-expense-api/sms-verification/sends-verification-code) (`POST /SmsVerification/Send`) endpoint. A 6-digit verification code is delivered to the recipient's phone.
2. **The code is verified:** The code received from the recipient is sent with the same `UUID` to the [Verifies Code](https://developer.nilvera.com/en/api/e-expense-api/sms-verification/verifies-code) (`POST /SmsVerification/Verify`) endpoint.
3. **The document is sent:** The verified code is added, together with the phone number and the verification method, to the `ExpenseInfo.VerificationInfo` field of the expense voucher, and the document is sent.

```javascript
VerificationInfo: {
  Type: "SMS",
  Phone: "5551234567",
  Code: "123456"
}
```

{% hint style="info" %}
The **same UUID** must be used for sending the code, verifying it and sending the document. The `ExpenseInfo.UUID` value in the document must be the same as the UUID used when sending the SMS.
{% endhint %}

### Time Limits and Sending Rules

* A verification code can be sent **only once within 180 seconds** for the same UUID. Repeated requests before this period ends are rejected with a `422` error.
* A verified code is **valid for 180 seconds**. The code must be used in the related expense voucher and the document must be sent within this period.
* When the period expires, the code becomes invalid. A new code must be sent for the same UUID and the verification steps must be repeated.

{% hint style="warning" %}
Send the document **within 180 seconds** after the code is verified. Otherwise, the code expires and the verification details in the document are considered invalid.
{% endhint %}

### Verification Method by Scenario

The verification method is specified as `SMS` or `IADEKODU` in the `VerificationInfo.Type` field. The method that can be used depends on the document's scenario:

| Scenario | SMS     | IADEKODU    |
| -------- | ------- | ----------- |
| Sale     | Allowed | Not allowed |
| Return   | Allowed | Allowed     |
