Quickstart
Make your first signed sandbox request and create a receive address.
This walkthrough uses Node.js 18 or later and a sandbox key. Sandbox and live use the same API host; the key decides which mode you reach. For other languages, see Signing a request.
1. Create a sandbox key
In the Gyvar dashboard, switch to Sandbox, then open
Developers > API keys > New API key. Choose Generate keypair, save the private
key shown once, and grant Receive. Save the key id, which begins
gyv_k_sandbox_. Only an owner or admin can create a key.
Set these environment variables in your terminal. The private key is the base64 text shown by the dashboard; do not encode it again. Keep it out of source control.
export GYVAR_KEY_ID='gyv_k_sandbox_...'
export GYVAR_PRIVATE_KEY='...'A key with Read and Receive needs no IP allowlist. See Access for keys that can move money.
2. Authenticate, then create an address
Save this as quickstart.mjs and run node quickstart.mjs. It signs and sends the
same body bytes, uses a fresh nonce for each request, and checks authentication with
GET /v1/whoami before creating anything.
import { createHash, createPrivateKey, randomBytes, sign } from 'node:crypto'
const keyID = process.env.GYVAR_KEY_ID
const seed = Buffer.from(process.env.GYVAR_PRIVATE_KEY ?? '', 'base64')
if (!keyID?.startsWith('gyv_k_sandbox_') || seed.length !== 32) {
throw new Error('Set a sandbox GYVAR_KEY_ID and its 32-byte base64 GYVAR_PRIVATE_KEY')
}
const privateKey = createPrivateKey({
key: Buffer.concat([
Buffer.from('302e020100300506032b657004220420', 'hex'),
seed,
]),
format: 'der',
type: 'pkcs8',
})
async function request(method, path, bodyObject) {
const body = bodyObject === undefined ? '' : JSON.stringify(bodyObject)
const timestamp = String(Math.floor(Date.now() / 1000))
const nonce = randomBytes(16).toString('hex')
const bodyHash = createHash('sha256').update(body).digest('hex')
const canonical = [method, path, bodyHash, timestamp, nonce, keyID].join('\n')
const signature = sign(null, Buffer.from(canonical), privateKey).toString('base64')
const response = await fetch(`https://api.gyvar.com${path}`, {
method,
headers: {
'X-Gyvar-Key': keyID,
'X-Gyvar-Timestamp': timestamp,
'X-Gyvar-Nonce': nonce,
'X-Gyvar-Signature': signature,
...(body ? { 'Content-Type': 'application/json' } : {}),
},
...(body ? { body } : {}),
})
const result = await response.json()
console.log(method, path, response.status, result)
if (!response.ok) throw new Error(result.details?.code ?? result.message)
return result
}
await request('GET', '/v1/whoami')
await request('POST', '/v1/addresses', {
chain: 'base',
reference: `quickstart-${randomBytes(8).toString('hex')}`,
})The first call should return 200 and identify your sandbox key. The second should
return 201 with data.address and data.assets (including USDC). Reusing the
same reference returns that address with 200; use your customer or invoice id in
a real integration. If a call fails, use its details.code with the error guide.
What to test next
You can create sandbox addresses, but you cannot deposit into them in sandbox.
The Wallet faucet adds a test balance directly and does not emit deposit.success.
Use the webhook signing fixture to test your receiver's
signature verification locally. To prove the entire deposit and webhook path, use a
live key and a small real payment. See Sandbox for the other mode limits.
If you are building a shop, continue with Checkout. If you are paying out, read Sending money before making a payment request.