Skip to Content
SegurançaSenha Única - OTPSolicitar OTP

Solicitar Senha Única (OTP)

Para solicitar a Senha Única (OTP) para confirmae sua identidade, você vai precisar de um usuário e do tipo de confirmação.

Por exemplo:

  • Usuário: teste@gmail.com
  • Tipo: EMAIL

Montando a requisição

Método da requisição

POST

Endereço da requisição

Desenvolvimento:

https://apidsv.unimedbh.io/security/v1/otp/request

Homologação:

https://apihml.unimedbh.io/security/v1/otp/request

Produção:

https://api.unimedbh.io/security/v1/otp/request

Cabeçalho da requisição

{ "Content-Type": "application/json" }

Corpo da requisição

{ "username": "teste@gmail.com", "type": "EMAIL" }

Respostas da requisição

200 - Sucesso

{ "type": "EMAIL", "sended": true, "requestedAt": "2025-11-11T18:40:15.071+0000" }

400 - Dados Inválidos

{ "date": "11/11/2025 16:29:32", "message": "Por favor, informe os dados relacionados ao usuário que deseja autenticar.", "details": [] }

404 - Dados Não Encontrados

{ "date": "11/11/2025 16:29:32", "message": "Nenhuma sessão encontrada com os dados informados.", "details": [] }

Exemplos da requisição

HTTP

POST /security/v1/otp/request HTTP/1.1 Host: apihml.unimedbh.io Content-Type: application/json Content-Length: 61 { "username": "teste@gmail.com", "type": "EMAIL" }

cURL

curl --location 'https://apihml.unimedbh.io/security/v1/otp/request' \ --header 'Content-Type: application/json' \ --data-raw '{ "username": "teste@gmail.com", "type": "EMAIL" }'

JavaScript

const myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); const raw = JSON.stringify({ "username": "teste@gmail.com", "type": "EMAIL" }); const requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("https://apihml.unimedbh.io/security/v1/otp/request", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));

Node.js

const axios = require('axios'); const data = JSON.stringify({ "username": "teste@gmail.com", "type": "EMAIL" }); const config = { method: 'post', maxBodyLength: Infinity, url: 'https://apihml.unimedbh.io/security/v1/otp/request', headers: { 'Content-Type': 'application/json' }, data : data }; axios.request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); });

PHP

<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://apihml.unimedbh.io/security/v1/otp/request', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "username": "teste@gmail.com", "type": "EMAIL" }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;

Java

Unirest.setTimeouts(0, 0); HttpResponse<String> response = Unirest.post("https://apihml.unimedbh.io/security/v1/otp/request") .header("Content-Type", "application/json") .body("{\"username\": \"teste@gmail.com\",\"type\": \"EMAIL\"}") .asString();

C#

var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://apihml.unimedbh.io/security/v1/otp/request"); var content = new StringContent("{\"username\": \"teste@gmail.com\",\"type\": \"TYPE\"}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync());
Last updated on