API v1 · WEBHOOKS

Mystoq Developer API

Connect your store to any external system — inventory tools, dashboards, or your own apps. Read your products and orders, create orders programmatically, and receive events the moment they happen via signed Webhooks.

Quickstart

Three steps from zero to your first programmatic order:

  1. Create an API key from Dashboard → Developers (choose the read or write scope).
  2. Send the key in the Authorization: Bearer header on every request.
  3. Call GET /v1/products, then register a Webhook URL to receive events.

Introduction

The Mystoq API is RESTful, returns JSON, and is secured with API keys. Every request runs strictly within your own store (full tenant isolation). Create your key from Dashboard → Developers.

Authentication

Pass your key in the Authorization header as a Bearer token. Keys look like msq_<prefix>_<secret>; the secret part is shown only once, at creation.

# Every request needs this header
Authorization: Bearer msq_ab12cd34_your_secret_here
Store the key securely. The read scope is read-only; the write scope is required to create orders.

Base URL & limits

Base URLhttps://mystoq.com/api/v1
FormatJSON (Accept: application/json)
Rate limit120 requests per minute per key
Paginationper_page param (1–100, default 25). Every list response includes meta.current_page, per_page, total, last_page.

Products

GET/v1/products

Lists your store’s published products (status = active), paginated.

Query parameters (optional)

per_pageItems per page (1–100, default 25).
searchSearch by product name.
category_idFilter by category id.
# Example
curl "https://mystoq.com/api/v1/products?per_page=2&search=jacket" \
  -H "Authorization: Bearer msq_ab12cd34_secret" \
  -H "Accept: application/json"
// Response
{
  "data": [
    { "id": 1027, "name": "Women's jacket", "slug": "womens-jacket",
      "price": 2000, "compare_price": 2800, "sku": "JCK-01",
      "stock": 100, "status": "active", "category_id": 4,
      "images": ["https://…/p1.jpg"] }
  ],
  "meta": { "current_page": 1, "per_page": 2, "total": 57, "last_page": 29 }
}
GET/v1/products/{id}

A single product. Returns 404 if not found or not published.

Orders

GET/v1/orders

Lists your store’s orders (paginated, newest first).

Query parameters (optional)

per_pageItems per page (1–100, default 25).
statusFilter by status (e.g. pending, confirmed, shipped, delivered, cancelled).
fromFrom date (inclusive), YYYY-MM-DD.
toTo date (inclusive), YYYY-MM-DD.
GET/v1/orders/{id}

A single order with its items and customer details.

// Order response
{
  "data": {
    "id": 5821, "reference": "ORD-5821", "status": "pending",
    "payment_method": "cod", "payment_status": "unpaid",
    "subtotal": 2000, "shipping_cost": 500, "discount": 0, "total": 2500,
    "delivery_type": "home", "wilaya_id": 16, "commune": "Bab Ezzouar",
    "customer": { "name": "Ahmed Ben Ali", "phone": "0555123456" },
    "items": [ { "product_id": 1027, "name": "Women's jacket", "price": 2000, "qty": 1, "total": 2000 } ],
    "created_at": "2026-07-18T20:00:00Z"
  }
}

Create an order

POST/v1/orders

Create an order programmatically. Requires a key with the write scope. The order passes through all store rules: server-side price recalculation, stock reservation and per-wilaya shipping fees.

Request body

customer.name optionalCustomer full name (or use first_name and last_name).
customer.phone requiredA 10-digit Algerian phone starting with 05, 06 or 07 — e.g. 0555123456.
customer.wilaya_id requiredWilaya id (1–69).
customer.commune optionalCommune.
items[] requiredOrder items: each has product_id (or bundle_id) and qty.
payment_method optionalPayment method: cod (default), chargily, ccp, baridimob
delivery_type optionalDelivery type: home (default) or desk (pickup desk).
curl -X POST "https://mystoq.com/api/v1/orders" \
  -H "Authorization: Bearer msq_ab12cd34_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": { "name": "Ahmed Ben Ali", "phone": "0555123456", "wilaya_id": 16, "commune": "Bab Ezzouar" },
    "items": [ { "product_id": 1027, "qty": 1 } ],
    "payment_method": "cod",
    "delivery_type": "home"
  }'
Success returns the order object with id, reference and totals. Webhook events fire automatically.

Webhooks

Register an https URL in the dashboard to receive instant POST notifications when events occur.

EventFires when
order.createdA new order is created in your store.
order.updatedAn order’s status changes (includes old_status and new_status).
// Payload sent to your URL
{
  "event": "order.created",
  "created_at": "2026-07-11T20:00:00Z",
  "data": {
    "id": 5821, "reference": "ORD-5821", "status": "pending",
    "total": 2500, "customer": { "name": "Ahmed", "phone": "0555…" }
  }
}

Verifying signatures

Every Webhook carries an X-Mystoq-Signature header = sha256=HMAC(secret, rawBody). Verify it to confirm the request is from Mystoq and the body was not tampered with.

// Node.js — verification example
const crypto = require("crypto");
const expected = "sha256=" +
  crypto.createHmac("sha256", SECRET).update(rawBody).digest("hex");
if (expected === req.headers["x-mystoq-signature"]) { /* trusted */ }
Respond with 2xx within 8 seconds. On failure we retry up to 4 times with increasing back-off.

Errors

CodeMeaning
200 / 201Success
401Invalid or missing key
403Key lacks the required scope (write)
404Resource not found
422Validation failed (details in errors)
429Rate limit exceeded