Security
Keeping your token safe
- Keep your token, and your signing secret if you have one, on your server only. Never put them in a web page or an app.
- Send the token in the
X-CC-Tokenheader, not in a URL. - If a token or secret is exposed, CoConnect replaces it in one click and the old one stops working.
Signing requests
Signing proves each request came from your server unchanged, within the last five minutes, and only once. A copied request cannot be altered or sent again. CoConnect gives you a signing secret (ccs_…) on request.
With the SDK (version 1.1 or later), pass the secret and every request is signed for you:
Node.js
const hub = new CoConnect({ token: process.env.COCONNECT_TOKEN, secret: process.env.COCONNECT_SECRET });Without the SDK, add two headers:
| Header | Value |
|---|---|
X-CC-Timestamp | The current time in Unix seconds, for example 1760870400 |
X-CC-Signature | v1= and the hex HMAC-SHA256 of the string below, keyed with your secret |
<timestamp>.<METHOD>.<path and query>.<raw body>
1760870400.POST./api/partner/events.{"event":"ftd","user":"u_1001","amount":75}- Sign the exact body you send: serialize the JSON once and send that same string. For GET the body is empty, so the string ends with a dot.
- Use a new timestamp for every attempt, retries included, and keep your server clock in sync.
Signing is optional while you switch over. Once every call is signed, CoConnect can require it, and unsigned calls are then refused.
Responses and errors
| Code | Meaning | What to do |
|---|---|---|
200 | Received. Each event shows queued (rewarded within seconds) or duplicate | Nothing |
400 | Missing event name or user, or more than 50 events | Fix and resend |
401 | Wrong or replaced token, or a bad or expired signature | Check your token, secret and clock |
403 | Your integration is paused | Contact CoConnect |
409 | The same signed request arrived twice | Sign each attempt with a new timestamp |
429, 503, 5xx | Too many requests, events paused, or a temporary error | Retry with backoff; nothing is lost |
Send events within five minutes of the action, because members are waiting for their reward.
Reference
- OpenAPI description, for generating a client in any language:
https://hub.coconnect.co/openapi.json - Node.js SDK: npmjs.com/package/@coconnect/sdk
- Python SDK: pypi.org/project/coconnect
Last updated on