Validate cart email

Validate a customer email address during checkout.

Request Parameters

🏷️ header · unmarked parameters are query params

ParameterTypeRequiredDescription
Locally-Api-Token 🏷️stringYesLocally API token must be passed in the header to authenticate the API consumer.
emailstringYesThe 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

  • successtrue whenever validation completes, even for an invalid address. Only request-level failures (bad token, server error) return success: false, with the error text in msg and an error_code.
  • data.email — Echo of the submitted address with surrounding whitespace trimmed.
  • data.is_valid1 or 0 (integer, not boolean). 1 requires both a syntactically valid address and MX records on its domain; otherwise 0 — check this field, not success.
  • data.session.id — The current session ID. It can change between calls, so always send the latest value in the Locally-Api-Session-Id header on your next request. Session IDs eventually expire.
Query Params
string
required

The domain of the host website.

Headers
string
required

Locally API token must be passed in the header to authenticate the API consumer

Responses
200

Successful

400

Bad Request

401

Unauthorized

402

Request Failed

403

Forbidden

404

Not Found

429

Too Many Requests

500

Server Error

Language
LoadingLoading…
Response
Click Try It! to start a request and see the response here!