Create a challenge
curl --request POST \
--url https://{defaultHost}/v1/auth/{app_id}/challengesimport requests
url = "https://{defaultHost}/v1/auth/{app_id}/challenges"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://{defaultHost}/v1/auth/{app_id}/challenges', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/v1/auth/{app_id}/challenges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/v1/auth/{app_id}/challenges"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{defaultHost}/v1/auth/{app_id}/challenges")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/auth/{app_id}/challenges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"challenge": {
"token": "ch_abc123xyz789",
"status": "pending",
"purpose": "authenticate",
"method": "email_otp",
"expires_at": "2023-11-07T05:31:56Z",
"remaining_attempts": 3,
"time_remaining": 540,
"intent": "<string>",
"delivery_required": true
}
}{
"error": "<string>",
"error_code": "invalid_request"
}{
"error": "User not found",
"error_code": "user_not_found"
}Challenges
Create a challenge
Create a new challenge for authentication, MFA, step-up verification, or custom flows.
Purposes:
authenticate- Primary login verification (returns session tokens on success)mfa- Second factor after primary auth (returns session tokens on success)step_up- Re-verify identity for sensitive actionsverify_contact- Verify email/phone ownershipverify_identity- KYC/identity verificationchange_identifier- Verify new email/phone before updatingcustom- Custom verification with callback
Methods:
email_otp- Send OTP code via emailsms_otp- Send OTP code via SMSmagic_link- Send magic link via emailtotp- Time-based OTP (authenticator app)backup_code- Use backup recovery codewebauthn- Passkey/security key verificationpush- Push notification approval
POST
/
v1
/
auth
/
{app_id}
/
challenges
Create a challenge
curl --request POST \
--url https://{defaultHost}/v1/auth/{app_id}/challengesimport requests
url = "https://{defaultHost}/v1/auth/{app_id}/challenges"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://{defaultHost}/v1/auth/{app_id}/challenges', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/v1/auth/{app_id}/challenges",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/v1/auth/{app_id}/challenges"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{defaultHost}/v1/auth/{app_id}/challenges")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/auth/{app_id}/challenges")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"challenge": {
"token": "ch_abc123xyz789",
"status": "pending",
"purpose": "authenticate",
"method": "email_otp",
"expires_at": "2023-11-07T05:31:56Z",
"remaining_attempts": 3,
"time_remaining": 540,
"intent": "<string>",
"delivery_required": true
}
}{
"error": "<string>",
"error_code": "invalid_request"
}{
"error": "User not found",
"error_code": "user_not_found"
}Was this page helpful?