πŸ”Private API Access

Authenticated Routes

Signed API request are required when interacting with:

  • /v1/balances/*

  • /v1/users/*

  • /v1/payouts/*

When generating an API Client key, you’ll receive:

  • Public Key (Base58) – stored by Swapped

  • Private Key (Base58, 32 bytes) – used to sign requests

⚠️ Your Commerce API Client private key is never stored by Swapped. If lost, it cannot be recovered β€” generate a new key instead.

Signing Requests

Every signed API request must include a signature generated from a canonical string. This canonical string is a strict, concatenated sequence of values from the request β€” no separators, no whitespace, and no JSON formatting.

Canonical String Format

{METHOD}{PATH}{TIMESTAMP}{IDEMPOTENCY_KEY}{BODY_SHA256}

Component Breakdown

Component
Description
Example Value
Included Exactly As

METHOD

Uppercase HTTP method

POST

"POST"

PATH

Full request path (no domain, no query params)

/v1/payouts

"/v1/payouts"

TIMESTAMP

Date.now() in milliseconds

1733359952000

"1733359952000"

IDEMPOTENCY_KEY

UUID generated per request

bcd1f714-66e8-49f2-8c7d-d21afa474ef7

"bcd1f714-66e8-49f2-8c7d-d21afa474ef7"

BODY_SHA256

Hex-encoded SHA-256 hash of raw request body (empty string if no body)

2b7df2035a…

"2b7df2035a..."

Important: These fields are concatenated directly β€” no spaces, newlines, or separators.


Example Canonical String

Raw values

Field
Value

METHOD

POST

PATH

/v1/payouts

TIMESTAMP

1733359952000

IDEMPOTENCY_KEY

bcd1f714-66e8-49f2-8c7d-d21afa474ef7

BODY_SHA256

2b7df2035a...

Concatenated canonical string:


Notes and Tips

  • PATH must not include domain or query string (for example, use /v1/payouts, not https://api.example.com/v1/payouts?foo=bar)

  • BODY_SHA256 must hash the exact raw body bytes and extra whitespace or comments will change the signature

  • IDEMPOTENCY_KEY is required even for GET requests

  • TIMESTAMP must match the value in X-Sign-Timestamp

Header
Description

X-API-Key

Your public key

X-Signature

Base64 signature generated with your private key

X-Sign-Timestamp

Date.now() in milliseconds

X-Idempotency-Key

Unique UUID per request

Below are some language specific examples for generating the X-Signature:

Our Developer Postman collection is also configured to sign requests after you configure your keys.

Last updated