Keys
Generate keys
Generates keys for a product and deducts from your balance.
POST
/keysToken permission: Generate keys keys:generatespends credits
Charges the price of the chosen duration times the quantity. Without enough balance, nothing is generated or charged.
Idempotency-Key required
Every call carries the Idempotency-Key header, a unique code per request. Repeating with the same code, you get the same keys without paying again. Why?
Headers
| Header | Required | Description |
|---|---|---|
Idempotency-Key | Yes | A unique code per request (a UUID works). Up to 100 characters: letters, digits and _ - : . |
Content-Type | Yes | application/json |
Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
product_id | number | Yes | The product, from the product list. |
quantity | number | Yes | How many keys to generate, from 1 to 50. |
days | number | No | The duration, among the product plans. Without it, 30 days. If the product has no 30-day plan, days is required. |
The price is always calculated on our side, from the duration and the quantity. Any other field in the body is ignored.
Response
| Field | What it is |
|---|---|
generation_id | The id of this batch. It shows up in the statement as reference_id. |
keys[].key_code | The key to deliver to the customer. |
keys[].user_id | The key id in the API (to look it up and reset its HWID). |
days | The duration of the generated keys. |
credits_spent | The total charged. |
balance | Your balance after the charge. |
Repeating the same request
Repeating with the same Idempotency-Key and the same body, the response brings the same keys and does not charge again. It comes with "idempotent_replay": true in data and the Idempotent-Replayed: true header.
Errors
| HTTP | When | What to do |
|---|---|---|
402 | Not enough balance. Nothing was generated or charged. | errors.balance has your balance. Buy credits and try again. |
403 | The token lacks the Generate keys permission. | Create a token with it. |
409 | The Idempotency-Key was already used for a different request, or the first request is still running. | New request: use a new code. Same request: wait a few seconds and retry. |
422 | Invalid data, missing or malformed Idempotency-Key, unavailable product, or a duration the product does not have. | The message says what to fix. A wrong duration lists the options in errors.days. |
429 | Over the limit. | Wait the seconds in Retry-After and try again. |
500 | Failure on our side while generating. | The credits go back to your balance (errors.credits_refunded says how much). Retry with the same Idempotency-Key. If the message mentions a partial refund, or it keeps failing, contact support. |