Quick answer · Custom development · 2 min read
Wix Headless: which login or ID should my code use?
Use the headless client's Client ID for visitors and members. Wix says it's safe in frontend code. Admin calls, like updating stock or querying all orders, go in backend code only, with client credentials or an API key. On Wix's Astro integration, visitor and member logins are handled for you.
Key points
- Visitors and members need only the Client ID, which is safe in frontend code.
- Admin operations run in backend code only, with client credentials or an API key.
- Use an API key for account-level work or integrations beyond your project's own site.
For anything a visitor or member does, your code uses the headless client's Client ID. Wix calls it the public identifier of your headless client and says it's safe to use in frontend code. Anything that needs more permissions, like updating stock or querying every order, is an admin operation. That runs in backend code only, with client credentials or an API key. If you build with Wix's Astro integration, Wix handles visitor and member logins for you.
Which credential goes with which job?
- Find your Client ID. In the project dashboard, go to Settings, then Development & integrations, then Headless Settings. On a Wix-managed project, the appId in wix.config.json is the same client ID.
- Visitors use the Client ID only. Wix says visitor and member authentication needs only a client ID, not a client secret. The JavaScript SDK creates visitor tokens on your first API call. With REST, you request tokens yourself, and access tokens expire after 4 hours. Store and restore the tokens if you want a cart to survive page loads.
- Members use the Client ID too. Logged-in members go through a Wix login page or your own login flow, still on the client ID.
- Admin operations stay on the server. Wix gives examples like creating members, updating inventory, issuing refunds and querying all orders. On the Astro integration, you elevate the call in backend code. On any other setup, Wix recommends client credentials, using the client secret. You only see the secret once when you generate it, so store it safely.
- Use an API key for wider access. For account-level operations or integrations beyond your project's own site, Wix says to use an API key. Each call needs either a site ID or an account ID header, not both. Give each key the narrowest set of sites it needs.
The rule that matters most: the client secret and API keys never go in browser code. Wix's docs repeat it on every admin page. Want the full picture? Read how we rebuilt our own website on Wix Headless. If you'd like a hand with your setup, see our Wix Headless service.
Sources
- Wix Headless: About Authentication (Wix Developers)
- Wix Headless: Authenticate Visitors (REST) (Wix Developers)
- Wix Headless: About Admin Operations (Wix Developers)
- Wix Headless: Make Admin API Calls with Client Credentials (Wix Developers)
- Wix Headless: Generate an API Key (Wix Developers)
- Wix Headless: Set Up a Headless Client (Wix Developers)