Skip to main content
This page takes you from a new API key to one confirmed Jupiter swap. Each step shows the call and what you should get back.
The last two steps move real funds on Solana mainnet-beta. Run them only against a dedicated vault with a small balance.
You need:
  • An API key from a Hedgin administrator with scopes read, send, and jupiter/swap.
  • The manager keypair that is the vault’s current on-chain authority.
  • curl and Node.js 18 or later.
1

Store the API key

Keep the key in your bot’s secret store, not in source code. For a shell session, load it into an environment variable:
Every request sends it as Authorization: Bearer $HEDGIN_API_KEY.
2

List your vaults

You get { "vaults": [...] }. Each entry has an address, a depositMint, and depositDecimals. Copy the address of the vault you want to use. An empty list means the key’s manager is not the authority of any vault in the key’s scope.
3

Get a quote

Amounts are integer strings in token base units. For a token with 6 decimals, "1000000" is 1 token.
You get { "vault": "...", "data": { "inAmount", "outAmount", "priceImpactPct", "routeLabels", "slippageBps" } }. A quote does not reserve a price.
4

Build the swap

You get { "vault": "...", "result": { "transaction", "simulation", "ticket", "blockhash", ... } }. transaction is an unsigned base64 Solana v0 transaction. The ticket expires 90 seconds after the build, so sign and send promptly. Do not put payer in the body. The API sets it from your key.
5

Sign, send, and confirm

Sign the transaction locally with the manager keypair. Then post the signed bytes and the ticket to POST /transactions/send, and poll GET /transactions/status with the returned receipt until it reports confirmed. Examples has the complete TypeScript code for this step.The swap happened only when status is confirmed. If send returns status: "unknown", keep polling the same receipt. Do not build the swap again until the status is expired or failed.If the build result has a next field, the swap needs a follow-up transaction. After the first one confirms, build next.path with next.body. That follow-up is jupiter/swap again or jupiter/sweep, and the key needs that scope too.

Next steps

  • Read Send and status before you handle batches or next steps.
  • Ask your administrator for each additional builder action your bot needs. Authentication lists the continuation scopes some actions require.