> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fyno.io/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fyno.io/docs/_mcp/server.

# Verify OTP

POST https://api.fyno.io/v1/{WSID}/{version}/verify/validate

This API enables you to validate the OTP entered by the user using either `request_id` (received in response of the Fire an Event API) or `destination` (such as phone number, email).

**Note:** By default, OTPs are not tied to a specific notification event. If you validate using `destination`, an OTP sent to the same destination by another event that also uses destination validation can override the earlier OTP. To avoid this, pass the optional `event_name` parameter to validate the OTP against a specific event.


Reference: https://fyno.io/docs/api-reference/verify-otp

## Authentication

- `Authorization` header (bearer token, required) — Enter your API Key. If you don't have it already, you can create one from the API Keys page within your Fyno account

## Request

### Path parameters

- `WSID` (string, required) — Enter your workspace ID. You can obtain this value from the API Keys page within your Fyno account.
- `version` (string, required) — Specify the version for which you would like to manage the user profile.

### Query parameters

- `request_id` (string, optional) — Specify the request id of the triggered notification event that sent the OTP to the user. You must use this query parameter if **you've disabled "Use destination as id"** in the Fyno Verify setting.
- `destination` (string, optional) — Enter the destination where the OTP is sent. It can be either mobile no or email id. You must use this query parameter if **you've enabled "Use destination as id"** in the Fyno Verify setting.
- `event_name` (string, optional) — (Optional) Enter the name of the notification event that sent the OTP, for example `login_otp`. Use this parameter along with `destination` to validate the OTP for a specific event. Without it, an OTP sent to the same destination by another event that also uses destination validation can override the OTP you are validating.
- `otp` (string, required) — Enter the OTP which you want to validate.

## Response

### 200

OTP successfully validated

- `_message` (string, required)
- `status` (string, required)

## Errors

### 400 Bad Request Error

Invalid OTP entered by user

- `_message` (string, required)
- `status` (string, required)

### 401 Unauthorized Error

API Key or Workspace ID is invalid. User is unauthorised.

- `_message` (string, required)
- `status` (string, required)

## Examples

### Validate using request_id

**Response**

```json
{
  "_message": "verified",
  "status": "ok"
}
```

**SDK Code**

```python Validate using request_id
import requests

url = "https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate"

querystring = {"otp":"1234","request_id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}

headers = {"Authorization": "Bearer <apiKey>"}

response = requests.post(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Validate using request_id
const url = 'https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?otp=1234&request_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
const options = {method: 'POST', headers: {Authorization: 'Bearer <apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Validate using request_id
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?otp=1234&request_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Validate using request_id
require 'uri'
require 'net/http'

url = URI("https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?otp=1234&request_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'

response = http.request(request)
puts response.read_body
```

```java Validate using request_id
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?otp=1234&request_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
  .header("Authorization", "Bearer <apiKey>")
  .asString();
```

```php Validate using request_id
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?otp=1234&request_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', [
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Validate using request_id
using RestSharp;

var client = new RestClient("https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?otp=1234&request_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Validate using request_id
import Foundation

let headers = ["Authorization": "Bearer <apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?otp=1234&request_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Validate using destination and event_name

**Response**

```json
{
  "_message": "verified",
  "status": "ok"
}
```

**SDK Code**

```python Validate using destination and event_name
import requests

url = "https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate"

querystring = {"destination":"xxxxxxxxxx","event_name":"login_otp","otp":"1234"}

headers = {"Authorization": "Bearer <apiKey>"}

response = requests.post(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Validate using destination and event_name
const url = 'https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?destination=xxxxxxxxxx&event_name=login_otp&otp=1234';
const options = {method: 'POST', headers: {Authorization: 'Bearer <apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Validate using destination and event_name
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?destination=xxxxxxxxxx&event_name=login_otp&otp=1234"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Validate using destination and event_name
require 'uri'
require 'net/http'

url = URI("https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?destination=xxxxxxxxxx&event_name=login_otp&otp=1234")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'

response = http.request(request)
puts response.read_body
```

```java Validate using destination and event_name
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?destination=xxxxxxxxxx&event_name=login_otp&otp=1234")
  .header("Authorization", "Bearer <apiKey>")
  .asString();
```

```php Validate using destination and event_name
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?destination=xxxxxxxxxx&event_name=login_otp&otp=1234', [
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Validate using destination and event_name
using RestSharp;

var client = new RestClient("https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?destination=xxxxxxxxxx&event_name=login_otp&otp=1234");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Validate using destination and event_name
import Foundation

let headers = ["Authorization": "Bearer <apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fyno.io/v1/FYXXXXXXXX/live/verify/validate?destination=xxxxxxxxxx&event_name=login_otp&otp=1234")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```