Endpoints
POST /payments
Create a payment server-to-server.
POST
/paymentssecret keyCreate a payment server-to-server. Use when you tokenize the customer's payment data on your side and have the appropriate PCI scope.
Body parameters
amountintegerrequiredSmallest currency unit.currencystringrequiredISO-4217.methodstringrequiredcard | spei | pix | oxxo | bank_transfer | …sourceobjectrequiredMethod-specific token / fields. For cards: { token } or { number, exp_month, exp_year, cvv }.customerobject{ email, firstName, lastName, country, ip }capturebooleanCapture immediately. Default true.metadataobjectFree-form key-value pairs.
Request
curl https://sandbox-api.key2pays.com/v1/payments \
-H "Authorization: Bearer sk_test_51N8mP...exampleK3Y" \
-H "Content-Type: application/json" \
-d '{ "amount": 12000, "currency": "MXN", "method": "spei", … }'Response
{ "id": "pay_3aB81…", "status": "processing", "next_action": { "type": "spei_transfer", "clabe": "012345678901234567" } }Try itPOST
/paymentssandboxRequest body
amountintegerRequiredcurrencyenumRequiredmethodenumRequiredsourcejsonRequiredcustomerjsoncapturebooleanmetadatajsonLive snippet
curl -X POST "https://sandbox-api.key2pays.com/v1/payments" \
-H "Authorization: Bearer sk_test_…YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 12000,
"currency": "MXN",
"method": "spei",
"source": {
"token": "tok_demo_123"
},
"customer": {
"email": "user@example.com",
"firstName": "Ana",
"lastName": "Pérez"
},
"capture": true,
"metadata": {
"order_id": "ord_5xZ"
}
}'Snippet updates as you edit the form. Sandbox responses are deterministic.