Overview
A transaction is a sale Keysender fulfils: it takes codes from a database, sends them to the buyer with your template, and spends one credit per dispatch. Your software creates one whenever it sells outside a connected channel, for example from your own store or a marketplace Keysender does not integrate, and Keysender handles delivery from there.
TL;DR
POST /transaction/addcustomrecords a sale and delivers a code from a database you choose.- There is no deduplication key: store the returned
idimmediately, and never retry a call that already returned 200. POST /transaction/addrepeats an earlier eBay, PayPal Button, or Allegro transaction with the same details.
Doing this by hand instead of by code? See manually adding a transaction for the same delivery from the panel.
Before you start
Make sure you have:
- A bearer token from
POST /loginand the base URLhttps://panel.keysender.com/api/v1.0. - A database with available codes (see Uploading and managing codes with the API).
- An email template set as the default in Templates, or the
template_idof the one to use. Without any template the call is rejected. - Credits on the account. Each dispatch uses one.
Steps
Record a sale and deliver the code
- Send
POST /transaction/addcustomwith the buyer, the quantity, the database, and the sale details:
curl -X POST "https://panel.keysender.com/api/v1.0/transaction/addcustom" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"payer": "[email protected]", "quantity": 1, "database_id": 123, "amount": 9.99, "currency": "EUR", "name": "Example Game (Steam)"}'
- Required fields:
payer(the buyer's email),quantity(1 to 5,000),database_id,amount(up to two decimals),currency, andname(what the buyer sees). Optional:template_id,msgsubject, andmsgtextto override the template for this sale. - The response is the transaction:
id,status,quantity,quantity_sent,amount,currency,keysender_buyer_email, andkeysender_code_id. Delivery runs in the background right after the call, soquantity_sentcan still be 0 in this first response.
Send exactly once
- There is no deduplication key. Every accepted
addcustomcall creates a new transaction and delivers codes again, even if the body is identical. - Record the returned
idagainst your own order before you retry anything, and never retry a call that already returned 200. - If a call times out without a response, check the panel's Transactions page for the buyer's email before sending again.
Repeat a previous transaction
- Send
POST /transaction/addwithsource_transaction_id,payer,quantity, anddatabase_idto create a new transaction with the same details as an earlier one. The source must be an eBay, PayPal Button, or Allegro transaction; other sources are rejected with422.
Read what was delivered
- Send
GET /transaction/456/inventorywith the transaction id. The response lists each delivered code as{"id", "value", "kind"}; for file codes,valueis the file encoded in base64 andfileNameis added.
Respect the limits
- Quantity is capped at 5,000 per transaction.
- Your account may be limited to a number of deliveries per minute;
429means slow down and retry after a minute.
Confirm it works
The new transaction appears under Transactions in the panel with the buyer's email, the database's available count drops by the quantity, and the buyer receives the delivery email from the template. See Viewing specific order details for what that record looks like in the panel.
Troubleshooting
| Symptom | Cause | Action |
|---|---|---|
422 naming a field |
One of the six required fields is missing or malformed | amount accepts digits with up to two decimals; recheck the field named in the response |
422 about a template |
No default template is set | Set one in Templates, or pass template_id |
| The buyer received two emails | The call was sent twice | Use the returned id to make retries safe, and never retry a call that already returned 200 |
Nothing delivered and quantity_sent stays 0 |
The database has no available codes, or the account has no credits | Check both before retrying |
If it still is not working
Submit a ticket with the transaction id and the buyer's email.
Quick answers
What happens when I call /transaction/addcustom?
Keysender creates a paid transaction, reserves the requested quantity from the database, sends the codes to the payer with your template, and spends one credit per dispatch. Delivery runs in the background right after the call returns.
Is it safe to retry a transaction call?
No. There is no deduplication key, so a repeated call creates a second transaction and delivers again. Store the returned id against your order before you retry anything, and check the panel's Transactions page after a timeout.
How do I see which codes were delivered?
Send GET /transaction/<id>/inventory. Each delivered code is listed with its id, value, and kind; file codes come back base64-encoded with a fileName.
Was this helpful?