Skip to main content

Storefront Auth API

The Storefront Auth controller (api/storefront-auth.php, base auth) mirrors StoreEngine's storefront login, registration, and password-reset forms over REST. It calls WordPress core primitives, so behavior is identical whether a shopper submits the classic form or a JS/headless client hits these routes.

Authentication

All four routes are public (__return_true), except registration, which is additionally gated by WordPress's "Anyone can register" setting.

Same-origin only for the cookie session

POST /auth/login sets the standard WordPress auth cookie via wp_signon(). That cookie can only be set for the same origin — you cannot establish a cookie session cross-origin. Cross-origin headless storefronts should authenticate with Application Passwords instead. Protect same-origin calls with the WP REST nonce (X-WP-Nonce).

Routes

MethodPathPurpose
POST/auth/loginSign in; sets the WP auth cookie
POST/auth/registerCreate a customer account (+ auto-login)
POST/auth/forgot-passwordRequest a reset email
POST/auth/reset-passwordFinalize the reset with key + login

All paths are relative to /wp-json/storeengine/v1.

POST /auth/login

POST /wp-json/storeengine/v1/auth/login

ParamTypeRequiredNotes
usernamestringyesUsername or email.
passwordstringyes
rememberbooleannoPersistent session. Default false.
redirect_tostring (uri)noPost-login redirect. Defaults to the dashboard (or wp-admin for admins).
curl -X POST https://your-store.example/wp-json/storeengine/v1/auth/login \
-H "Content-Type: application/json" \
-H "X-WP-Nonce: $NONCE" --cookie-jar cookies.txt \
-d '{ "username": "[email protected]", "password": "secret", "remember": true }'

On success the WP auth cookie is issued and the response is:

{
"message": "You have logged in successfully. Redirecting...",
"redirect_url": "https://your-store.example/dashboard/",
"user": { "id": 12, "display_name": "Ada Lovelace", "email": "[email protected]" }
}

Bad credentials return storeengine_auth_failed (401). A stale auth cookie is cleared before each attempt so a failed login never leaves the previous session in place.

POST /auth/register

POST /wp-json/storeengine/v1/auth/register

Creates a storeengine_customer account. Returns storeengine_registration_closed (403) if site registration is disabled.

ParamTypeRequiredNotes
emailstring (email)yesMust be unique (storeengine_register_email_taken, 409).
passwordstringyesMinimum length filterable via storeengine/auth/min_password_length (default 8).
first_namestringno
last_namestringno
auto_loginbooleannoDefault true; sign the new user in immediately.

The username is derived from the email local-part (dedup'd with a numeric suffix), matching the auto-create-on-checkout flow. Registration fires storeengine/checkout/customer_created, so the welcome email is sent on REST signup too. Success returns { message, redirect_url, user: { id, email, login } }.

POST /auth/forgot-password

POST /wp-json/storeengine/v1/auth/forgot-password

ParamTypeRequired
emailstring (email)yes

Triggers retrieve_password(), sending the branded reset email. To prevent account enumeration, the response is always generic regardless of whether the email matches an account:

{ "message": "If an account exists with that email, a reset link is on its way." }

POST /auth/reset-password

POST /wp-json/storeengine/v1/auth/reset-password

Finalizes the reset using the key and login from the emailed link.

ParamTypeRequiredNotes
keystringyesReset key from the email.
loginstringyesUsername from the email.
passwordstringyesSubject to the same minimum-length filter.

An invalid or expired link returns storeengine_reset_expired (410). Success fires WordPress's password_reset action and returns { message, redirect_url }.

  • Authentication — the full auth model and headless options.
  • Me API — the account dashboard the shopper lands on after login.