Code samples

Copy-paste examples for the most common flows, in cURL, Node and Python.

Not live yet — api.baynoy.com does not resolve, so the examples below will not run today. They describe the contract we are building to, and the shapes on this page may still change.

Create a payment link

The same call in three shapes — plain HTTPS, no library.

cURL
curl https://api.baynoy.com/v1/catalog/links \
  -H "Authorization: Bearer bk_test_..." \
  -H "Content-Type: application/json" \
  -d '{"title": "Design retainer", "amountMinor": "4900", "assetKey": "fiat:EUR"}'

# -> {"id": "lnk_...", "slug": "k3x9q2"}  — the page is https://baynoy.com/pay/k3x9q2
Node
// Node 18+, no package needed
const res = await fetch("https://api.baynoy.com/v1/catalog/links", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.BAYNOY_SECRET_KEY}`,
    "content-type": "application/json",
  },
  // amounts are strings of integer minor units — never floats
  body: JSON.stringify({ title: "Design retainer", amountMinor: "4900", assetKey: "fiat:EUR" }),
});
const { slug } = await res.json();
console.log(`https://baynoy.com/pay/${slug}`);
Python
import os, requests

r = requests.post(
    "https://api.baynoy.com/v1/catalog/links",
    headers={"Authorization": f"Bearer {os.environ['BAYNOY_SECRET_KEY']}"},
    json={"title": "Design retainer", "amountMinor": "4900", "assetKey": "fiat:EUR"},
)
print("https://baynoy.com/pay/" + r.json()["slug"])