Verify MFA code and complete authentication
1 min
POST
https://api.upstartcommerce.com/api/v1/auth/mfa/verify
Body Parameters
- bodyMfaVerifyRequestrequiredExample
{ "challengeId": "ch_abc123xyz", "code": "123456" }Description- challengeIdstringrequiredExampleDescription
- codestringrequiredExampleDescriptionMin Length6Max Length10
Responses
200
- AuthResponseExample
{ "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "refreshToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "expiresIn": 3600, "tokenType": "Bearer" }Description- accessTokenstringrequiredExampleDescription
- refreshTokenstringrequiredExampleDescription
- expiresIninteger<int64>requiredExampleDescriptionFormatint64
- tokenTypestringrequiredExampleDescription
400
- ErrorResponseExample
{ "error": "invalid_request", "message": "Challenge ID and code are required", "code": "BAD_REQUEST" }Description- errorstringrequiredExampleDescription
- messagestringrequiredExampleDescription
- codestring<BAD_REQUEST | UNAUTHORIZED | UNAUTHORIZED_TENANT | TENANT_REQUIRED | FORBIDDEN | RATE_LIMITED | ACCOUNT_LOCKED | INTERNAL_SERVER_ERROR>requiredExampleDescriptionAllowedBAD_REQUESTUNAUTHORIZEDUNAUTHORIZED_TENANTTENANT_REQUIREDFORBIDDENRATE_LIMITEDACCOUNT_LOCKEDINTERNAL_SERVER_ERROR
401
- ErrorResponseDescription
- errorstringrequiredExampleDescription
- messagestringrequiredExampleDescription
- codestring<BAD_REQUEST | UNAUTHORIZED | UNAUTHORIZED_TENANT | TENANT_REQUIRED | FORBIDDEN | RATE_LIMITED | ACCOUNT_LOCKED | INTERNAL_SERVER_ERROR>requiredExampleDescriptionAllowedBAD_REQUESTUNAUTHORIZEDUNAUTHORIZED_TENANTTENANT_REQUIREDFORBIDDENRATE_LIMITEDACCOUNT_LOCKEDINTERNAL_SERVER_ERROR
403
- ErrorResponseExample
{ "error": "forbidden", "message": "Account locked due to too many failed MFA attempts", "code": "FORBIDDEN" }Description- errorstringrequiredExampleDescription
- messagestringrequiredExampleDescription
- codestring<BAD_REQUEST | UNAUTHORIZED | UNAUTHORIZED_TENANT | TENANT_REQUIRED | FORBIDDEN | RATE_LIMITED | ACCOUNT_LOCKED | INTERNAL_SERVER_ERROR>requiredExampleDescriptionAllowedBAD_REQUESTUNAUTHORIZEDUNAUTHORIZED_TENANTTENANT_REQUIREDFORBIDDENRATE_LIMITEDACCOUNT_LOCKEDINTERNAL_SERVER_ERROR
500
- ErrorResponseDescription
- errorstringrequiredExampleDescription
- messagestringrequiredExampleDescription
- codestring<BAD_REQUEST | UNAUTHORIZED | UNAUTHORIZED_TENANT | TENANT_REQUIRED | FORBIDDEN | RATE_LIMITED | ACCOUNT_LOCKED | INTERNAL_SERVER_ERROR>requiredExampleDescriptionAllowedBAD_REQUESTUNAUTHORIZEDUNAUTHORIZED_TENANTTENANT_REQUIREDFORBIDDENRATE_LIMITEDACCOUNT_LOCKEDINTERNAL_SERVER_ERROR
curl
curl --request POST \
--url https://api.upstartcommerce.com/api/v1/auth/mfa/verify \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"challengeId": "ch_abc123xyz",
"code": "123456"
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"challengeId": "ch_abc123xyz",
"code": "123456"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.upstartcommerce.com/api/v1/auth/mfa/verify", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.upstartcommerce.com/api/v1/auth/mfa/verify")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump({
"challengeId": "ch_abc123xyz",
"code": "123456"
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.upstartcommerce.com/api/v1/auth/mfa/verify"
payload = json.dumps({
"challengeId": "ch_abc123xyz",
"code": "123456"
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
200
// MFA verification successful - tokens issued
{
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1NTBl...",
"refreshToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1NTBl...",
"expiresIn": 3600,
"tokenType": "Bearer"
}400
// Invalid request
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}401
// Invalid MFA code or challenge expired
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}GENERATED
// Invalid MFA code or challenge expired
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}invalidCode
// Invalid MFA code
{
"error": "unauthorized",
"message": "Invalid MFA code. 4 attempts remaining.",
"code": "UNAUTHORIZED"
}challengeExpired
// Challenge expired
{
"error": "unauthorized",
"message": "MFA challenge has expired. Please login again.",
"code": "UNAUTHORIZED"
}403
// Account locked due to too many failed attempts
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}500
// Internal server error
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}GENERATED
// Internal server error
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}tokenGenerationFailed
// Token generation failed
{
"error": "internal_error",
"message": "Token generation failed",
"code": "INTERNAL_SERVER_ERROR"
}serviceError
// Upstream service error
{
"error": "internal_error",
"message": "Failed to communicate with authentication backend",
"code": "INTERNAL_SERVER_ERROR"
}