Authentication
Server-to-server calls use an API key sent in the x-api-key header. Keys are created by a CRM administrator in Settings → Integrations → API keys. They are not tied to a user, so they keep working when staff change.
x-api-key: am_3f9c…
The CRM stores only a hash of the key. Admins see it once, when it is created. If it is lost, they create a new key and revoke the old one.
Platform#
Each key is created for one platform name (2–40 characters: lowercase letters, digits, -, _), for example shopify, woo-eu or pos-main. The platform:
- tags every order, customer and lead sent with the key, and shows in the CRM as where the record came from;
- scopes your ids: order
1001fromshopifyand order1001frompos-mainare different orders; - is the default platform for
externalIdlookups in the read API; - appears as
origin.platformon webhooks, so you can ignore your own changes when they come back.
Use a separate platform name for each system that has its own ids. Use a separate key for each environment.
Scopes#
| Scope | Allows |
|---|---|
customers.write | POST /integrations/customers |
orders.write | POST /integrations/orders |
customers.read | GET /integrations/customers, GET /integrations/customers/{id} |
orders.read | GET /integrations/orders, GET /integrations/orders/{id} |
leads.write | POST /integrations/leads (and, for older keys, POST /integrations/customers) |
A request without the scope it needs gets 403 API_KEY_SCOPE. GET /integrations/me works with any key and shows its platform and scopes.
Signed requests (recommended)#
When an admin ticks Require signed requests, the key also gets a signing secret (whsec_…). Every request made with that key must then be signed. A key that leaked on its own is useless without the secret, and a captured request cannot be sent again.
Send two more headers:
x-timestamp: 1791282600
x-signature: sha256=<hex HMAC-SHA256(secret, x-timestamp + "." + rawBody)>
x-timestampis Unix time in seconds; milliseconds also work. Requests more than 5 minutes off are rejected.- Sign the exact bytes you send as the body. Serialise once, then sign and send that same string.
- Each signature is accepted once. Sign every retry again with a fresh timestamp.
GETrequests (the read API,/integrations/me) have no body, so they signx-timestamp + "."alone.
Node.js#
import crypto from 'node:crypto';
async function crmPost(path, payload) {
const body = JSON.stringify(payload);
const ts = Math.floor(Date.now() / 1000).toString();
const sig = crypto.createHmac('sha256', process.env.CRM_SIGNING_SECRET).update(`${ts}.${body}`).digest('hex');
const res = await fetch(`${process.env.CRM_URL}${path}`, {
method: 'POST',
headers: {
'content-type': 'application/json',
'x-api-key': process.env.CRM_API_KEY,
'x-timestamp': ts,
'x-signature': `sha256=${sig}`,
},
body,
});
return { status: res.status, body: await res.json() };
}
Python#
import hashlib, hmac, json, os, time, requests
def crm_post(path, payload):
body = json.dumps(payload, separators=(",", ":"))
ts = str(int(time.time()))
sig = hmac.new(os.environ["CRM_SIGNING_SECRET"].encode(), f"{ts}.{body}".encode(), hashlib.sha256).hexdigest()
return requests.post(
os.environ["CRM_URL"] + path,
data=body.encode(),
headers={
"content-type": "application/json",
"x-api-key": os.environ["CRM_API_KEY"],
"x-timestamp": ts,
"x-signature": f"sha256={sig}",
},
timeout=30,
)
PHP#
$body = json_encode($payload);
$ts = (string) time();
$sig = hash_hmac('sha256', $ts . '.' . $body, getenv('CRM_SIGNING_SECRET'));
$ch = curl_init(getenv('CRM_URL') . '/integrations/orders');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'content-type: application/json',
'x-api-key: ' . getenv('CRM_API_KEY'),
'x-timestamp: ' . $ts,
'x-signature: sha256=' . $sig,
],
]);
$response = curl_exec($ch);
Authentication errors#
| Status | code | Meaning |
|---|---|---|
| 401 | API_KEY_MISSING | No x-api-key header |
| 401 | API_KEY_INVALID | Unknown or revoked key |
| 401 | SIGNATURE_MISSING | The key requires signing and a header is missing |
| 401 | SIGNATURE_EXPIRED | x-timestamp is more than 5 minutes off; check the server clock |
| 401 | SIGNATURE_INVALID | Wrong secret, or the body was changed after signing |
| 401 | SIGNATURE_REPLAYED | This exact signed request was already received; sign retries again |
| 403 | API_KEY_SCOPE | The key lacks the scope for this endpoint |
Keeping keys safe#
- Keep keys and secrets in server-side configuration or a secret manager, never in code, browsers or mobile apps.
- Use one key per platform and environment, so a leak can be revoked without stopping everything else.
- To rotate: create the new key, deploy it, check it is used (Last used in the key list), then revoke the old key.