Auth
Verify MFA
Confirm a TOTP code against the pending secret, enable MFA, and receive one-time backup codes.
POST
/
v1
/
auth
/
mfa
/
verify
Confirm and enable TOTP MFA
curl --request POST \
--url https://billing.example.com/v1/auth/mfa/verify \
--header 'Content-Type: application/json' \
--cookie recurso_session= \
--data '
{
"code": "<string>"
}
'import requests
url = "https://billing.example.com/v1/auth/mfa/verify"
payload = { "code": "<string>" }
headers = {
"cookie": "recurso_session=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'recurso_session=', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>'})
};
fetch('https://billing.example.com/v1/auth/mfa/verify', 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://billing.example.com/v1/auth/mfa/verify",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>'
]),
CURLOPT_COOKIE => "recurso_session=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/auth/mfa/verify"
payload := strings.NewReader("{\n \"code\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "recurso_session=")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/auth/mfa/verify")
.header("cookie", "recurso_session=")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/auth/mfa/verify")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'recurso_session='
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"mfa_enabled": true,
"backup_codes": [
"<string>"
]
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Validates a TOTP code against the secret issued by
Begin MFA Setup, enables MFA for the
logged-in user, and returns a fresh set of ten one-time backup codes. The
backup codes are shown exactly once — only their hashes are stored — so
display them to the user immediately. Any backup codes from a previous
enrollment are replaced. After this call, logins complete via
Complete an MFA Login.
Requires a logged-in user session; API-key callers receive
Errors use the standard envelope — see Errors.
401.
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | The current 6-digit TOTP code from the authenticator app. |
Example Request
curl -X POST https://api.recurso.dev/v1/auth/mfa/verify \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{
"code": "482913"
}'
Example Response
{
"mfa_enabled": true,
"backup_codes": [
"K7Q2M-3XR4T",
"P3ZH5-W6NDC",
"A5YJ4-L2VB7",
"T2RM6-Q3XKF",
"G4WN2-H7PZD",
"C6BV7-J5TAM",
"X2LK6-N4RQW",
"M5DF3-Z7HYB",
"R5PT4-V2KCJ",
"H3NX6-B2QLW"
]
}
Fields
| Field | Type | Description |
|---|---|---|
mfa_enabled | boolean | Always true on success. |
backup_codes | array of string | Ten one-time recovery codes, formatted XXXXX-XXXXX. Each can be used once in place of a TOTP code; they are not retrievable after this response. |
Errors
| Status | Code | When | Fix |
|---|---|---|---|
| 400 | validation_failed | code is missing, or it does not match the pending secret (invalid code). | Send the current code from the authenticator; check the device clock. |
| 401 | unauthorized | No live session cookie, or the caller authenticated with an API key rather than a user session. | Sign in via /auth/login and send the recurso_session cookie. |
| 409 | conflict | MFA is already enabled, or setup has not been started (no pending secret). | Call Begin MFA Setup first; if already enabled, no action is needed. |
| 500 | internal_error | MFA could not be enabled or the backup codes could not be stored. | Retry; contact support if it persists. |
Authorizations
Dashboard user session cookie (httpOnly) issued by POST /auth/register and POST /auth/login. v1 endpoints accept EITHER this cookie or the tenant API key (bearerAuth).
Body
application/json
⌘I
Confirm and enable TOTP MFA
curl --request POST \
--url https://billing.example.com/v1/auth/mfa/verify \
--header 'Content-Type: application/json' \
--cookie recurso_session= \
--data '
{
"code": "<string>"
}
'import requests
url = "https://billing.example.com/v1/auth/mfa/verify"
payload = { "code": "<string>" }
headers = {
"cookie": "recurso_session=",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {cookie: 'recurso_session=', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>'})
};
fetch('https://billing.example.com/v1/auth/mfa/verify', 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://billing.example.com/v1/auth/mfa/verify",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>'
]),
CURLOPT_COOKIE => "recurso_session=",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/auth/mfa/verify"
payload := strings.NewReader("{\n \"code\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("cookie", "recurso_session=")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/auth/mfa/verify")
.header("cookie", "recurso_session=")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/auth/mfa/verify")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["cookie"] = 'recurso_session='
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"mfa_enabled": true,
"backup_codes": [
"<string>"
]
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}