# Verify User OTP POST https://api-gateway-stg.transak.com/api/v2/auth/verify Content-Type: application/json The **Verify User OTP** is a **non-authenticated API** that allows you to **verify a user’s email using an OTP** and retrieve an **access token** in return. Once you have successfully called `Send User OTP`, you need to pass the **email verification code** along with the user’s email to **verify the OTP**. **Access Token Usages (Received in response)** - This **access token is required** for all **authenticated API calls** (such as placing orders, fetching user details, and submitting KYC). - This **access token remains valid for 30 days from the time of generation**. Once expired, the user must restart the authentication process by requesting a new OTP. Reference: https://docs.transak.com/api/whitelabel/user/verify-user-otp ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: whitelabel-api version: 1.0.0 paths: /api/v2/auth/verify: post: operationId: verify-user-otp summary: Verify User OTP description: >- The **Verify User OTP** is a **non-authenticated API** that allows you to **verify a user’s email using an OTP** and retrieve an **access token** in return. Once you have successfully called `Send User OTP`, you need to pass the **email verification code** along with the user’s email to **verify the OTP**. **Access Token Usages (Received in response)** - This **access token is required** for all **authenticated API calls** (such as placing orders, fetching user details, and submitting KYC). - This **access token remains valid for 30 days from the time of generation**. Once expired, the user must restart the authentication process by requesting a new OTP. tags: - subpackage_user responses: '200': description: 200 - Success content: application/json: schema: $ref: '#/components/schemas/User_verify-user-otp_Response_200' '400': description: '400 - Bad Request ' content: application/json: schema: $ref: '#/components/schemas/Verify-user-otpRequestBadRequestError' '401': description: 401 - Unauthorized content: application/json: schema: $ref: '#/components/schemas/Verify-user-otpRequestUnauthorizedError' '500': description: 500 - Internal Server Error content: application/json: schema: $ref: '#/components/schemas/Verify-user-otpRequestInternalServerError' requestBody: content: application/json: schema: type: object properties: apiKey: type: string default: YOUR_API_KEY description: Your API Key from Transak Dashboard email: type: string default: test@transak.com description: Your Email address used to receive OTP. otp: type: string default: '123456' description: Your OTP received in your Email inbox. stateToken: type: string default: STATE_TOKEN_12345 description: token received in api/v2/auth/login required: - apiKey - email - otp - stateToken servers: - url: https://api-gateway-stg.transak.com components: schemas: ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaData: type: object properties: ttl: type: integer created: type: string accessToken: type: string required: - ttl - created - accessToken title: ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaData User_verify-user-otp_Response_200: type: object properties: data: $ref: >- #/components/schemas/ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaData required: - data title: User_verify-user-otp_Response_200 ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaError: type: object properties: statusCode: type: integer message: type: string required: - statusCode - message title: ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaError Verify-user-otpRequestBadRequestError: type: object properties: error: $ref: >- #/components/schemas/ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaError required: - error title: Verify-user-otpRequestBadRequestError Verify-user-otpRequestUnauthorizedError: type: object properties: error: $ref: >- #/components/schemas/ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaError required: - error title: Verify-user-otpRequestUnauthorizedError Verify-user-otpRequestInternalServerError: type: object properties: error: $ref: >- #/components/schemas/ApiV2AuthVerifyPostResponsesContentApplicationJsonSchemaError required: - error title: Verify-user-otpRequestInternalServerError ``` ## SDK Code Examples ```python Success import requests url = "https://api-gateway-stg.transak.com/api/v2/auth/verify" headers = {"Content-Type": "application/json"} response = requests.post(url, headers=headers) print(response.json()) ``` ```javascript Success const url = 'https://api-gateway-stg.transak.com/api/v2/auth/verify'; const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: undefined}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Success package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/auth/verify" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Success require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/auth/verify") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' response = http.request(request) puts response.read_body ``` ```java Success import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/auth/verify") .header("Content-Type", "application/json") .asString(); ``` ```php Success request('POST', 'https://api-gateway-stg.transak.com/api/v2/auth/verify', [ 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Success using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/auth/verify"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); IRestResponse response = client.Execute(request); ``` ```swift Success import Foundation let headers = ["Content-Type": "application/json"] let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/auth/verify")! 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() ``` ```python User_verify-user-otp_example import requests url = "https://api-gateway-stg.transak.com/api/v2/auth/verify" payload = { "apiKey": "YOUR_API_KEY", "email": "test@transak.com", "otp": "123456", "stateToken": "" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript User_verify-user-otp_example const url = 'https://api-gateway-stg.transak.com/api/v2/auth/verify'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"apiKey":"YOUR_API_KEY","email":"test@transak.com","otp":"123456","stateToken":""}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go User_verify-user-otp_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api-gateway-stg.transak.com/api/v2/auth/verify" payload := strings.NewReader("{\n \"apiKey\": \"YOUR_API_KEY\",\n \"email\": \"test@transak.com\",\n \"otp\": \"123456\",\n \"stateToken\": \"\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby User_verify-user-otp_example require 'uri' require 'net/http' url = URI("https://api-gateway-stg.transak.com/api/v2/auth/verify") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"apiKey\": \"YOUR_API_KEY\",\n \"email\": \"test@transak.com\",\n \"otp\": \"123456\",\n \"stateToken\": \"\"\n}" response = http.request(request) puts response.read_body ``` ```java User_verify-user-otp_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-gateway-stg.transak.com/api/v2/auth/verify") .header("Content-Type", "application/json") .body("{\n \"apiKey\": \"YOUR_API_KEY\",\n \"email\": \"test@transak.com\",\n \"otp\": \"123456\",\n \"stateToken\": \"\"\n}") .asString(); ``` ```php User_verify-user-otp_example request('POST', 'https://api-gateway-stg.transak.com/api/v2/auth/verify', [ 'body' => '{ "apiKey": "YOUR_API_KEY", "email": "test@transak.com", "otp": "123456", "stateToken": "" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp User_verify-user-otp_example using RestSharp; var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/auth/verify"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"apiKey\": \"YOUR_API_KEY\",\n \"email\": \"test@transak.com\",\n \"otp\": \"123456\",\n \"stateToken\": \"\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift User_verify-user-otp_example import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "apiKey": "YOUR_API_KEY", "email": "test@transak.com", "otp": "123456", "stateToken": "" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/auth/verify")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ```