post
https://www.locally.com/headless/api/1.0/cart/validate_email
Validate a customer email address during checkout.
Request Parameters
🏷️ header · unmarked parameters are query params
| Parameter | Type | Required | Description |
|---|---|---|---|
Locally-Api-Token 🏷️ | string | Yes | Locally API token must be passed in the header to authenticate the API consumer. |
email | string | Yes | The domain of the host website. |
Example Request
curl 'https://www.locally.com/headless/api/1.0/cart/validate_email' \
--request POST \
--header 'Locally-Api-Token: {{API_TOKEN}}' \
--url-query '[email protected]'const response = await fetch(
'https://www.locally.com/headless/api/1.0/cart/[email protected]',
{
method: 'POST',
headers: {
'Locally-Api-Token': '{{API_TOKEN}}'
}
}
);
const data = await response.json();import requests
response = requests.post(
"https://www.locally.com/headless/api/1.0/cart/validate_email",
params={"email": "[email protected]"},
headers={"Locally-Api-Token": "{{API_TOKEN}}"},
)
data = response.json()email is the shopper's email address to validate. Validation checks the address format and confirms the domain has valid MX records; an invalid address still returns HTTP 200, with data.is_valid set to 0.
Example Response
{
"success": true,
"data": {
"email": "[email protected]",
"is_valid": 1,
"session": {
"id": "hVQmXAY0f0mB0m5AqEHOZLR2FDATcQxrxWpplUUb"
}
},
"msg": ""
}{
"success": true,
"data": {
"email": "[email protected]",
"is_valid": 0,
"session": {
"id": "hVQmXAY0f0mB0m5AqEHOZLR2FDATcQxrxWpplUUb"
}
},
"msg": ""
}Response Explanation
success—truewhenever validation completes, even for an invalid address. Only request-level failures (bad token, server error) returnsuccess: false, with the error text inmsgand anerror_code.data.email— Echo of the submitted address with surrounding whitespace trimmed.data.is_valid—1or0(integer, not boolean).1requires both a syntactically valid address and MX records on its domain; otherwise0— check this field, notsuccess.data.session.id— The current session ID. It can change between calls, so always send the latest value in theLocally-Api-Session-Idheader on your next request. Session IDs eventually expire.
200Successful
400Bad Request
401Unauthorized
402Request Failed
403Forbidden
404Not Found
429Too Many Requests
500Server Error

