- Home
- Enterprise
- Docs
Enterprise Integration Docs
Connect your trading systems to Pinbar AI in minutes
JavaScript/TypeScript SDK
Push trades, fetch analytics, and manage evaluations from any JS environment.
Integration Guide
Everything you need to connect your trading systems to Pinbar AI
Generate an API Key
Go to your Enterprise Dashboard → Integration Setup and click Generate New Key. Copy it — it's shown only once.
Send Your First Trade
Replace YOUR_API_KEY with your actual key:
curl -X POST "https://api.pinbar.ai/v1/v1-trades" \
-H "Authorization: Bearer pnbr_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"trades": [{
"external_id": "test-001",
"symbol": "EURUSD",
"side": "buy",
"entry_price": 1.0850,
"exit_price": 1.0875,
"quantity": 1.0,
"entry_time": "2026-04-10T14:30:00Z",
"exit_time": "2026-04-10T15:45:00Z",
"profit_loss": 25.00,
"account_id": "test-trader-1"
}]
}'Check the Dashboard
Your trade will appear in the Traders tab within seconds.
Response Codes
Standard HTTP status codes returned by all API endpoints.
| Code | Meaning | Action |
|---|---|---|
| 200 | Success | Request processed successfully |
| 201 | Created | Resource created (e.g., trade ingested) |
| 400 | Bad Request | Check request body — missing or invalid fields |
| 401 | Unauthorized | Invalid or missing API key in Authorization header |
| 429 | Rate Limited | Too many requests — wait and retry. Check X-RateLimit-Reset header |
| 500 | Server Error | Unexpected error — retry with exponential backoff. Contact support if persistent |
Rate Limits
All API endpoints are rate-limited per API key. Limits are included in response headers.
Rate limit headers are included in every response:
X-RateLimit-Limit— Maximum requests per windowX-RateLimit-Remaining— Requests remaining in current windowX-RateLimit-Reset— Unix timestamp when the window resets
Need higher limits? Contact us for custom rate limits.
Outbound Webhooks
Subscribe to real-time events (trade.ingested, risk.alert.triggered) delivered as signed HTTPS POST requests with automatic retries (5 attempts, exponential backoff).
Headers sent on every delivery (v1)
X-Pinbar-Signature: t=<unix>,n=<nonce>,v1=<hex>— HMAC-SHA256 of`$${t}.$${n}.$${body}`using your webhook secretX-Pinbar-Timestamp— Unix seconds at the time of signingX-Pinbar-Nonce— Per-delivery random UUID for replay protectionX-Pinbar-Event— Event type (e.g.trade.ingested)X-Pinbar-Delivery— Stable delivery UUID for idempotencyX-Pinbar-Signature-Version: v1
Verify the signature (Node.js)
import crypto from "crypto";
const TOLERANCE_SECONDS = 300; // reject deliveries older than 5 minutes
const seenNonces = new Set(); // back this with Redis in production
export function verifyPinbarWebhook(rawBody, headers, secret) {
const sig = headers["x-pinbar-signature"] || "";
const parts = Object.fromEntries(sig.split(",").map(p => p.split("=")));
const t = Number(parts.t), n = parts.n, provided = parts.v1;
if (!t || !n || !provided) throw new Error("malformed signature");
if (Math.abs(Date.now() / 1000 - t) > TOLERANCE_SECONDS) {
throw new Error("timestamp out of tolerance");
}
if (seenNonces.has(n)) throw new Error("replay detected");
seenNonces.add(n);
const expected = crypto.createHmac("sha256", secret)
.update(`${t}.${n}.${rawBody}`)
.digest("hex");
if (!crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(provided))) {
throw new Error("signature mismatch");
}
}Configure webhooks in your firm dashboard under Integrations → Webhooks. Rotate the signing secret any time from the same screen — the new secret is shown exactly once and immediately activates the v1 signature for that endpoint. Toggle between live and test environments to safely build integrations.
Migrating from v0 → v1
Webhooks created before June 2026 deliver legacy v0 signatures (sha256=<hex> of the raw body, header X-Pinbar-Signature-V0). We recommend upgrading to v1 within 90 days:
- Deploy the v1 verifier above alongside your existing v0 handler so both are accepted.
- Open Integrations → Webhooks and click Rotate Secret. The new secret is shown exactly once — copy it into your verifier.
- Rotation atomically flips the endpoint to v1 and starts signing every subsequent delivery with the new format.
- Once you've confirmed v1 deliveries are validating, remove the v0 fallback code.
Rotation is one-way — v0 secrets cannot be restored. Both signature formats use the same secret material, so failed retries from before rotation will still verify if you keep v0 enabled briefly.
Sandbox API Keys
Keys prefixed with pnbr_test_ operate in an isolated sandbox environment — they only deliver to webhooks marked as test and don't affect live analytics. Use them for staging, CI, and integration testing.
Live System Status
Real-time uptime, latency percentiles, and incident timeline.