Create your secret websiteID.
Sign in to your Neurvance account, choose a Neurvance plan, and then open the Cube dashboard. Once payment is verified, choose Create API key and copy your secret websiteID. Canceling renewal keeps API access until the paid period ends. If a renewal payment fails, update your payment method in Manage billing to restore access after payment is verified.
- Choose Create API key in the dashboard.
- Copy the complete key when it appears. It is shown only once.
- Save this one secret as SHOP_WEBSITE_ID on your server. It is also your API key.
Your websiteID is your secret API key. These names refer to one credential. It is shown only when created or rotated. Cube keeps its own account identifiers internal; you do not need a separate public ID.
How do I generate a replacement credential?
With an active subscription, choose Rotate API key. Copy the new secret websiteID and update SHOP_WEBSITE_ID on your website server. The old credential immediately stops working. Your saved data and your products stay with your website.
Keep the key on your server.
The browser sends its measurements to your own server. Your server adds the secret websiteID and calls Cube over HTTPS. Never put the key in frontend code, browser storage, URLs, or logs. Cube accepts HTTPS only; a plain HTTP request is refused with 400. The calls you can make are /upload, /main and /perbuy, plus the products page.
SHOP_API_URL=https://YOUR_CUBE_API_ADDRESS
SHOP_WEBSITE_ID=YOUR_SECRET_WEBSITEID_API_KEYUse the Cube API address shown in your Cube dashboard. Add these values in your hosting provider’s private environment settings. With Python, install requests and use this helper:
import os
import requests
# Run on YOUR WEBSITE SERVER. Never send this key to a browser.
def cube_request(path, payload):
response = requests.post(
os.environ["SHOP_API_URL"].rstrip("/") + path,
headers={"Authorization": "Bearer " + os.environ["SHOP_WEBSITE_ID"]},
json=payload,
timeout=(3, 25),
allow_redirects=False,
)
response.raise_for_status()
return response.json()Every request is a JSON object sent with POST and Content-Type: application/json. Send the key in the Authorization: Bearer header. If you cannot set headers, put it in the JSON body as "websiteID" instead. Call this helper from your own protected server routes, check browser request origins, and never accept another visitor’s data as your own.
Send six numbers every 10 seconds.
While a visitor is on your website, your server sends POST /upload every ten seconds with what the visitor has done so far. Cube saves it in your website’s history, which is what later predictions are based on.
{
"bought_number": 0,
"avgSpeed": 120,
"avgCordinates": [640, 360],
"productsSeen": 6,
"productsClciked": 2,
"clicks": 14
}# every 10 seconds, for each visitor on your website
visit = {
"bought_number": 0, # products bought in this visit (verified orders only)
"avgSpeed": 120, # average mouse speed
"avgCordinates": [640, 360], # average mouse position [x, y]
"productsSeen": 6, # products the visitor has seen
"productsClciked": 2, # products the visitor has clicked
"clicks": 14, # mouse clicks
}
result = cube_request("/upload", visit) # {"ok": true}A saved upload returns {"ok": true}. 403 means your subscription is not active. When your order system has verified a payment, send the visit’s next upload with bought_number set to the number of products bought — product quantity, not money spent. Never trust a browser’s claim that an order was paid.
Field types and validation
- Send all six fields in every upload. The names are exact, including
productsClciked. bought_number,productsSeen,productsClcikedandclicksare whole numbers of 0 or more.avgSpeedis a number of 0 or more. Cube stores it rounded to a whole number.avgCordinatesis a list[x, y]of two numbers of 0 or more, for example[640, 360].- A wrong or missing field returns
400with a message naming the field, and nothing is saved.
Tell Cube what you sell.
Open the products page at your Cube API address followed by /products. The dashboard shows the full link. Paste your secret websiteID to connect, then add each product with a name, a short bio (its description) and a price. You can delete products there too.
- Cube reads each bio once, when you add it, and uses it to suggest the best product for a visitor.
- Only your own products are shown, and only you can delete them.
- Names are up to 200 characters, bios up to 2,000, and prices are 0 or more.
Add your products before you use /main. The secret websiteID is kept only while the products page is open; it is never saved in the browser.
Ask about the current visit.
Send what the visitor is doing right now as currentlyDoing, using the same numbers as the upload: speed is avgSpeed, clicks is clicks, clicked is productsClciked, and productsSeen is productsSeen.
POST /main returns the layout commands for this visitor and, when the product on screen is not the best fit, the product to show instead. Put the bio of the product the visitor is looking at in shown.
{
"shown": "Light linen shirt in sand, relaxed fit.",
"currentlyDoing": {
"speed": 120,
"clicks": 14,
"clicked": 2,
"productsSeen": 6
}
}{
"commands": ["moreProducts()"],
"spendMore": "moreProducts()",
"best": "Wool overshirt in navy, regular fit."
}commandsis a list ofmoreProducts()(show more products) andlessProducts()(show fewer). It can be empty.spendMoreismoreProducts()when the visitor moves faster than your usual visitors, otherwise empty text.bestis the bio of one of your products to feature, ornullwhen the shown product already fits.
POST /perbuy returns the visitor’s chance of buying as one sentence:
{
"currentlyDoing": {
"speed": 120,
"clicks": 14,
"clicked": 2,
"productsSeen": 6
}
}{
"result": "The user has a chance of buying 2.0 products"
}Predictions start when your website has 1,000 saved rows. Until then, and when the subscription is not active, both calls answer with HTTP 200 and a message (for /main) or result (for /perbuy) such as “Not enough data to make a prediction. Please wait until more data is collected.” The dashboard shows how far your website is.
Commands are plain text. Compare them with your own list of actions; never evaluate response strings as code. These calls do not save anything.
Delete your saved data.
In the Cube dashboard, use Delete all Cube data. Enter your current secret websiteID and type DELETE. Cube removes every row it saved for your website. Your products, subscription, account and API key stay. Deleting your Neurvance account also cancels the subscription and removes your Cube data and products.
Handle errors deliberately.
| Response | What to do |
|---|---|
| 400 | Read the message: a field is missing or has the wrong type, the body is not a JSON object, or the request was sent over plain HTTP instead of HTTPS. |
| 401 | Check the secret key. It may be expired, revoked, or replaced. |
| 403 | Check the paid subscription. Open Manage billing to renew or update your payment method. |
| 404 | The product does not exist or belongs to another website. |
| 500 | Retry later with backoff. Contact support if it keeps happening. |
Errors come back as JSON: {"error": "message"}. Retry only after you have fixed the cause.