Authenticate user and issue tokens
1 min
POST
https://api.upstartcommerce.com/api/v1/auth/login
Header Parameters
- AuthorizationstringExampleDescriptionPattern^Bearer .+$
- x-upstart-tenantstringExampleDescription
Body Parameters
- bodyLoginRequestrequiredDescription
- usernamestringrequiredExampleDescription
- passwordstring<password>requiredExampleDescriptionFormatpassword
- tokenTypestring<consumer | management>requiredExampleDescriptionAllowedconsumermanagement
Responses
200
- LoginResponseDescription
- mfaRequiredbooleanrequiredDescription
- accessTokenstringExampleDescription
- refreshTokenstringExampleDescription
- expiresIninteger<int64>ExampleDescriptionFormatint64
- tokenTypestringExampleDescription
- mfaChallengeIdstringExampleDescription
- mfaMethodstring<totp | sms>ExampleDescriptionAllowedtotpsms
- mfaExpiresIninteger<int64>ExampleDescriptionFormatint64
- mfaMaskedPhoneNumberstringExampleDescription
400
- 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
401
- ErrorResponseExample
{ "error": "unauthorized", "message": "Invalid username or password", "code": "UNAUTHORIZED" }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
403
- 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
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/login \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data-raw '{
"username": "[email protected]",
"password": "securePassword123",
"tokenType": "consumer"
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"username": "[email protected]",
"password": "securePassword123",
"tokenType": "consumer"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.upstartcommerce.com/api/v1/auth/login", 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/login")
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({
"username": "[email protected]",
"password": "securePassword123",
"tokenType": "consumer"
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.upstartcommerce.com/api/v1/auth/login"
payload = json.dumps({
"username": "[email protected]",
"password": "securePassword123",
"tokenType": "consumer"
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
200
// Authentication result. Either:
Successful authentication with tokens (mfaRequired=false or absent)
MFA challenge required (mfaRequired=true)
{
"mfaRequired": false,
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"tokenType": "Bearer",
"mfaChallengeId": "ch_abc123xyz",
"mfaMethod": "totp",
"mfaExpiresIn": 300,
"mfaMaskedPhoneNumber": "***1234"
}GENERATED
// Authentication result. Either:
Successful authentication with tokens (mfaRequired=false or absent)
MFA challenge required (mfaRequired=true)
{
"mfaRequired": false,
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"tokenType": "Bearer",
"mfaChallengeId": "ch_abc123xyz",
"mfaMethod": "totp",
"mfaExpiresIn": 300,
"mfaMaskedPhoneNumber": "***1234"
}successfulLogin
// Successful login (no MFA)
{
"mfaRequired": false,
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"tokenType": "Bearer"
}mfaRequired
// MFA verification required
{
"mfaRequired": true,
"mfaChallengeId": "ch_abc123xyz",
"mfaMethod": "totp",
"mfaExpiresIn": 300
}400
// Bad request - invalid JSON, missing fields, or tenant selection required
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}GENERATED
// Bad request - invalid JSON, missing fields, or tenant selection required
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}invalidRequest
// Invalid request body
{
"error": "invalid_request",
"message": "Failed to read request body",
"code": "BAD_REQUEST"
}tenantRequired
// Tenant selection required
{
"error": "tenant_required",
"message": "Multiple tenants available; tenant selection required via x-upstart-tenant header",
"code": "TENANT_REQUIRED"
}invalidTokenType
// Invalid token type
{
"error": "invalid_request",
"message": "Invalid token type. Must be 'consumer' or 'management'",
"code": "BAD_REQUEST"
}401
// Invalid credentials
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}403
// Forbidden - unauthorized tenant or no authorized tenants
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}GENERATED
// Forbidden - unauthorized tenant or no authorized tenants
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}unauthorizedTenant
// Unauthorized tenant
{
"error": "unauthorized_tenant",
"message": "User is not authorized for tenant: tenant-xyz",
"code": "UNAUTHORIZED_TENANT"
}noAuthorizedTenants
// No authorized tenants
{
"error": "forbidden",
"message": "User has no authorized tenants",
"code": "FORBIDDEN"
}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"
}