Codes are the stock inside a database: the keys, licenses, vouchers, or files Keysender delivers when an order is paid. The Code endpoints let your software top up a database in bulk, check what is available or already used, flag a code to go out first, and remove a code that should never be sent.
Make sure you have:
POST /login and the base URL https://panel.keysender.com/api/v1.0.id of the database you are filling (see Manage inventory databases with the API).A code has these fields: id, type (1 text, 2 file), value, status (0 available, 1 used), keyusage, sendfirst (1 to deliver before other codes), filename, and the optional unit_cost, currency, purchase_date, and expiration_date.
POST /code?database_id=123 with a JSON array of objects, one per code:curl -X POST "https://panel.keysender.com/api/v1.0/code?database_id=123" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '[{"value": "AAAA-BBBB-CCCC"}, {"value": "DDDD-EEEE-FFFF", "unit_cost": 4.2, "currency": "EUR"}]'
POST /code?database_id=123&name=manual.pdf with the raw file as the body and its real content type (for example Content-Type: application/pdf). Allowed types: PDF, JPG, PNG, GIF, TXT, CSV, TSV, XLS, MP3, EPUB. Maximum 80 MB.type: 2 and filename set.GET /codes?database_id=123. Add page and pagesize (maximum 1000), and filter with filter=[{"status":0}] for available codes, [{"status":1}] for used ones, or [{"value":"AAAA"}] to find one.PUT /code with all three fields: {"id": 456, "status": 1, "sendfirst": 0}. Both status and sendfirst must be present even when only one changes.DELETE /code with {"id": 456}. Only an available code (status: 0) can be deleted; a used code stays for the order history.After an upload, GET /codes?database_id=123&filter=[{"status":0}] includes the new values, and the database's available count under Inventory in the panel has grown by the same number.
422 on the file upload: the content type is not in the allowed list, or the file exceeds 80 MB.1,000. Codes beyond the first 1,000 in a single request are not stored and the response does not warn you, so split larger uploads into batches and count the ids you get back.
Send POST /code with database_id and name in the query and the raw file as the body, with its real content type such as application/pdf. The response is one code of type 2 with the filename set.
No. Only codes with status 0 (available) can be deleted. A used code stays so the order history remains complete.