Reading this in another language? Use your browser's built-in translate option. Button and field names stay in English on purpose, to match what you see in Keysender.
This is the end-to-end path for a store, marketplace, or back office that Keysender does not connect to natively: your software records each sale through the API and Keysender delivers the code. It takes four calls to go from a fresh API key to a buyer holding a working code, and the same calls run every day after that.
TL;DR
addcustom, so store every transaction id you receive before doing anything else.Make sure you have:
If your platform is one Keysender already connects to, use that integration instead; see Connected channels. Guides for popular automation platforms are being published as those integrations are released.
POST /login with api_key and api_secret, store the access_token, and send it as Authorization: Bearer ... on every call. Details: Getting started with the Keysender API. POST /database with name, sku, and type: 0. Use your own product code as the sku; a repeat call with the same SKU returns the same database, so you can run it on every sync. Details: Managing inventory databases with the API. POST /code?database_id=... with an array of {"value": "..."} objects, 1,000 per request at most. Details: Uploading and managing codes with the API. POST /transaction/addcustom with payer, quantity, database_id, amount, currency, and name. Keysender picks the codes, sends them with your template, and spends a credit. id against your order immediately. There is no deduplication: a retried call delivers again. Details: Creating transactions with the API. GET /transaction/{id}/inventory shows exactly which codes went out, and Transactions in the panel shows the same sale. GET /logout when you retire a token. 429, wait and retry with the same body only for reads, never for addcustom. id you receive. It is the only handle you have on a delivery. A test order placed in your own system ends with a delivery email in the buyer's inbox, a transaction under Transactions in the panel, and the database's available count one lower.
| Symptom | Cause | Action |
|---|---|---|
| The buyer got nothing | The database had no available codes, or the account had no credits | Check quantity_sent on the transaction, the database's available count, and the credit balance |
| The buyer got two emails | The same sale was sent twice | Use the stored id to make retries safe; never retry a call that already returned 200 |
401 mid-way |
The token expired or was logged out | Log in again and continue |
Submit a ticket with the transaction id and the time of the calls.
When Keysender does not connect natively to the store or marketplace you sell on. For channels it does connect to, the built-in integration records the sale and delivers without any code on your side.
Four: log in, create the product's database, upload codes, and record the sale with /transaction/addcustom. After that, only the sale call runs per order, plus code uploads as stock is replenished.
Never place the API secret in a browser, mobile app, or public repository; never retry a transaction call that already returned 200; and never log in before every request when one token will do.