Get started
Quickstart
From a test key to a paid test charge in five steps, using only cURL or fetch. Nothing to install.
On this page
Step 1: Get your test keys
Copy the test secret key from the developer area of the dashboard.
Step 2: Store the secret key
Keep it in an environment variable on your server, never in the browser.
Step 3: Create a charge
Call
POST /v1/chargeswith an amount, a description and the accepted methods.Step 4: Pay in the test checkout
Open the
checkout_urland pay with a test card or the Pix simulation.Step 5: Confirm the payment
Receive
charge.paidon your webhook, or read the charge and checkstatus.
Before you start
- A terminal with
curl, or any JavaScript runtime with a globalfetch(Node.js 18 or later, Deno, Bun). - Access to the demo dashboard. Everything in it is test data.
Warning: The endpoints do not answer yet
1. Get your test keys
Open Developers → API keys. You will find two keys: the secret key (kp_test_sk_…), used by your server for every API call, and the publishable key (kp_test_pk_…), reserved for future client-side use. This guide only needs the secret key.
2. Store the secret key
Put the key in an environment variable called KROKOPAY_SECRET_KEY. The rest of the documentation reads it from there, so no example contains a key you could commit by accident.
# Current terminal session only. Paste the test secret key from the dashboard.export KROKOPAY_SECRET_KEY="kp_test_sk_4f9a2c7e1b8d4a6f9c3e5d7b"3. Create a charge
Send the amount in centavos, the currency, a description the buyer will see and the methods you accept. The Idempotency-Key header makes the call safe to retry: sending it again with the same key never creates a second charge (see Idempotency).
/v1/chargescurl -X POST https://api.krokopay.app/v1/charges \ -H "Authorization: Bearer $KROKOPAY_SECRET_KEY" \ -H "Idempotency-Key: order_1042" \ -H "Content-Type: application/json" \ -d '{ "amount": 49700, "currency": "BRL", "description": "Curso Identidade Visual do Zero", "customer_id": "cus_8Hq2LmZr4TxN1a", "methods": [ "pix", "card" ] }'The charge comes back as pending with method: null, because the buyer has not chosen Pix or card yet. Keep the id with your order.
4. Pay in the test checkout
Redirect the buyer to checkout_url (https://krokopay.app/pay/{id}). In the test environment you are the buyer:
// After creating the charge on your server, send the buyer to its hosted checkout.const charge = await response.json();// Express-style handler: redirect the browser.res.redirect(303, charge.checkout_url);// → https://krokopay.app/pay/chg_9Qs5MbT2kXn8Vd- Card: use
4242 4242 4242 4242with any future expiry date and any CVC. The payment is approved. - Pix: choose Pix to get a fictional QR code, then open Demo controls and press Confirm Pix payment.
To try this today, create a charge in Payments → New payment and open its checkout link: the flow is the same one your buyers will see.
5. Confirm the payment
When the buyer pays, KrokoPay sends a charge.paid event to your webhook endpoint. Fulfill the order there, after verifying the signature (see Webhooks).
{ "id": "evt_6Ff7Gg8Hh9Ii0J", "object": "event", "type": "charge.paid", "api_version": "2026-11-01", "created_at": "2026-11-03T14:23:41.000Z", "data": { "object": { "id": "chg_4Fp9KzW1xQm7Rt", "object": "charge", "amount": 49700, "currency": "BRL", "status": "paid", "method": "pix", "card": null, "description": "Curso Identidade Visual do Zero", "customer_id": "cus_8Hq2LmZr4TxN1a", "product_id": "prod_3Vb7QpK9sWd2Ee", "price_id": "price_5Kd1NcR8vYq3Hm", "link_id": "plink_2Wn6HsT9cVb4Lq", "subscription_id": null, "fee": null, "net": null, "refunded_amount": 0, "failure_code": null, "created_at": "2026-11-03T14:22:05.000Z", "paid_at": "2026-11-03T14:23:41.000Z", "expires_at": "2026-11-03T14:37:05.000Z", "available_at": null, "checkout_url": "https://krokopay.app/pay/chg_4Fp9KzW1xQm7Rt" } }}Without a webhook you can read the charge and check that status is paid:
/v1/charges/{id}curl https://api.krokopay.app/v1/charges/chg_4Fp9KzW1xQm7Rt \ -H "Authorization: Bearer $KROKOPAY_SECRET_KEY"Success: Done
Next steps
- Try a declined card and the other outcomes in test cards.
- Handle
charge.failedandcharge.expiredas well: see Errors. - Sell without code using payment links.