Overview
A database is one pool of stock for one product, the same thing you create under Inventory in the panel. Every connected listing draws from it, and every code you upload belongs to one. The Database endpoints let your software create databases, read their stock counts, rename them, and remove empty ones, all from one bearer token.
TL;DR
- A database is one product's stock pool, the same thing you create under Inventory in the panel.
- Create one with
POST /database; a repeat call with the sameskureturns the existing one instead of a duplicate. - List, read, rename, and delete databases with
GET/PUT/DELETE /database. - A database cannot be deleted while it still has codes reserved for delivery (
to_sendabove 0).
Before you start
Make sure you have:
- A bearer token from
POST /login(see Getting started with the Keysender API). - The base URL
https://panel.keysender.com/api/v1.0and the headerAuthorization: Bearer YOUR_ACCESS_TOKENon every call.
A database has these fields in every response: id, name, type (0 for text codes, 1 for files), available (codes in stock), to_send (codes reserved for orders that are still delivering), and sku.
Steps
List your databases
- Send
GET /databases. Addpage,pagesize, orfilter=[{"name":"part of a name"}]to narrow the list.
curl "https://panel.keysender.com/api/v1.0/databases?pagesize=50" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Read one database
- Send
GET /database?id=123. You receive the six fields above, or422if the id is not yours.
Create a database
- Send
POST /databasewithname,sku, andtype:
curl -X POST "https://panel.keysender.com/api/v1.0/database" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Steam key: Example Game", "sku": "EXAMPLE-GAME-STEAM", "type": 0}'
- The
skuis the identifier your own systems use. If a database with that SKU already exists on your account, the API returns the existing database instead of creating a second one, so a repeated create is safe.
Rename a database
- Send
PUT /databasewithidand the newname. Theskuandtypecannot be changed after creation; create a new database instead.
Delete a database
- Send
DELETE /databasewith{"id": 123}in the body. - A database that still has codes reserved for delivery (
to_sendabove 0) cannot be deleted. Wait for those orders to finish, then retry.
Confirm it works
After POST /database, GET /databases lists the new entry with available: 0, and it appears under Inventory in the panel with the same name. After a delete, it is gone from both. Next, load it with Uploading and managing codes with the API.
Troubleshooting
| Symptom | Cause | Action |
|---|---|---|
422 with You can change only own code databases |
The id belongs to another account or does not exist |
Re-check the id with GET /databases |
| A create returns an id you already had | The SKU was already in use; that is the match, not an error | No action needed, reuse the returned id |
| A delete is refused | The database still has codes reserved for delivery (to_send above 0) |
Wait for those orders to finish, then retry |
If it still is not working
Submit a ticket with the request body (without your secret) and the response.
Quick answers
What happens if I create a database with a SKU that already exists?
The API returns the existing database instead of creating a second one. That makes create safe to run on every sync: the SKU is the match key.
Can I change a database's SKU or type after creating it?
No. PUT /database only changes the name. Create a new database for a different SKU or type and move the stock.
Why is a delete refused?
A database with codes reserved for orders still delivering (to_send above 0) cannot be deleted. Wait for those deliveries to finish, then retry.
Was this helpful?