E-commerce

Authentication

Elective Commerce uses API keys to authenticate requests. You can view and manage your API keys in the Dashboard.

This site allows you to test endpoints live.
Paste your public key in the top header, and ensure https://docs.electivecommerce.com is added to your allowed origins in the Dashboard.

Base URL

https://api.electivecommerce.com/v1

1 Key Types

pk_live_...

Safe for client-side code (browsers, mobile apps). Read-only access to published products and collections.

Listing Products
Creating Carts
Creating Orders (Requires Secret)
sk_live_...

Server-side only. Full read/write access. Never expose this key in frontend code.

Managing Inventory
Processing Payments
Viewing Drafts

2 Usage

Authenticate your API calls by including your key in the Authorization header of every request.

HTTP Header
Authorization: Bearer pk_live_12345...

3 Allowed Origins (CORS)

Important

Public API keys are protected by strict CORS policies. You must whitelist your domain (e.g. https://www.mystore.com) in the Dashboard > Settings page.

Requests from unauthorized domains will be rejected with 403 Forbidden.

4 Example

JavaScript
fetch('https://api.electivecommerce.com/v1/products', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer pk_live_12345...',
    'Content-Type': 'application/json'
  }
})
.then(response => response.json())
.then(data => console.log(data));