Payment links (API)
Shareable payment pages made with an API key. Each payer gets a checkout session; you get payment_link.paid when they pay.
A link is active until you deactivate it, it reaches max_payments (single_use means 1), or it passes expires_at.
Each payment is a checkout session started from the link, paid by a collection, so the same webhooks and sandbox numbers apply.
Send your API key as Authorization: Bearer apk_test_… (sandbox) or apk_live_… (live). Each endpoint lists the scope the key needs. See API keys.
Create a payment link
/api/v1/payment-linkspayment_links:write Idempotency-Key requiredA fixed amount, or a range the payer chooses from, plus optional single use, a payment cap and an expiry.
amountintegeroptionalA fixed price in KES cents, whole shillings, KES 10 to KES 150,000. Or send min_amount and max_amount instead.
min_amountintegeroptionalSmallest amount the payer can choose, KES cents.
max_amountintegeroptionalLargest amount the payer can choose, KES cents.
descriptionstringrequiredWhat it's for, shown on the page. Up to 140 characters.
referencestringoptionalYour own id, up to 64 characters.
after_payment_urlstringoptionalhttps URL to send the payer to after paying, with ?session_id= added.
single_usebooleanoptionalClose after one payment. Default false.
max_paymentsintegeroptionalClose after this many payments.
expires_atstringoptionalISO 8601 time, 5 minutes to 365 days away.
metadataobjectoptionalUp to 20 string key-value pairs, copied onto each checkout session.
curl -X POST "https://api.autopayke.com/api/v1/payment-links" \
-H "Authorization: Bearer $AUTOPAYKE_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"amount": 500000,
"description": "Invoice 2041: October deliveries",
"reference": "INV-2041",
"single_use": true,
"after_payment_url": "https://example.com/paid"
}'{
"ok": true,
"data": {
"id": "pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"object": "payment_link",
"livemode": false,
"status": "active",
"url": "https://www.autopayke.com/l/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"amount": 500000,
"min_amount": null,
"max_amount": null,
"currency": "KES",
"description": "Invoice 2041: October deliveries",
"reference": "INV-2041",
"metadata": {},
"after_payment_url": "https://example.com/paid",
"single_use": true,
"max_payments": 1,
"payments_count": 0,
"amount_collected": 0,
"expires_at": null,
"created": "2026-11-03T09:10:00.000Z",
"updated": "2026-11-03T09:10:00.000Z"
}
}Plus the key and rate errors any keyed call can return.
List payment links
/api/v1/payment-linkspayment_links:readNewest first, in the key's environment.
limitintegeroptionalHow many to return, 1 to 100. Default 20.
starting_afterstringoptionalCursor for the next page: the id of the last item you got. Lists are newest first; when has_more is true, pass the last id here.
statusstringoptionalOnly links in this status.
activeinactiveexpiredreferencestringoptionalOnly links with this reference.
curl "https://api.autopayke.com/api/v1/payment-links" \
-H "Authorization: Bearer $AUTOPAYKE_API_KEY"{
"ok": true,
"data": {
"object": "list",
"data": [
{
"id": "pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"object": "payment_link",
"livemode": false,
"status": "active",
"url": "https://www.autopayke.com/l/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"amount": 500000,
"min_amount": null,
"max_amount": null,
"currency": "KES",
"description": "Invoice 2041: October deliveries",
"reference": "INV-2041",
"metadata": {},
"after_payment_url": "https://example.com/paid",
"single_use": true,
"max_payments": 1,
"payments_count": 0,
"amount_collected": 0,
"expires_at": null,
"created": "2026-11-03T09:10:00.000Z",
"updated": "2026-11-03T09:10:00.000Z"
}
],
"has_more": false
}
}Get a payment link
/api/v1/payment-links/{id}payment_links:readOne link with its payments_count and amount_collected.
idstringrequiredThe link id (pl_…).
curl "https://api.autopayke.com/api/v1/payment-links/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp" \
-H "Authorization: Bearer $AUTOPAYKE_API_KEY"{
"ok": true,
"data": {
"id": "pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"object": "payment_link",
"livemode": false,
"status": "inactive",
"url": "https://www.autopayke.com/l/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"amount": 500000,
"min_amount": null,
"max_amount": null,
"currency": "KES",
"description": "Invoice 2041: October deliveries",
"reference": "INV-2041",
"metadata": {},
"after_payment_url": "https://example.com/paid",
"single_use": true,
"max_payments": 1,
"payments_count": 1,
"amount_collected": 500000,
"expires_at": null,
"created": "2026-11-03T09:10:00.000Z",
"updated": "2026-11-03T09:10:00.000Z"
}
}List a link's payments
/api/v1/payment-links/{id}/paymentspayment_links:readThe paid checkout sessions of one link, newest first.
idstringrequiredThe link id (pl_…).
curl "https://api.autopayke.com/api/v1/payment-links/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp/payments" \
-H "Authorization: Bearer $AUTOPAYKE_API_KEY"{
"ok": true,
"data": {
"object": "list",
"data": [
{
"object": "payment_link.payment",
"checkout_session": "cs_9Lp2Wq7Zt4Mn8Rx3Kb6Yc1Df",
"collection": "col_5Ty8nQw3Rz2Lm7Kc9Pd4Hs1V",
"amount": 500000,
"currency": "KES",
"paid_at": "2026-11-03T09:12:05.000Z"
}
],
"has_more": false
}
}Deactivate a payment link
/api/v1/payment-links/{id}/deactivatepayment_links:writeStop taking payments now. Payments already made aren't affected.
idstringrequiredThe link id (pl_…).
curl -X POST "https://api.autopayke.com/api/v1/payment-links/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp/deactivate" \
-H "Authorization: Bearer $AUTOPAYKE_API_KEY"{
"ok": true,
"data": {
"id": "pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"object": "payment_link",
"livemode": false,
"status": "inactive",
"url": "https://www.autopayke.com/l/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp",
"amount": 500000,
"min_amount": null,
"max_amount": null,
"currency": "KES",
"description": "Invoice 2041: October deliveries",
"reference": "INV-2041",
"metadata": {},
"after_payment_url": "https://example.com/paid",
"single_use": true,
"max_payments": 1,
"payments_count": 0,
"amount_collected": 0,
"expires_at": null,
"created": "2026-11-03T09:10:00.000Z",
"updated": "2026-11-03T09:10:00.000Z"
}
}