Keys

Generate keys

Generates keys for a product and deducts from your balance.

POST/keys

Token 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

HeaderRequiredDescription
Idempotency-KeyYesA unique code per request (a UUID works). Up to 100 characters: letters, digits and _ - : .
Content-TypeYesapplication/json

Body (JSON)

FieldTypeRequiredDescription
product_idnumberYesThe product, from the product list.
quantitynumberYesHow many keys to generate, from 1 to 50.
daysnumberNoThe 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

FieldWhat it is
generation_idThe id of this batch. It shows up in the statement as reference_id.
keys[].key_codeThe key to deliver to the customer.
keys[].user_idThe key id in the API (to look it up and reset its HWID).
daysThe duration of the generated keys.
credits_spentThe total charged.
balanceYour 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

HTTPWhenWhat to do
402Not enough balance. Nothing was generated or charged.errors.balance has your balance. Buy credits and try again.
403The token lacks the Generate keys permission.Create a token with it.
409The 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.
422Invalid 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.
429Over the limit.Wait the seconds in Retry-After and try again.
500Failure 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.