15-day Pro trial · no credit cardStart free →

API & webhooks

Partner APIBeta

Server-to-server API for STINGIM partners and ISVs: authentication, endpoints and errors.

Partner program

The Partner API is available to agencies, e-commerce platforms and ISVs with a partner agreement. Partner accounts and API credentials are created by STINGIM — contact [email protected] to apply.

The Partner API lets you onboard and manage merchants programmatically: create a merchant (organisation + first project + owner account), set its plan and limits within your wholesale allotment, manage agents and teams, mint one-time console login links, read usage for billing, read conversations when the merchant allows it, and receive signed webhooks.

Base URL: https://api.stingim.com/v1/partner. All bodies are JSON (max 1 MiB). Every response carries an X-Request-Id header.

Authentication

Your credential is a key id (pk_…) and a secret (psk_…, shown once). Every request carries four headers:

HeaderValue
X-Partner-KeyKey id, e.g. pk_8Hq…
X-Partner-TimestampUnix time in seconds, within ±5 minutes of server time
X-Partner-Nonce16–64 characters [A-Za-z0-9_-], unique per request (a replay → 401 replayed_nonce)
X-Partner-Signaturev1= + lowercase hex HMAC-SHA256(secret, canonical)
Text
canonical = METHOD + "\n" +
            PATH_AND_QUERY + "\n" +   # escaped path, plus "?" + raw query when present, exactly as sent
            TIMESTAMP + "\n" +
            NONCE + "\n" +
            hex(SHA256(body))          # body bytes as sent; empty body → SHA256("")

For a GET the body hash is e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855. Keys can have an IP allowlist (403 ip_not_allowed). Rate limit: 600 requests / minute / key (429 rate_limited, Retry-After: 60).

import crypto from 'node:crypto';

export async function partnerFetch({ baseUrl, keyId, secret }, method, pathAndQuery, body, extraHeaders = {}) {
  const raw = body === undefined ? '' : JSON.stringify(body);
  const ts = Math.floor(Date.now() / 1000).toString();
  const nonce = crypto.randomBytes(16).toString('hex');
  const bodyHash = crypto.createHash('sha256').update(raw).digest('hex');
  const canonical = [method.toUpperCase(), pathAndQuery, ts, nonce, bodyHash].join('\n');
  const signature = 'v1=' + crypto.createHmac('sha256', secret).update(canonical).digest('hex');
  const res = await fetch(baseUrl + pathAndQuery, {
    method,
    headers: {
      'Content-Type': 'application/json',
      'X-Partner-Key': keyId,
      'X-Partner-Timestamp': ts,
      'X-Partner-Nonce': nonce,
      'X-Partner-Signature': signature,
      ...extraHeaders,
    },
    body: raw === '' ? undefined : raw,
  });
  return { status: res.status, body: await res.json() };
}

// await partnerFetch({ baseUrl: 'https://api.stingim.com', keyId, secret }, 'POST', '/v1/partner/merchants',
//   { name: 'Acme', owner: { email: '[email protected]' } }, { 'Idempotency-Key': 'acme-signup-42' });

Idempotency

  • POST /merchants requires Idempotency-Key (1–128 printable ASCII). Other POST / PUT calls honour it when present.
  • Keys are scoped per partner and kept for at least 24 hours. The same key with the same request replays the stored response with Idempotent-Replayed: true.
  • Same key, different request → 422 idempotency_mismatch; still in progress → 409 idempotency_in_progress. 5xx responses are not stored, so you can retry with the same key.

Errors

JSON
{ "error": { "code": "allotment_exceeded", "message": "seats: requested 5 exceeds remaining allotment 4 …",
             "details": { "metric": "seats", "allotment": 10, "allocated": 6, "requested": 5 } },
  "request_id": "req_…" }
Statuscode
400invalid_request, invalid_json, invalid_body, invalid_period, idempotency_key_required, invalid_idempotency_key
401malformed_auth, stale_timestamp, invalid_signature, replayed_nonce, unauthorized
403ip_not_allowed, partner_suspended, conversation_access_not_enabled
404not_found — also for merchants that belong to another partner
409quota_exceeded, team_limit, merchant_suspended, owner_email_taken, external_ref_taken, account_name_taken, email_taken, disabled_by_platform, conflict, idempotency_in_progress
413body_too_large
422allotment_exceeded, plan_not_allowed, plan_unavailable, idempotency_mismatch
429rate_limited
5xxinternal_error, unavailable, resume_pending — safe to retry with the same Idempotency-Key

Limits and allotment

Limits use -1 for unlimited.

FieldEnforced at
seatsAgent creation. The owner occupies one seat; the AI assistant does not.
ai_answers_per_monthAI bot replies (resets on the 1st, UTC).
ai_tokens_per_monthAI bot replies stop once the month's tokens reach the cap.
broadcasts_per_monthChat-channel marketing messages per calendar month.
channelsChannel / web widget creation.

The sum of your merchants' limits may not exceed your wholesale allotment (422 allotment_exceeded); -1 is only allowed when your allotment for that metric is unlimited. Plans must be in your allowed_plans. Partner-managed merchants cannot buy plans themselves or create extra projects.

Endpoints

MethodPathDescription
GET/accountYour contract: allowed plans, allotment, allocated limits, merchant count
POST/merchantsCreate a merchant (Idempotency-Key required) → 201
GET/merchants?status=active|suspended&limit=50&cursor=…List merchants, newest first (limit ≤ 100, next_cursor while more exist)
GET/merchants/{merchant_id}Get one merchant
POST/merchants/{merchant_id}/suspendSuspend: { "reason": "unpaid" }
POST/merchants/{merchant_id}/resumeResume access
PUT/merchants/{merchant_id}/planSwitch plan: { "plan_code": "ultimate" }
PUT/merchants/{merchant_id}/limitsPartial limits update, e.g. { "seats": 10, "ai_tokens_per_month": -1 }
POST / GET/merchants/{merchant_id}/agentsCreate (consumes a seat, returns an activation_url) / list agents
POST / GET/merchants/{merchant_id}/teamsCreate ({ "name", "description" }) / list teams (max 500)
POST/merchants/{merchant_id}/login-linksOne-time console login link for the owner, valid 5 minutes
GET/merchants/{merchant_id}/usageLimits, usage of the current month and AI usage (?period=YYYY-MM)
GET/merchants/{merchant_id}/conversation-accessRead-only conversation access state
POST/merchants/{merchant_id}/conversation-access/requestAsk the merchant to enable access: { "note": "…" }
GET/merchants/{merchant_id}/conversationsSearch conversations (needs access)
GET/merchants/{merchant_id}/conversations/{conversation_id}Conversation and contact
GET/merchants/{merchant_id}/conversations/{conversation_id}/messagesMessages, chronological, cursor-paged
GET/merchants/{merchant_id}/contacts/{contact_id}One contact

Create a merchant

JSON
{
  "name": "Acme Shop",
  "external_ref": "acme-42",
  "plan_code": "enterprise",
  "owner": { "email": "[email protected]", "name": "Alice", "language": "en", "time_zone": "Asia/Singapore" },
  "limits": { "seats": 5, "ai_answers_per_month": 2000, "ai_tokens_per_month": 2000000, "broadcasts_per_month": 10000, "channels": 4 }
}
  • plan_code defaults to your default plan. external_ref is your own id (optional, unique per partner).
  • Omitted limits default to the plan's quota for seats, channels and AI answers, and to unlimited (if your allotment is unlimited) or 0 for AI tokens and broadcasts. If the plan's quota is unlimited but your allotment is finite, pass the limit explicitly.
  • The organisation, project, owner account (no password), subscription and quotas are created atomically. The response includes owner.activation_url, a one-time link (default 7 days) where the owner sets a password. No email is sent — deliver it through your own channel.
JSON
{ "merchant": { "merchant_id": "1861…", "project_id": "1861…", "external_ref": "acme-42", "name": "Acme Shop",
                "status": "active", "plan_code": "enterprise", "owner_user_id": "1861…",
                "limits": { "seats": 5, "ai_answers_per_month": 2000, "ai_tokens_per_month": 2000000, "broadcasts_per_month": 10000, "channels": 4 },
                "created_at": "2026-11-28T08:00:00Z" },
  "owner": { "user_id": "1861…", "email": "[email protected]",
             "activation_url": "https://chat.stingim.com/partner-activate?token=…", "activation_expires_at": "…" } }

Suspending a merchant signs out every session, blocks logins, AI replies and broadcasts; a merchant disabled by STINGIM itself cannot be resumed by you (409 disabled_by_platform).

Create an agent

JSON
{ "account_name": "alice.support", "nickname": "Alice", "email": "[email protected]", "role": "agent",
  "team_ids": ["1862…"], "language": "en", "concurrent_reception_limit": 10, "reception_limit": 999 }

account_name is the login name (3–64 characters, starting with a letter); role is agent or admin. Returns a one-time activation_url.

Usage

JSON
{ "merchant_id": "1861…", "plan_code": "enterprise", "status": "active", "limits": { },
  "usage": { "period": "2026-11", "seats_used": 4, "channels_used": 2, "ai_answers": 812, "ai_tokens": 1534200,
             "broadcast_messages": 3100, "email_messages": 0, "conversations": 950, "messages": 18234 },
  "ai": { "from": "2026-11-01T00:00:00Z", "to": "2026-12-01T00:00:00Z", "unit": "ai_points", "totals": { }, "projects": [ ], "as_of": "…" } }

Monthly counters cover the current calendar month (UTC). messages is null if it could not be computed in time.

Read-only conversation access

You can read a merchant's conversations only after the merchant enables it (organisation admins, under Settings → Platform access log → Partner access). It is off by default, can be switched off at any time, and every read is logged in the merchant's platform access log. Without access, data endpoints return 403 conversation_access_not_enabled. Data endpoints are GET only, cover all projects of the merchant and are limited to 120 reads per minute per partner and merchant. Internal notes, whispers, AI configuration, visitor tokens, IP addresses and other secrets are never returned.

  • GET …/conversations query: keyword, contact_id, channel_code, project_id, from / to (YYYY-MM-DD or RFC 3339), page (≤ 1000), page_size (≤ 50, default 20).
  • GET …/messages?cursor=…&page_size=100 (≤ 200): only messages the customer saw. type: 1 text, 2 image, 3 voice, 4 video, 5 file, 33 email. attachment.url is a signed link valid for 5 minutes.

Partner webhooks

Configured for your partner account by STINGIM (public https:// URL on port 443). Same delivery rules as merchant webhooks: at-least-once, unordered, 8 attempts over about 24 hours.

HeaderExample
X-Partner-Eventquota.threshold
X-Partner-Deliverypwd_…
X-Partner-Signaturet=1764316800,v1=<hex(HMAC-SHA256(secret, "<t>.<raw body>"))>
JSON
{ "id": "evt_…", "type": "quota.threshold", "api_version": "2026-11-28", "created_at": "2026-11-28T08:00:00Z",
  "partner_id": "ptn_…", "data": { } }
Eventdata
merchant.created{ "merchant": <merchant> }
merchant.suspended{ "merchant": <merchant>, "reason": "…" }
merchant.resumed{ "merchant": <merchant> }
quota.threshold{ "merchant_id", "project_id", "external_ref", "metric", "threshold_percent": 80 | 100, "used", "limit", "period" }
merchant.conversation_access_changed{ "merchant_id", "conversation_access": "off" | "enabled", "changed_at" }
webhook.test{ "message": "test delivery" }

Verify exactly like merchant webhooks, using the X-Partner-Signature header.

Found a mistake? Email [email protected]