Skip to content

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.

POST/api/v1/payment-links
API keypayment_links:write Idempotency-Key required

A fixed amount, or a range the payer chooses from, plus optional single use, a payment cap and an expiry.

Body (JSON)
  • amountintegeroptional

    A fixed price in KES cents, whole shillings, KES 10 to KES 150,000. Or send min_amount and max_amount instead.

  • min_amountintegeroptional

    Smallest amount the payer can choose, KES cents.

  • max_amountintegeroptional

    Largest amount the payer can choose, KES cents.

  • descriptionstringrequired

    What it's for, shown on the page. Up to 140 characters.

  • referencestringoptional

    Your own id, up to 64 characters.

  • after_payment_urlstringoptional

    https URL to send the payer to after paying, with ?session_id= added.

  • single_usebooleanoptional

    Close after one payment. Default false.

  • max_paymentsintegeroptional

    Close after this many payments.

  • expires_atstringoptional

    ISO 8601 time, 5 minutes to 365 days away.

  • metadataobjectoptional

    Up to 20 string key-value pairs, copied onto each checkout session.

Request
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"
  }'
Response201 application/json
{
  "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"
  }
}
Errors

Plus the key and rate errors any keyed call can return.

GET/api/v1/payment-links
API keypayment_links:read

Newest first, in the key's environment.

Query parameters
  • limitintegeroptional

    How many to return, 1 to 100. Default 20.

  • starting_afterstringoptional

    Cursor 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.

  • statusstringoptional

    Only links in this status.

    activeinactiveexpired
  • referencestringoptional

    Only links with this reference.

Request
curl "https://api.autopayke.com/api/v1/payment-links" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "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/api/v1/payment-links/{id}
API keypayment_links:read

One link with its payments_count and amount_collected.

Path parameters
  • idstringrequired

    The link id (pl_…).

Request
curl "https://api.autopayke.com/api/v1/payment-links/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "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"
  }
}
Errors

Plus the key and rate errors any keyed call can return.

GET/api/v1/payment-links/{id}/payments
API keypayment_links:read

The paid checkout sessions of one link, newest first.

Path parameters
  • idstringrequired

    The link id (pl_…).

Request
curl "https://api.autopayke.com/api/v1/payment-links/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp/payments" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "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
  }
}
Errors

Plus the key and rate errors any keyed call can return.

POST/api/v1/payment-links/{id}/deactivate
API keypayment_links:write

Stop taking payments now. Payments already made aren't affected.

Path parameters
  • idstringrequired

    The link id (pl_…).

Request
curl -X POST "https://api.autopayke.com/api/v1/payment-links/pl_4Hd8Kq2Nx7Wm3Rt9Zb5Vc1Lp/deactivate" \
  -H "Authorization: Bearer $AUTOPAYKE_API_KEY"
Response200 application/json
{
  "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"
  }
}
Errors

Plus the key and rate errors any keyed call can return.