Issue or refresh an anonymous consumer token
1 min
POST
https://api.upstartcommerce.com/api/v1/auth/guest
Header Parameters
- x-upstart-tenantstringExampleDescription
- CookiestringExampleDescription
Responses
200
- GuestTokenResponseExample
{ "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "expiresIn": 3600, "tokenType": "Bearer" }Description- accessTokenstringrequiredExampleDescription
- expiresIninteger<int64>requiredExampleDescriptionFormatint64
- tokenTypestringrequiredExampleDescription
Response Headers
- Set-CookiestringExampleDescription
400
- ErrorResponseExample
{ "error": "tenant_required", "message": "x-upstart-tenant header is 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
429
- ErrorResponseExample
{ "error": "rate_limited", "message": "Too many guest token requests. Retry in 900s.", "code": "RATE_LIMITED" }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/guest \
--header 'accept: application/json'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var requestOptions = {
method: 'POST',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.upstartcommerce.com/api/v1/auth/guest", 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/guest")
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"
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.upstartcommerce.com/api/v1/auth/guest"
payload = {}
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
200
// Guest access token issued. The guest_session cookie in the response replaces
any previously presented cookie — always store the latest value.
{
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"tokenType": "Bearer"
}400
// Missing required x-upstart-tenant header
{
"error": "unauthorized",
"message": "Invalid username or password",
"code": "UNAUTHORIZED"
}429
// Rate limit exceeded
{
"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"
}