Sell the AI Stocks catalogue from your own shop.
Read products at your prices, place prepaid orders and deliver the result to your buyer — including products that need details from your buyer, such as a redeem code or an email address.
- Prepaid in exact cents
- Retry-safe orders
- Instant & manual delivery
🚀Quick start
Get your API key on the AI Stocks Reseller Portal (or in the Telegram bot), then make four calls. Base URL: https://api.aistocks.store
GET /v1/pingGET /v1/productsPOST /v1/ordersorder.itemscurl https://api.aistocks.store/v1/products -H "Authorization: Bearer YOUR_API_KEY"
curl -X POST https://api.aistocks.store/v1/orders \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: order-1001" \
-H "Content-Type: application/json" \
-d '{"product_id":10,"qty":1}'Instant products return the delivered items in the same response. Products delivered later answer 202 with status: "pending"; you then check the order until it is delivered (see below).
🔐Authentication
Send your key on every /v1 request, in either header:
Authorization: Bearer YOUR_API_KEY
X-API-Key: YOUR_API_KEY- Keys look like
aistocks_followed by 48 hex characters (earlier keys start withqm_live_). The key is shown once when issued — store it on your server only, never in a browser or app. - Missing or unknown keys return
401. After 15 failed attempts within 5 minutes your IP is blocked for 15 minutes (429 locked_out). - A key belongs to one reseller account and only spends that account's balance. The shop can revoke it at any time.
📐Basics & limits
Format
- Requests and responses are JSON. Success:
{"ok":true,…}. Error:{"ok":false,"error":{"code":"…","message":"…"}}. - Money comes twice: exact integer cents (
unit_price_cents: 39) and a display string (unit_price: "0.39"). Currency isUSD. Calculate with cents. - Times are Unix seconds. Request bodies may be up to 32 KB.
Rate limits
- 120 requests per minute per key, of which at most 20 order attempts.
- Every authenticated response carries
X-RateLimit-Limit,X-RateLimit-RemainingandX-RateLimit-Reset(seconds until the minute resets). - Over the limit:
429 rate_limitedwith aRetry-Afterheader. Wait, then retry.
🛍️Products
GET /v1/products returns every product you can sell, at your price, with live stock. The fields you need:
| Field | Meaning |
|---|---|
id, name, description | Product identity. Sync by id — names and prices change, ids don't. |
unit_price_cents, unit_price, currency | Your price per unit of qty. |
delivery_type | "auto" = delivered instantly in the order response. Any other value (for example "manual") = delivered later; the order waits as pending. |
customer_input_fields | Details you must collect from your buyer before ordering (empty list = none). See Products that need customer data. |
stock, stock_unlimited, stock_known | How many units you can order. If stock_unlimited is true the product is available even though stock is 0. If stock_known is false, don't sell it. |
min_qty, max_qty | Allowed quantity per order (max_qty: 0 = no maximum). |
units_per_item | Items delivered per unit of qty (e.g. 5 = a pack of five accounts). |
order_cooldown_sec | Minimum time between two orders of this product (0 = none). |
instructions | Plain-text instructions & terms to give your buyer with the delivery. |
preorder_supported | true if you may order it while out of stock. See Pre-orders. |
Other fields you may see (optional)
product_type, subscription_type, has_warranty, warranty_period | Descriptive information for your product page. |
sold_total, your_sold_qty, your_sold_spent_cents | Sales statistics (shop-wide and yours). |
stock_additions, stock_notify_allowed | Restock batches, if you announce restocks to your buyers. |
emoji, custom_emoji_id | Display icon. |
customer_input_configuration_valid, preorder_* | See the sections below. |
New fields can be added at any time — ignore fields you don't use.
🛒Placing orders
POST /v1/orders pays for the order from your balance and either delivers it at once or queues it for delivery.
| Body field | Rule | |
|---|---|---|
product_id | REQUIRED | Product id from GET /v1/products. |
qty | REQUIRED | Between min_qty and max_qty. You receive qty × units_per_item items. |
customer_inputs | IF NEEDED | Your buyer's details, when the product has customer_input_fields. |
preorder | OPTIONAL | true to pre-order an out-of-stock product. |
Also send a unique Idempotency-Key header (8–128 characters: letters, digits, _, -) for every new order — see Retries.
| HTTP | Meaning |
|---|---|
201 | Delivered now — order.items contains everything. |
202 | Paid and waiting for delivery (pending or preorder). Never order again — check the order. |
200 | A retry of an order you already placed (replayed: true). |
4xx | Refused, nothing charged. See Errors. |
🧾Products that need customer data
Some products need details from your buyer — a redeem code, an account email, a username… The product tells you exactly what to ask in customer_input_fields; you pass the answers in customer_inputs. No messages to the shop are needed: the details reach the shop with the order.
customer_input_fieldsrequired firstcustomer_inputs202 → completed1. Read the fields
{"id":57,"name":"Example — tokens on your account","delivery_type":"manual",
"stock":0,"stock_unlimited":true,"unit_price":"0.70",
"customer_input_fields":[
{"key":"redeem_code","label":"Your redeem code (6 characters)","type":"text","required":true}
],
"customer_input_configuration_valid":true, …}Each field has a key (use it unchanged), a label (show it to your buyer), a type and required.
| type | Accepted value |
|---|---|
text | Up to 200 characters. |
email | A valid email address (max 254 characters). |
phone | 7–15 digits, optional leading +; spaces are removed. |
username | 3–32 letters, digits, _ or .; a leading @ is removed. |
2. Send them with the order
curl -X POST https://api.aistocks.store/v1/orders \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: order-1002" \
-H "Content-Type: application/json" \
-d '{"product_id":57,"qty":1,"customer_inputs":{"redeem_code":"AB12CD"}}'customer_inputs is one flat object: field key → text value. Leave out optional fields you don't have. One order = one buyer: different buyers need separate orders.
3. The answer
HTTP/1.1 202 Accepted
{"ok":true,
"order":{"code":"RA-7C1D2E3F4A","status":"pending","delivery_type":"manual",
"product_id":57,"qty":1,"total_cents":70,"total":"0.70","remaining_qty":1,
"customer_inputs":[{"key":"redeem_code","label":"Your redeem code (6 characters)","value":"AB12CD", …}],
"items":[], …},
"balance_cents":1250,"balance":"12.50"}The order is paid and waiting for the shop. Tell your buyer it is being processed and follow Order status & delivery.
customer_input_required (a required field is empty), invalid_customer_input (wrong format), unknown_customer_input (a key the product doesn't have — reload the product). Fix it and send again; the same idempotency key may be reused. If customer_input_configuration_valid is false, the product can't be ordered right now (409 input_configuration_error).📦Order status & delivery
status | Meaning | What to do |
|---|---|---|
completed | Delivered. | Give your buyer items[].content and instructions. If refunded_cents > 0, part was refunded — refund your buyer that part. |
pending | Paid, waiting for the shop to deliver. | Check again later. |
preorder | Paid, waiting for stock. | Check again later; you may cancel it. |
refunded | Could not be delivered; the full amount is back on your API balance. | Refund your buyer. delivery_error may say why. |
Waiting for delivery
There are no webhooks: check GET /v1/orders/:code with growing pauses (e.g. every minute, then every few minutes). When delivered:
{"ok":true,"order":{"code":"RA-7C1D2E3F4A","status":"completed","delivered_qty":1,"remaining_qty":0,
"items":[{"content":"Tokens added to your account."}],"instructions":"…", …}}items[].contentis what you deliver — a credential, a code or a confirmation message. Treat it as private.- Large orders can be delivered in parts:
itemsgrows while the order stayspending. Forward only the new entries. - Delivered-later orders also show
delivered_qty,remaining_qty,refunded_centsandclosed_at(set when finished). - Need to cancel a waiting order? Contact support with the
RA-…code. Through the API only pre-orders can be cancelled.
⏳Pre-orders
When preorder_supported is true, you can buy an out-of-stock product now and receive it as soon as stock arrives.
{"product_id":10,"qty":3,"preorder":true}- Answer:
202withstatus: "preorder". Items arrive automatically, possibly in parts (preorder_delivery_mode:partialorfull). - Limits can apply:
preorder_max_qty(per order),preorder_max_open_units(open units in total) andpreorder_allow_multiple(false= one open pre-order at a time). Over a limit:409 preorder_limit.0means no limit. - Without
preorder: true, an out-of-stock order is simply refused (409 out_of_stock) — it is never turned into a pre-order. - You can cancel the undelivered part at any time:
POST /v1/orders/:code/cancel.
🔁Retries & idempotency
A network error does not tell you whether the order went through. The idempotency key makes retrying safe.
- Create a new key for every new order and save it before sending. Send it as the
Idempotency-Keyheader (oridempotency_keyin the body). - Retry with the same key and the same body → you get the same order back (
200,replayed: true), never a second charge. - Same key with a different body →
409 idempotency_key_conflict. - A refused request (4xx) creates nothing, so its key can be reused for the corrected request.
- Lost the response? Look the order up with
GET /v1/orders/by-idempotency/:key.
curl https://api.aistocks.store/v1/ping -H "Authorization: Bearer YOUR_API_KEY"
{"ok":true,"reseller":"Your shop","status":"active","build":"reseller-api v1.4"}Works even when your account is suspended, so you can see its status.
curl https://api.aistocks.store/v1/balance -H "Authorization: Bearer YOUR_API_KEY"
{"ok":true,"balance_cents":961,"balance":"9.61","currency":"USD"}To top up, contact the shop.
curl https://api.aistocks.store/v1/products -H "Authorization: Bearer YOUR_API_KEY"
{"ok":true,"products":[
{"id":10,"name":"Example account","description":"…","instructions":"Sign in, then keep recovery details unchanged.",
"delivery_type":"auto","unit_price_cents":39,"unit_price":"0.39","currency":"USD",
"stock":808,"stock_unlimited":false,"stock_known":true,
"min_qty":1,"max_qty":0,"units_per_item":1,"order_cooldown_sec":0,
"customer_input_fields":[],"preorder_supported":false, …}
]}Not paginated. Inactive, free and unpriceable products are not listed. Field meanings: Products.
curl https://api.aistocks.store/v1/products/10 -H "Authorization: Bearer YOUR_API_KEY"
{"ok":true,"product":{"id":10,"name":"Example account","stock":808, …}}Same fields as in the list. Use it to re-check price, stock and required fields right before an order. Unknown or unavailable ids return 404 product_not_found.
curl -X POST https://api.aistocks.store/v1/orders \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: order-1001" \
-H "Content-Type: application/json" \
-d '{"product_id":10,"qty":1}'
HTTP/1.1 201 Created
{"ok":true,
"order":{"code":"RA-1A2B3C4D5E","idempotency_key":"order-1001","product_id":10,"product_name":"Example account",
"qty":1,"units_per_item":1,"delivered_item_count":1,
"unit_price_cents":39,"unit_price":"0.39","total_cents":39,"total":"0.39","currency":"USD",
"status":"completed","created_at":1789143092,"replayed":false,
"items":[{"content":"login:password"}],
"instructions":"Sign in, then keep recovery details unchanged."},
"balance_cents":961,"balance":"9.61"}Body fields and answers: Placing orders. With customer data: Products that need customer data.
curl https://api.aistocks.store/v1/orders/RA-1A2B3C4D5E -H "Authorization: Bearer YOUR_API_KEY"Returns the order with its status, delivered items and instructions, in the same shape as the order answer. Use it to wait for delivery (statuses). Someone else's or an unknown code returns 404 order_not_found.
curl https://api.aistocks.store/v1/orders/by-idempotency/order-1001 -H "Authorization: Bearer YOUR_API_KEY"Read-only: finds the order you placed with this key (never buys). No order with this key: 404 order_not_found — then it is safe to send the order again with the same key.
curl "https://api.aistocks.store/v1/orders?limit=50&offset=0" -H "Authorization: Bearer YOUR_API_KEY"
{"ok":true,"orders":[{"code":"RA-1A2B3C4D5E","product_id":10,"product_name":"Example account","qty":1,
"total_cents":39,"total":"0.39","status":"completed","created_at":1789143092, …}]}Newest first. limit 1–200 (default 50), offset from 0; stop when a page is shorter than limit. The list leaves out items and customer data — open an order to see them.
curl -X POST https://api.aistocks.store/v1/orders/RA-1A2B3C4D5E/cancel -H "Authorization: Bearer YOUR_API_KEY"
{"ok":true,"replayed":false,"refunded_cents":250}Cancels the undelivered part of a pre-order and returns its price to your API balance; delivered items stay delivered. Safe to repeat. Other orders return 409 cancel_not_allowed — ask support to cancel those.
curl https://api.aistocks.store/v1/sold -H "Authorization: Bearer YOUR_API_KEY"
{"ok":true,"items":[{"product_id":10,"product_name":"Example account","qty":40,"orders":38,
"spent_cents":1560,"spent":"15.60","currency":"USD","first_at":1786500000,"last_at":1789143092}],
"total_qty":40,"total_spent_cents":1560,"total_spent":"15.60","currency":"USD"}Counts delivered units only.
🚨Errors
Every error is {"ok":false,"error":{"code":"…","message":"…"}}. A refused request never charges your balance.
| HTTP | code | What to do |
|---|---|---|
| 400 | invalid_json, invalid_request, invalid_product_id, invalid_qty, invalid_idempotency_key, idempotency_key_mismatch, invalid_preorder, bad_request | Fix the request. |
| 400 | qty_out_of_range | Use a quantity between min_qty and max_qty (both are in the error). |
| 400 | customer_input_required, invalid_customer_input, unknown_customer_input, invalid_customer_inputs | Correct your buyer's details (customer data) and send again. |
| 401 | missing_or_malformed_key, invalid_key | Check your API key. |
| 403 | reseller_suspended, access_revoked | Contact the shop. |
| 404 | product_not_found, order_not_found, not_found | Check the id, code or path. |
| 409 | out_of_stock | Not enough stock (for instant products available in the error says how many are left). Order less, later, or as a pre-order. |
| 409 | insufficient_balance | Top up your API balance. |
| 409 | idempotency_key_conflict | This key was used for a different order — use a new key. |
| 409 | preorder_disabled, preorder_limit | Pre-order not possible for this product or over its limit. |
| 409 | cancel_not_allowed | Only pre-orders can be cancelled here — ask support. |
| 409 | input_configuration_error, pricing_error, invalid_balance, unsupported_source, invalid_cost | A problem on the shop's side — contact the shop. |
| 413 | body_too_large | Keep the body under 32 KB. |
| 429 | rate_limited, locked_out | Wait for Retry-After seconds. |
| 429 | cooldown | This product was ordered too recently (order_cooldown_sec; orders from your linked Telegram account count too). Wait retry_after_seconds. |
| 500 503 | internal_error, busy | Temporary. Retry after a short pause with the same idempotency key. |
🏆Best practices
- Show your buyers whether a product is delivered instantly or later, and collect the required details before they pay you.
- Re-check the product (
GET /v1/products/:id) right before ordering: price, stock and required fields can change. - Save the idempotency key before sending, and the
RA-…code after. Never place a second order because the first one is still pending. - Keep the API key, delivered items and your buyers' details out of logs and out of browsers.
- Calculate with the
*_centsfields, not the display strings. - Back off on
429,500and503.
🧩Code examples
Order a product (with customer data if it needs any) and wait until it is delivered.
const BASE = 'https://api.aistocks.store', KEY = process.env.API_KEY;
const api = (path, opts = {}) => fetch(BASE + path, { ...opts,
headers: { Authorization: 'Bearer ' + KEY, 'Content-Type': 'application/json', ...opts.headers } })
.then(r => r.json());
async function buy(productId, qty, customerInputs, idempotencyKey) {
const res = await api('/v1/orders', { method: 'POST',
headers: { 'Idempotency-Key': idempotencyKey },
body: JSON.stringify({ product_id: productId, qty, customer_inputs: customerInputs }) });
if (!res.ok) throw new Error(res.error.code + ': ' + res.error.message);
let order = res.order;
while (order.status === 'pending' || order.status === 'preorder') {
await new Promise(r => setTimeout(r, 60000)); // check once a minute
order = (await api('/v1/orders/' + order.code)).order;
}
return order; // completed → order.items ; refunded → refund your buyer
}
// buy(57, 1, { redeem_code: 'AB12CD' }, 'order-1002')import os, time, requests
BASE, KEY = 'https://api.aistocks.store', os.environ['API_KEY']
H = {'Authorization': 'Bearer ' + KEY}
def buy(product_id, qty, customer_inputs, idempotency_key):
body = {'product_id': product_id, 'qty': qty}
if customer_inputs: # only when the product has fields
body['customer_inputs'] = customer_inputs
r = requests.post(BASE + '/v1/orders', json=body,
headers={**H, 'Idempotency-Key': idempotency_key}).json()
if not r['ok']:
raise Exception(r['error']['code'] + ': ' + r['error']['message'])
order = r['order']
while order['status'] in ('pending', 'preorder'):
time.sleep(60) # check once a minute
order = requests.get(BASE + '/v1/orders/' + order['code'], headers=H).json()['order']
return order # completed -> order['items'] ; refunded -> refund your buyer
# buy(57, 1, {'redeem_code': 'AB12CD'}, 'order-1002')❓FAQ
A product shows stock: 0 — can I sell it?
Yes, if stock_unlimited is true. Otherwise it is out of stock (or offer a pre-order when preorder_supported is true).
My order has been pending for a while.
Products delivered by the shop take some time. Keep checking the order; never buy again. If it takes unusually long, contact support with the RA-… code.
How do I send my buyer's redeem code / email to the shop?
In customer_inputs with the order — see Products that need customer data. No separate message is needed.
Why is a product missing from the list?
It is inactive, free, not sold through the API (e.g. file downloads), or has no price for API sales right now.
Did my order go through after a timeout?
Check GET /v1/orders/by-idempotency/:key, or simply send the same request with the same key — you'll get the existing order, never a second charge.
🗒️Changelog
customer_inputs. The old deferred-v1 capability header is no longer needed (it is still accepted). Documentation rewritten.202 pending orders with automatic delivery or automatic refund.order_cooldown_sec, 429 cooldown, quantity limits in qty_out_of_range./v1/sold.💬Support
For API access, balance top-ups or a question about an order, contact the shop. Mention your reseller name and the RA-… order code — never send your API key.