.agents/skills/onchain-pay-open-api/references/authentication.md
All Onchain-Pay Open API requests use RSA SHA256 signature with a PEM private key.
payload = JSON_BODY + TIMESTAMP
JSON_BODY: The raw JSON request body string (compact, no trailing newline). If no body is needed, use empty string.TIMESTAMP: Current Unix timestamp in milliseconds (e.g., 1709654400000)Example:
{"fiatCurrency":"USD","cryptoCurrency":"BTC","totalAmount":100,"amountType":1}1709654400000
signature=$(echo -n "$payload" \
| openssl dgst -sha256 -sign "$PRIVATE_KEY_PATH" \
| openssl enc -base64 -A)
All requests are POST with these headers:
| Header | Value |
|---|---|
X-Tesla-ClientId | Your client ID (e.g., your-client-id) |
X-Tesla-SignAccessToken | Your API key |
X-Tesla-Signature | The RSA signature from Step 2 |
X-Tesla-Timestamp | The timestamp used in signing |
Content-Type | application/json |
x-trace-id | (Optional) Trace ID for debugging |
# Generate timestamp in milliseconds (cross-platform compatible)
timestamp=$(($(date +%s) * 1000))
api_params='{"fiatCurrency":"USD","cryptoCurrency":"BTC","totalAmount":100,"amountType":1}'
payload="${api_params}${timestamp}"
signature=$(echo -n "$payload" \
| openssl dgst -sha256 -sign "test.pem" \
| openssl enc -base64 -A)
curl --location --request POST "https://api.commonservice.io/papi/v1/ramp/connect/buy/payment-method-list" \
--header "X-Tesla-ClientId: your-client-id" \
--header "X-Tesla-SignAccessToken: your-api-key" \
--header "X-Tesla-Signature: $signature" \
--header "X-Tesla-Timestamp: $timestamp" \
--header "Content-Type: application/json" \
--data-raw "$api_params"
Correct (works on macOS, Linux, BSD):
timestamp=$(($(date +%s) * 1000))
Incorrect (do not use):
# ❌ Doesn't work on macOS - outputs literal 'N'
timestamp=$(date +%s%3N)
# ❌ Just appends '000', not true milliseconds
timestamp=$(date +%s000)
On macOS, date doesn't support %N (nanoseconds), which causes date +%s%3N to output something like 1773744478N. This breaks JSON parsing with error:
Unexpected character ('N' (code 78)): was expecting comma to separate Object entries
2zefb...06h)