Hinkal Partner

Integrating Your Key

Add your key to Hinkal API calls, choose the right key for where your code runs, and check that calls are credited to you.

Add one header to the Hinkal API calls you already make:

x-api-key: hk_sk_live_…

The key goes on top of your normal authentication and doesn't replace any of it:

  • Normal-mode sessions: keep sending the session fields and x-hinkal-request-signature.
  • EIP-712 sessions: keep putting the per-transaction signature in the body. Don't add x-hinkal-request-signature to transaction calls on an EIP-712 session, because the API rejects that with 403. GET /get-fee uses the request signature in both modes.

x-api-key isn't part of the signed payload, so adding it doesn't change how you sign. See Authentication.

The API checks the session and signature first and the key second. A request with a bad signature fails as usual, whatever key it carries.


Routes that read the key

MethodRouteWhat you get
POST/withdraw, /transfer, /swap, /private-send, /private-send-bridge, /receive-address with recipientAddress (a transfer address)Volume and commission
POST/receive-address without recipientAddressNothing is credited, but the key is still checked: an invalid key fails the request
POST/deposit, /deposit-for-other, /deposit-solana-for-other, /proofless-depositVolume only
POST/receive-vault-recover, /recover-stuck-balance with kind: "vault"Volume only
POST/recover-stuck-balance with kind utxo or bridgeNothing is credited, but the key is still checked: an invalid key fails the request
GET/get-feeYour current fee in the response. No transaction is recorded.
POST/partner/transfer-addressVolume and commission on each payout. Secret key only.
GET, POST/partner/transfer-address/stuck-balances, /partner/transfer-address/recoverNothing is credited. Secret key only.

Every other route ignores the key, including /create-session, /balance, /get-swap-data, /withdraw-stuck-utxos and /recover-stuck-bridge-balance. /withdraw-stuck-utxos and /recover-stuck-bridge-balance move funds but are never credited to you.

Deposits that arrive at a plain receive address aren't credited to you. A transfer address (/receive-address with recipientAddress) is different: the key is read when the address is created, and each forward to its recipient is credited with your fee.

The /partner/transfer-address routes are the exception to "key on top of your normal authentication": there is no session, and the secret key takes its place. The recover route also needs a signature from the refundTo wallet. Your backend can create transfer addresses without holding a wallet, and payments that can't be paid out are refunded to a refundTo address you choose. Refunds and recoveries aren't credited. See Partner Transfer Address.


Choose the key for where your code runs

Your backend holds the wallet, opens the session and signs every request. Send the secret key from the server. This uses the helpers from Examples:

const session = await createSession();

const body = {
  ...sessionBodyParams(session, CHAIN_ID),
  tokenAddresses: [USDC],
  amounts: ["500000"],
  recipientAddress: "0xRecipientAddress",
  feeToken: USDC,
};

const { txHash } = await post("/withdraw", body, {
  ...requestSignaturePostHeader(session, "/withdraw", body),
  "x-api-key": process.env.HINKAL_SECRET_KEY,
});

The same header goes on /transfer, /swap, /private-send (Private Send) and the deposit routes.

Users connect their own wallet in your web app, and the browser opens the session and signs each request. Send the publishable key, and add every origin your app is served from to the key's list. See Allowed origins.

The API accepts cross-origin requests, so x-api-key and x-hinkal-request-signature pass the browser's preflight check. The helpers in Examples use Node's crypto and Buffer, so replace those with browser equivalents first, for example @noble/hashes for SHA-256 and crypto.getRandomValues for random bytes.

const res = await fetch("https://api.hinkal.io/swap", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": "hk_pk_live_…",
    ...requestSignaturePostHeader(session, "/swap", body),
  },
  body: JSON.stringify(body),
});

Never put the secret key in browser code.

Native apps send no Origin header, so a publishable key always returns 403 from them, and a secret key must never ship inside an app. Send the app's calls through a small proxy on your backend that adds the secret key.

Because x-api-key isn't part of the signature, the proxy can add it without breaking the request. Forward the body byte for byte: the API checks the signature against the raw body, so parsing and re-serializing the JSON can break it. The app still signs the Hinkal route, such as /withdraw, not your proxy's path, because the API binds the signature to its own route. In Express, mount the proxy route before any JSON body parser.

const ROUTES = new Set(["withdraw", "transfer", "swap", "private-send", "private-send-bridge", "receive-address"]);

app.post("/hinkal/:route", express.raw({ type: "application/json" }), async (req, res) => {
  if (!ROUTES.has(req.params.route)) return res.sendStatus(404);

  const upstream = await fetch(`https://api.hinkal.io/${req.params.route}`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-hinkal-request-signature": req.get("x-hinkal-request-signature") ?? "",
      "x-api-key": process.env.HINKAL_SECRET_KEY,
    },
    body: req.body,
  });

  const signature = upstream.headers.get("x-hinkal-response-signature");
  if (signature) res.set("x-hinkal-response-signature", signature);

  res.status(upstream.status).type("application/json").send(await upstream.text());
});

For GET routes such as /get-fee, forward the query string unchanged for the same reason. Rate-limit the proxy: everything sent through it is credited to you.


Check that the key works

Call GET /get-fee with your key. The full call is on Go Live. With a valid key the response includes partnerFeeBps. Without a key, or with a value that doesn't start with hk_, it doesn't.

{ "success": true, "feeAmount": "41250", "hinkalVariableRateBps": 10, "partnerFeeBps": 25, "breakdown": { … }, "nonce": "3f2c9a…" }
  • feeAmount is the flat network and relayer fee, in the fee token's smallest unit.
  • hinkalVariableRateBps is the Hinkal fee. It's 10 unless Hinkal set a custom rate for you.
  • partnerFeeBps is your fee as the API sees it right now. It's 0 until you set a fee.
  • breakdown shows how feeAmount was calculated, using each chain's own fee fields. See GET /get-fee in the API reference.
  • nonce echoes the nonce from your request.

Your first keyed call also completes step 2 of the Go-live card.


Common mistakes

Warning

A header value that doesn't start with hk_ is ignored, not rejected. The call succeeds but isn't credited to you. A value that starts with hk_ but isn't a complete key returns 401.

  • Sending your company name as ref. The key handles attribution. A body ref that isn't on Hinkal's legacy list fails with 400 Invalid ref: '…' is not a whitelisted referral.
  • Routing traffic through the SDK, WaaS or MCP. None of them send or read the key.
  • Running with a fee of 0. Calls are still credited to you, but they earn nothing. Each transaction is recorded with the fee in force when it ran, and later fee changes don't apply to it.

Credited transactions show up on the Transactions page once they confirm on-chain. If a call with your key fails, see Errors and Limits.