Diamond Cart API
اربط موقعك أو تطبيقك أو بوتك بمتجرنا: بتجيب كل المنتجات بأسعارك أنت (سعر مستواك كتاجر، نفس يلي بتشوفو بالمتجر)، بتتحقق من ID اللاعب، وبتعمل طلبات بتنشحن أوتوماتيك وبتندفع من رصيدك عنا.
- الـ API لحسابات التجّار بس، وبيتفعّل لكل حساب لحالو من المتجر: احكينا لنفعّلك. بعد ما يتفعّل، بتعمل المفتاح من: حسابي ← API للتجّار (لازم يكون إيميلك مأكّد). مستواك كتاجر ما بيفرق.
- لحد ما يتفعّل لحسابك (أو إذا انسكّر)، كل طلب بيرجع
403 API_DISABLEDوما بينخصم شي. التسكير ما بيمحي مفتاحك: لما يرجع يتفعّل، نفس المفتاح بيشتغل (ما في داعي لمفتاح جديد). إلا التجديد التلقائي لرقم افتراضي إذا كان مشغّل: بيضل يتجدّد من رصيدك بآخر يوم حتى والـ API مسكّر. لتوقّفو:POST /numbers/{id}/auto-renewمع{ "enabled": false }بيمشي حتى والـ API مسكّر (هوي بس)، أو طفّيه من «أرقامي الافتراضية» بالمتجر، أو احكينا. - المفتاح بيطلع مرة وحدة بس. خبّيه بالسيرفر تبعك، ولا تحطّو أبداً بصفحة أو تطبيق بيوصلو للزباين.
- مع كل منتج بـ
/products: سعرك، نوعو (topupشحن مباشر،codeبطاقة كود،subscriptionاشتراك،billفاتورة)، شو لازم تبعت بالطلب، إذا متوفّر هلّق (available)، وطريقة الاستعمال (howto). - إذا الطلب فشل، المبلغ بيرجع لرصيدك أوتوماتيك، وحالة الطلب بتصير
cancelled. - حد 60 طلب شرا بالدقيقة لكل حساب (كل
POST /ordersبينحسب، انعمل أو لأ). فوقو:429 RATE_LIMITEDمعRetry-After(كم ثانية تستنّى)، وما بينخصم شي. - رصيد ألفا / تاتش (Credits): طلب واحد لنفس الرقم بالدقيقة. طلب تاني لنفس الرقم قبل دقيقة:
429 TOO_SOONمعretry_after(ثواني)، وما بينخصم شي. استنّى وابعتو من جديد. - المنتجات يلي منعبّيها بإيدنا (يدوي) ما بتنطلب بالـ API: بتطلع بـ
/productsمعavailable: falseوunavailable_reason: "manual"(اطلبها من المتجر). ومنتج كل مورّديه برّا ساعاتهن أو موقّفين هلّق:available: false("off_hours"/"paused")، جرّب بعدين. طلبها بيرجع404 PRODUCT_UNAVAILABLEوما بينخصم شي. - طلبات الـ API ما إلها إيميل لكل طلب (انشحن / انلغى ورجعت المصاري): تابعها بـ
GET /orders، وبيوصلك إشعار عالتطبيق. إيميلات الأمان (مفتاح جديد، كود الدخول، كلمة السر) متل ما هي. - ابعت دايماً
client_order_id(رقمك إنت، غير لكل طلب). خطأ4xx= ما انخصم شي. خطأ5xxأو ما وصلك جواب = الطلب ممكن يكون انعمل: شيّك بـGET /orders?client_order_id=…أو أعد نفس الطلب بنفس الرقم (ما بينخصم مرتين). ولا مرة تعيد برقم جديد.
شراء بطاقة كود بالـ API (خطوة بخطوة)
- جيب البطاقات:
GET /products?type=codeواختار منتجavailable: true. السعر يلي فيه هوي سعرك. - اعمل الطلب:
POST /ordersمعproduct_idوclient_order_idبس، بلاplayer_id. لمنتجات ألفا / تاتش يلي فيهاdelivery_optionsزيد"delivery": "code". - الرد غالباً بيكون
completedدغري ومعو الكود. إذا لسّاpending: اسألGET /orders/{id}كل 5 لـ 10 ثواني لحد ما يصيرcompletedأوcancelled. - الكود بيكون بـ
delivery.code(ومعوdelivery.serialوdelivery.expiryتاريخ انتهاء البطاقة إذا في، وdelivery.howtoطريقة الاستعمال). هيدا يلي بتعطيه للزبون.
شحن ألفا / تاتش المباشر ("delivery": "direct"): لما يخلص (completed) delivery بيضل null، وممكن يكون مع الطلب card ({ "serial": "…", "pin": "…" }): البطاقة يلي المورّد شحن فيها الخط — مستعملة. خلّيها دليل عالشحن؛ إذا الرصيد ما وصل عالخط، فيك تجرّب الـ PIN بإيدك. ما تعطيها للزبون كأنها بطاقة جديدة.
دفع فاتورة Alfa / Touch / Ogero (خطوتين)
- جيب الفاتورة:
POST /bills/fetchمعproduct_id(منتجtype: "bill") وnumber(رقم الخط، أو الأرضي لـ Ogero). بيرجعلك المبلغ بالليرة، سعرك بالدولار، وquote_id. - إذا الرد فيه
otp_required: true: صاحب الخط وصلو كود، ابعتو بـPOST /bills/otpمعquote_idوotp، وبيرجعلك المبلغ والسعر. - ادفع:
POST /ordersمعproduct_idوquote_id(وclient_order_id). بتندفع هالفاتورة بالزبط وبهالسعر. quote_idصالح 10 دقايق وبينستعمل مرة وحدة. حد 100 "جيب فاتورة" بالساعة (مع المتجر)، و10 بالساعة لكل رقم (من كل الحسابات سوا:429 RATE_LIMITED).- إذا دفعة لنفس الرقم لسّا عم تتنفّذ (جواب المزوّد ما كان واضح وفريقنا عم يشيّك):
409 BILL_PENDINGمعerror.order_id— شيّك عهالطلب قبل ما تدفع مرة تانية. ما بينخصم شي. - إذا جبت رقم عندك فاتورتو لسّا ناطرة الكود (أقل من 10 دقايق): بيرجعلك نفس
quote_id(reused: true) بلا كود جديد لصاحب الخط. ابعت الكود يلي وصلو. ونفس الشي إذا جبت الرقم مرتين سوا (مثلاً إعادة بعد timeout): التانية بتستنّى الأولى، وما بيروح كود تاني.
تقرير سيارة CarFax / AutoCheck / Image (رقم الشاصي)
- المنتج: بـ
GET /productsمنتج التقارير فيهvin_check: trueوأنواع التقرير بـreport_types(carfax،autocheck،image). - افحص رقم الشاصي (ببلاش):
POST /check-playerمعproduct_idوplayer_id(رقم الشاصي، 17 حرف ورقم) وreport_type. إذاfound: trueفي تقرير (السيارة وعدد السجلات). إذاfound: falseما في تقرير بهالنوع: جرّب نوع تاني أو تأكّد من الرقم. - اشتري:
POST /ordersمع نفسplayer_idوreport_type(وclient_order_id). التقرير بيوصل رابط بـdelivery.link. - السيرفر بيفحص الرقم مرة تانية قبل ما يشتري (إلا إذا فحصتو من حسابك بنفس النوع من أقل من 10 دقايق): إذا ما في تقرير، الطلب بيتلغى (
cancelled) والمبلغ بيرجع لرصيدك أوتوماتيك. رقم شاصي غلط ما بينخصم عليه شي (BAD_VIN). حد 60 فحص رقم شاصي بالساعة.
أرقام افتراضية (شراء رقم واستلام الأكواد)
- جيب الأرقام المتوفرة بسعرك:
GET /numbers/available(وفيك تفلتر ببلد:?country=US). لكل رقم سعر الشهر وسعر السنة. إذاservice_available: falseالخدمة واقفة هلّق، جرّب بعد شوي. - اشتري:
POST /numbersمعnumber(الرقم متل ما هو باللائحة) وmonths(1 أو 12: مدة الشرا، هيي مدة الرقم بعدين، شوف التجديد تحت) وclient_order_id. بينخصم السعر من رصيدك، والطلب بيكونpending. - اسأل
GET /orders/{id}كل 5 لـ 10 ثواني: بالعادة خلال دقيقة بيصيرcompleted(الرقم صار إلك) أوcancelled(ما زبط، ورجعت المصاري لرصيدك). رقم الرقم (number_id) هو نفسو رقم الطلب. - الأكواد:
GET /numbers/{id}/messages. كل رسالة فيهاidثابت، المرسل (from) والنص (text)، وcode: تخمين منطلّعو من النص (ممكن يكون غلط، متل مبلغ أو سنة أو تاريخ قبل الكود)، والنصtextهو المرجع. لتستنّى كود جديد: اسأل كل 5 ثواني مع?stored_after=أكبرstored_atعندك (وقت ما الرسالة وصلتنا)، وما تاخد نفسidمرتين: رسالة ممكن توصلنا متأخرة، ووقت إرسالها (received_at) أقدم من رسائل صارت عندك، فـ?after=(علىreceived_at) ما بيرجّعها. الرسائل بتنمحى بعد 30 يوم من ما يخلص الرقم (أو من ما نسحبو برجعة مصاري): خلّي الأكواد يلي بتحتاجها عندك. - الرقم بيضل إلك للمدة يلي اشتريتها. ما في تجديد لحالو: جدّد بـ
POST /numbers/{id}/renew(بلاmonths= مدة الشرا)، أو شغّل التجديد التلقائي بـPOST /numbers/{id}/auto-renew: بآخر يوم قبل ما يخلص، بينخصم من رصيدك سعر التجديد لمدة الشرا (monthsبـGET /numbers: رقم اشتريتو لسنة بيتجدّد سنة، حتى لو جدّدتو شهر بالنص) وبيتجدّد بطلب لحالو. ما في خصم قبل هاليوم. حد السعر: التجديد التلقائي ما بيخصم أكتر من 1.25 × آخر سعر دفعتو لنفس المدة؛ إذا السعر أغلى، الرقم ما بيتجدّد وما بينخصم شي (منبعتلك إشعار عالتطبيق بس، بلا إيميل): جدّدو بإيدك بـPOST /numbers/{id}/renew. تجديد ردّو الأول مش أكيد بيستنّى 10 دقايق قبل ما نعيد، فممكن يخلص بعدexpires_at: بهالوقت الرقم بيضلactiveمعrenewing: trueوبتوصلو الرسائل. إذا رجّعنالك مصاري شرا رقم، الرقم بيرجع إلنا وبيبيّنexpired؛ وإذا رجّعنا مصاري تجديد، المدة يلي زادها بتنشال. التجديد التلقائي بيضل شغّال حتى إذا الـ API مسكّر لحسابك: طفّيه بـ"enabled": falseأو من «أرقامي الافتراضية» بالمتجر. إذا خلصت المدة بلا تجديد، الرقم بيروح وما بيرجع. - أرقامك كلها:
GET /numbers. الحدود لكل حساب: 20 لائحة بالدقيقة (عدّاد لحالو، غير المتجر)، 6 شرا / تجديد بالدقيقة، و120 قراية (أرقامي والرسائل) بالدقيقة. فوقها:429 RATE_LIMITEDوما بينخصم شي.
الشرح التقني الكامل تحت بالإنكليزي لأنو للمبرمجين.
Connect your website, app or bot to our store: fetch all products at your own reseller prices (your dealer level, the same prices you see in the store), verify player IDs, and place orders that are fulfilled automatically and paid from your store balance.
- The API is for reseller (dealer) accounts only, and access is enabled per account by the store: contact us to enable it. Once it is enabled, create your key from My account → API for resellers.
- The key is shown only once. Keep it on your server; never put it in a web page or app that your customers can download.
- For your safety, creating a new key needs a recent sign-in (last 15 minutes) and a verified email, and we notify you (app notification and email) whenever a key is created. A password reset or a forced sign-out also revokes your key.
- A new key (or rotating your key) needs API access to be switched on for your account by the store (your dealer level does not matter, see Access) and a verified email. If your key is revoked (password reset, forced sign-out, or you revoked it), create a new one while access is on, or contact us.
- Every product in
/productstells you its price for you, its type (topup,code,subscription,bill), what to send when ordering, whether it can be ordered now (available) and how to use it (howto). - Alfa / Touch / Ogero bills are paid in two steps: fetch the bill (you get the amount, your price and a
quote_id), then order with thequote_id. - Vehicle reports (CarFax / AutoCheck / Image): check the VIN for free, then order with the VIN and the
report_type. If there is no report, the order is cancelled and refunded automatically. - Virtual numbers (numbers that receive SMS verification codes): list the numbers at your price, buy one for 1 or 12 months, and read the messages it receives. Nothing renews by itself: you renew it, or switch on auto-renew.
- If an order fails, the amount is refunded to your balance automatically and the order status becomes
cancelled. - Limits: at most 60 orders per minute per account (
429 RATE_LIMITEDwithRetry-After, nothing charged). Products our team fills by hand can't be ordered through the API, and a product whose suppliers are all off or paused right now can't be ordered until they are back: see Limits, availability and notifications. - Always send a
client_order_id. An error4xxmeans nothing was charged. A5xxerror, a timeout or no answer means the order may exist: checkGET /orders?client_order_id=…or send the same request again with the sameclient_order_id(it is never charged twice). Never retry with a new id. See Errors and retries.
Authentication
Send your key in the X-API-Key header on every request (or Authorization: Bearer <key>). All our answers are JSON, errors included. A gateway or timeout error (502 / 504 from the hosting platform, or no answer at all) may not be JSON: treat it like 5xx (see Errors and retries). All prices are in USD.
Base URL: https://diamond-cart.com/api/v1
curl https://diamond-cart.com/api/v1/balance \ -H "X-API-Key: sfw_your_key_here"
Access
API access is enabled per account by the store. Until it is enabled for your account, every request with a valid key gets 403 with the code API_DISABLED (on every endpoint, except switching a virtual number's auto-renew off, below), and nothing is charged:
{ "ok": false, "error": { "code": "API_DISABLED", "message": "API access is not enabled for this account. Contact the store to enable it.",
"message_ar": "الـ API مش مفعّل لحسابك. احكينا لنفعّلك." } }
- The store can switch access off and on again at any time. It takes effect on the very next request.
- Switching access off never deletes your key: when it is switched on again, the same key works. You do not need a new key.
- Virtual numbers: auto-renew that was switched on keeps renewing from your balance while access is off (on the last day, see auto-renew). To stop it,
POST /numbers/{id}/auto-renewwith{ "enabled": false }still works while access is off (the only request that does; switching it on does not), or switch it off in the store under My virtual numbers, or ask us. - While access is off, the API page in My account is hidden, so you cannot manage your key there. If you think your key has leaked, reset your password (that revokes the key, see above) or contact us. Creating a new key needs access to be on and a verified email.
Product types: what to send
| Product | Send in POST /orders | You get back |
|---|---|---|
type: "topup" (direct top-up) | product_id + player_id (see player_id_label: Player ID, Phone number or VIN). For Lebanese lines (Alfa / Touch direct recharges and OneZone line products such as U-share) the number must be 8 digits (71123456, 03123456; +961 71 123 456 is fine). | Delivered to the player / number. delivery is null, except vehicle reports (vin_check: true): the report link in delivery.link. |
type: "code" (code card, eSIM) | product_id only. No player_id. | delivery.code (eSIM: delivery.qr / delivery.lpa) |
Has "delivery_options": ["direct","code"] (Alfa / Touch) | "delivery": "code" for a card code, or "delivery": "direct" + player_id (the phone number) for a direct recharge | Code: delivery.code. Direct: null (when completed, the order may also have a card). |
type: "subscription" (TV) | phone (the customer's mobile with the country code, 10-15 digits), plus first_name + last_name when requires_name (the account is made in the customer's name) | Login details or link in delivery (see what delivery can hold) |
custom_amount: true | units (between min_units and max_units) + player_id | Delivered to the player. |
type: "bill" (Alfa / Touch / Ogero bill) | product_id + quote_id from POST /bills/fetch | The bill is paid. bill has the bill id and LBP amount. |
vin_check: true (vehicle report) | product_id + player_id (the 17-character VIN) + optional report_type. Check the VIN first. | The report link in delivery.link. |
Buying a code card (step by step)
1. List the code products and pick one with available: true. price is what you pay.
curl "https://diamond-cart.com/api/v1/products?type=code" -H "X-API-Key: sfw_your_key_here"
{ "ok": true, "currency": "USD", "count": 1, "products": [
{ "id": "bc-55", "name": "Alfa $7.58", "category": "telecom", "group": "Alfa", "type": "code", "available": true,
"requires_player_id": false, "requires_phone": false, "requires_name": false,
"description": "كود رقمي", "howto": "Dial *14*CODE# to recharge", "image": "https://…",
"custom_amount": false, "max_quantity": 1, "price": "7.80", "price_cents": 780 } ] }
2. Order it with product_id only (and your own client_order_id, so a retry never charges twice). Do not send player_id. For a product with delivery_options, add "delivery": "code".
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"bc-55","client_order_id":"my-2001"}'
3. The response is often already completed with the code. If it is still pending, check GET /orders?client_order_id=my-2001 every 5–10 seconds until it is completed or cancelled (cancelled = refunded).
{ "ok": true, "order": { "id": "api_…", "client_order_id": "my-2001", "status": "completed", "product_id": "bc-55",
"total": "7.80", "total_cents": 780,
"delivery": { "kind": "code", "code": "12345678901234", "serial": "998877", "expiry": "31-12-2027", "howto": "Dial *14*CODE# to recharge" } } }
4. Give your customer delivery.code (and delivery.serial / delivery.expiry when present) with the howto instructions. serial, expiry and howto only appear when they exist.
Limits, availability and notifications
| What | Limit | Over the limit |
|---|---|---|
POST /orders | 60 per minute per account. Every request counts, placed or refused (a retry with the same client_order_id too). | 429 RATE_LIMITED with a Retry-After header (seconds). Nothing is charged; send the same request again after the wait. |
Alfa / Touch credit transfers (POST /orders, the products named "Alfa Credits $N" / "Touch Credits $N") | One order per phone number per minute, whoever orders it (all accounts, the store and the API together). The minute starts when the previous transfer was answered. | 429 TOO_SOON with error.retry_after and a Retry-After header (seconds). Nothing is charged; send the order again after the wait. To send several amounts to one number, wait a minute between them or order one bigger amount. |
POST /check-player | 60 VIN checks per hour per account (vehicle reports). For any other product the call is answered without a check and is not counted. | 429 RATE_LIMITED |
POST /bills/fetch | 100 bill lookups per hour per account (shared with your store account), and 10 per hour per number (provider + number however it is written, all accounts, the store and the API together). | 429 RATE_LIMITED (with message_ar; Retry-After for the per-number limit). The provider is not asked. |
| Virtual numbers | GET /numbers/available: 20 per minute (its own counter: the numbers pages of the store do not count). POST /numbers and POST /numbers/{id}/renew: 6 per minute together (valid requests count, placed or refused; shared with your store account). GET /numbers, /numbers/{id}, /numbers/{id}/messages and POST …/auto-renew: 120 per minute together. | 429 RATE_LIMITED with Retry-After. Nothing is charged. |
HTTP/1.1 429 Too Many Requests
Retry-After: 37
{ "ok": false, "error": { "code": "RATE_LIMITED", "message": "Too many orders this minute (max 60), try again shortly",
"message_ar": "طلبات كتير بالدقيقة، جرّب بعد شوي." } }
The order of checks for POST /orders: your key and API access (401 / 403) → the 60-a-minute limit (429) → the request format (400, e.g. no product_id or a bad client_order_id) → an order you already placed with this client_order_id is returned as it is ("duplicate": true, even if the product is not available any more) → the product can be ordered now (404 PRODUCT_UNAVAILABLE) → price, balance and the rest. Nothing is charged on any of these errors.
available: false in GET /products comes with unavailable_reason (it is null when available is true). POST /orders refuses all of these products with 404 PRODUCT_UNAVAILABLE, and nothing is charged. POST /check-player and POST /bills/fetch refuse them the same way (same body, nothing checked or counted), except "no_price": a product without a price for your account can still be checked (bills have no fixed price, so this reason never applies to them):
unavailable_reason | Meaning | Error when you order it |
|---|---|---|
"manual" | Our team fills this product by hand: it is not sold through the API. Your customers can still order it in the store. | "message": "This product is filled by hand by the store: it can't be ordered through the API", "message_ar": "المنتج مش متوفر" |
"off_hours" | Outside working hours: the product's own hours, or every supplier that can deliver it is off right now. | "message": "Product is not available right now, try again later", "message_ar": "المنتج مش متوفر هلّق، جرّب بعدين" |
"paused" | The suppliers that can deliver it are paused right now (for example after repeated failures). It comes back by itself when the pause is over (a few hours); until our next stock check, at most an hour later, it can still show as "sold_out". | "message": "Product is not available right now, try again later", "message_ar": "المنتج مش متوفر هلّق، جرّب بعدين" |
"sold_out" | Sold out, or the supplier has none right now. | "message": "Product not found or not available" |
"no_price" | No price for your account yet. | "message": "Product has no price" |
New reasons may appear: treat any available: false as "do not order now". The list can be up to a minute old; POST /orders always checks again.
No e-mail per order. Orders placed through the API do not send an e-mail when they are completed, cancelled or refunded (the store's own orders still do): follow them with GET /orders. If you use our app, you still get its notification. Security and account e-mails are not affected (a new API key, sign-in codes, password changes).
Endpoints
GET/balance
Your current balance.
{ "ok": true, "balance": "48.20", "balance_cents": 4820, "currency": "USD" }
GET/products
All products with your prices (your dealer level). Products that are sold out, paused by the supplier or outside their working hours are still listed, with available: false and the reason in unavailable_reason: do not order them until they are true again. Products our team fills by hand are listed with available: false and unavailable_reason: "manual": they are not sold through the API (see availability). Bills (type: "bill") have no fixed price, so they are listed only with ?type=bill: see Paying a bill. Internet plans need steps in the store and are not in the API.
Keep the list on your side and refresh it every few minutes at most: it can be up to a minute old, and it is a large answer. You do not need to call it before each order: POST /orders always checks the product and its price again, refuses a product that is not available (404 PRODUCT_UNAVAILABLE, nothing charged), and charges the price of the moment (send max_total_cents to cap it). Some code products are filled by hand by our team: their delivery can be null when completed (then contact us with the order_no).
Optional filters: ?type=code (code cards, plus the products with delivery_options), ?type=topup, ?type=subscription, ?type=bill (bills are only in this list), ?category=telecom, ?group=Alfa (exact values from the list).
| Field | Meaning |
|---|---|
id | Send it as product_id. |
name, name_en | Name (and English name when set, else null). |
category, category_name, category_name_en, group | Where it is in the store. |
type | topup, code, subscription or bill (see the table above). |
available | true = can be ordered now. |
unavailable_reason | Why available is false: "manual" (filled by hand, not sold through the API), "off_hours", "paused", "sold_out" or "no_price" (see availability). null when available. |
requires_player_id, player_id_label | Send player_id; the label says what it is (Player ID, Phone number, VIN (17 letters/digits)). |
requires_phone, requires_name | Subscriptions: send phone (and first_name + last_name). |
delivery_options | Only on products that can be a direct recharge or a code: ["direct","code"]. Choose with delivery. |
description, howto, image | Short note, how to use / redeem it, and the picture URL (each can be null). |
price, price_cents, max_quantity | Fixed packages (custom_amount: false): your price per item, and the most you can order at once (1 = one per order). |
min_units, max_units, price_per_1000, price_per_1000_cents | Custom amounts (custom_amount: true). The price per 1000 can be smaller than a cent (e.g. "0.0423" = 4.23 cents). You pay ceil(units × price_per_1000_cents / 1000) cents. |
requires_quote, bill_provider, number_label | Bills only (type: "bill", price: null): alfa, touch or ogero, and what to send as number (Phone number / Landline number). The price comes from POST /bills/fetch. |
vin_check, report_types, default_report_type | Vehicle reports only (vin_check: true): the report types you can send as report_type (["carfax","autocheck","image"]) and the one used when you leave it out. See Vehicle reports. |
{
"ok": true, "currency": "USD", "count": 3,
"products": [
{ "id": "dc-107", "name": "Tokens 150000", "name_en": null, "category": "games", "category_name": "ألعاب", "category_name_en": "Games",
"group": "جواكر", "type": "topup", "available": true, "unavailable_reason": null, "requires_player_id": true, "player_id_label": "Player ID",
"requires_phone": false, "requires_name": false, "description": "شحن مباشر بالـ ID", "howto": null, "image": "https://…",
"custom_amount": false, "max_quantity": 20, "price": "17.50", "price_cents": 1750 },
{ "id": "bc-12", "name": "Touch $4.5", "category": "telecom", "group": "Touch", "type": "topup", "available": true, "unavailable_reason": null,
"requires_player_id": true, "player_id_label": "Phone number", "delivery_options": ["direct", "code"],
"custom_amount": false, "max_quantity": 1, "price": "4.90", "price_cents": 490 },
{ "id": "dc-321-custom", "name": "Jawaker Unit", "category": "games", "group": "جواكر", "type": "topup", "available": false, "unavailable_reason": "off_hours",
"requires_player_id": true, "player_id_label": "Player ID",
"custom_amount": true, "min_units": 10000, "max_units": 1000000, "price_per_1000": "0.0423", "price_per_1000_cents": 4.23 }
]
}
POST/check-player
Player-ID verification is not available: for every product except vehicle reports this endpoint answers valid: null with a note, and nothing is checked or counted. You can skip it; an order with a wrong ID is refunded automatically. A product_id that is unknown, store-only or can't be ordered right now (sold out, supplier off, outside its hours), or that our team fills by hand (unavailable_reason: "manual"), gets 404 PRODUCT_UNAVAILABLE (with message_ar). For a vehicle report (vin_check: true) it checks the VIN instead: see Vehicle reports.
curl -X POST https://diamond-cart.com/api/v1/check-player \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"dc-107","player_id":"5123456789"}'
{ "ok": true, "valid": null, "player_name": null, "note": "Verification not available for this product" }
POST/orders
Place an order. The total is taken from your balance immediately. A request refused with a 4xx error takes nothing. After a 5xx error or no answer, the order may exist: see Errors and retries. The answer can take several seconds (we contact the provider): give your HTTP client a timeout of at least 30 seconds. At most 60 orders per minute per account (429 RATE_LIMITED + Retry-After), and only products with available: true can be ordered (404 PRODUCT_UNAVAILABLE otherwise, e.g. a product filled by hand or with every supplier off right now): see Limits.
| Field | Type | |
|---|---|---|
product_id | string | Required. From /products. |
player_id | string | Required if requires_player_id (for delivery_options products: only with "delivery": "direct"). Never needed for type: "code". |
delivery | "direct" | "code" | Only for products with delivery_options. code = card code (no player_id), direct = recharge to player_id. If you leave it out: with player_id = direct, without = code. |
phone | string | Subscriptions (requires_phone): the customer's mobile, e.g. 96171123456 or 71123456. |
first_name, last_name | string ≤ 40 | Subscriptions with requires_name: the customer's name. |
quantity | integer 1–max_quantity | Fixed packages only. Default 1. Codes, Alfa / Touch and subscriptions: always 1 (one order per item). |
units | integer | Custom-amount products only (e.g. 150000). |
client_order_id | string ≤ 64 | Needed for safe retries (always send it). Your own ID (A-Z a-z 0-9 _ -), unique for each purchase, forever and across all your terminals. Sending the same order again never charges twice: you get the existing order back with "duplicate": true. The same order means the same product, number, quantity / units, delivery, report_type (left out = the product's default) and quote_id, however the number is written (spaces, +961, a VIN with O for 0…); fields the product doesn't use (e.g. player_id on a code card, phone outside subscriptions) don't count. Reusing it for a different order (other product, number, quantity…) is refused with 409 IDEMPOTENCY_MISMATCH: that request takes nothing, but the order already placed with this ID stands (error.order_id): check it with GET /orders/{order_id} before buying again. |
max_total_cents, max_price_cents | integer (cents) | Optional price cap. Prices can change at any time (hourly repricing, your level), and an order is charged at the price of the moment. If the total is above max_total_cents, or the price per item above max_price_cents (fixed packages and bills), the order is refused with 409 PRICE_CHANGED (nothing charged; error.price_cents / error.total_cents give the current price). A lower price goes through. |
quote_id | string | Bills only (type: "bill"), and required there: from POST /bills/fetch. No player_id or quantity needed. |
report_type | "carfax" | "autocheck" | "image" | Vehicle reports only (vin_check: true; 1, 2, 3 also accepted). Default: the product's default_report_type. Any other value is refused (400 BAD_REQUEST, nothing charged). Ignored for other products. See Vehicle reports. |
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"dc-107","player_id":"5123456789","quantity":1,"client_order_id":"my-1001"}'
{
"ok": true, "duplicate": false,
"order": {
"id": "api_...", "order_no": "10048213", "client_order_id": "my-1001",
"status": "pending", "product_id": "dc-107", "product_name": "Tokens 150000",
"player_id": "5123456789", "quantity": 1, "units": null,
"total": "17.50", "total_cents": 1750, "refunded": false,
"created_at": "2026-10-08T10:15:02.000Z", "completed_at": null, "cancelled_at": null,
"delivery": null
}
}
Code card example (no player_id):
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"bc-55","client_order_id":"my-2001"}'
Alfa / Touch as a code (product with delivery_options):
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"bc-12","delivery":"code","client_order_id":"my-2002"}'
Alfa / Touch as a direct recharge:
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"bc-12","delivery":"direct","player_id":"71123456","client_order_id":"my-2003"}'
Subscription example (TV):
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"tv-netflix-1m","phone":"96171123456","first_name":"Ali","last_name":"Saad","client_order_id":"my-1002"}'
POST/bills/fetch → /orders: paying a bill (Alfa / Touch / Ogero)
Bills have no fixed price. 1. Fetch the bill of a number: you get the amount in LBP, your price in USD (same price as in the store) and a quote_id. Nothing is charged yet.
curl -X POST https://diamond-cart.com/api/v1/bills/fetch \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"oz-bill-alfa","number":"71123456"}'
{ "ok": true, "quote_id": "q3f9c…", "otp_required": false, "product_id": "oz-bill-alfa", "number": "71123456",
"bill_id": 501, "amount_lbp": 1790000, "price": "20.40", "price_cents": 2040, "currency": "USD",
"expires_at": "2026-11-08T10:25:02.000Z" }
| Field | Type | |
|---|---|---|
product_id | string | Required. A product with type: "bill" (GET /products?type=bill). |
number | string | Required. Alfa / Touch: the line number (71123456, +961 71 123 456 is fine). Ogero: the landline (01123456). |
Other answers: "no_bill": true (nothing to pay on this number, no quote_id), or "otp_required": true: the provider sent a code to the line owner's phone. Ask your customer for it and send it:
curl -X POST https://diamond-cart.com/api/v1/bills/otp \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"quote_id":"q3f9c…","otp":"4321"}'
→ the same answer as a fetched bill (amount_lbp, price, price_cents, same quote_id),
or "no_bill": true (nothing to pay, quote_id null)
If the provider does not answer the code (502 TEMPORARY), send the same code again: that try is not counted. If the code was accepted but the price could not be computed right now (also 502 TEMPORARY), send the same request again: the code is not sent to the provider again and no try is counted (up to 20 such retries per minute for your account; after that 429 RATE_LIMITED with Retry-After, "message_ar": "استنّى شوي وجرّب").
2. Pay it: POST /orders with product_id and quote_id (and your client_order_id). We pay exactly that bill at that price.
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"oz-bill-alfa","quote_id":"q3f9c…","client_order_id":"bill-1001"}'
{ "ok": true, "duplicate": false, "order": { "id": "api_…", "client_order_id": "bill-1001", "status": "completed",
"product_name": "Alfa Bill · 1,790,000 LBP", "player_id": "71123456", "total": "20.40", "total_cents": 2040,
"bill": { "provider": "alfa", "bill_id": 501, "amount_lbp": 1790000 }, "refunded": false, … } }
- A
quote_idis valid for 10 minutes and can be paid once; after that, fetch the bill again (410 QUOTE_EXPIRED). You can hold quotes for several customers at the same time. - A bill already paid: a quote is refused with
409 BILL_CHANGED, anderror.order_idis always the order that paid. For 24 hours after a payment from your account (API or store), the samebill_idis refused from any quote, fetched before or after that payment:{ "code": "BILL_CHANGED", "message": "This bill (bill_id 501) was already paid from your account in the last 24 hours (order api_…): check it with GET /api/v1/orders/api_…. Nothing was charged", "message_ar": "هالفاتورة اندفعت من شوي من حسابك. شوف طلباتك قبل ما تدفع مرة تانية.", "order_id": "api_…" }. Check that order withGET /orders/{order_id}; do not fetch and pay again. A quote is also refused when the same number was paid with anotherbill_idafter that quote was fetched (for example a bill with a verification code, which gets a newbill_idon every fetch, fetched twice and one quote paid):"message_ar": "الفاتورة تغيّرت. جيب الفاتورة من جديد"; check that order, then fetch again to see what is due now. An order that was cancelled and refunded blocks nothing; after the 24 hours, the provider's own check applies (BILL_ALREADY_PAID/NO_BILL_DUE). - A payment still being processed: while a payment for the same number is still being processed (for example the provider's answer was unclear and our team is checking it), a new fetch, or the payment of any quote of that number (fetched before or after that payment), from the API or the store, is refused with
409 BILL_PENDING(error.order_id,"message_ar": "دفعتك لهالرقم عم تتنفّذ. استنّى لتخلص وبعدين جيب الفاتورة."): check that order withGET /orders/{order_id}before paying again. Nothing is charged and the provider is not asked. (If 300 or more bill payments of one provider are still being processed for your account, bills of that provider answer503 TEMPORARYuntil some of them are resolved.) - Up to 100 bill lookups per hour (shared with your store account), and 5 code tries per quote. One number can be looked up 10 times per hour at most, from all accounts together (the store and the API), however it is written (
71123456,071123456and+961 71 123 456are the same number): after that,429 RATE_LIMITEDwithRetry-Afterand"message_ar": "جبت هالرقم كتير هالساعة، جرّب بعد شوي."; the provider is not asked. - No second code for a pending quote: if you fetch a number that already has a quote waiting for its code (same provider and number, from your account, less than 10 minutes old, tries left), you get that same quote back (same
quote_id,"otp_required": true,"reused": true) and the provider is not asked again, so the line owner gets no new SMS. It is not counted in the limits. Send the code the owner already received withPOST /bills/otp. Once that quote is paid, expired or out of tries, a new fetch asks the provider again. - Look-ups at the same time: if a look-up of the same number from your account is still waiting for the provider (for example you retried after your own timeout), the new one waits for it instead of asking the provider again: if a code was sent, you get that same quote (
"reused": true); otherwise the new look-up asks the provider itself. If the first one is still waiting after a few seconds, you get429 RATE_LIMITEDwithRetry-After("message_ar": "استنّى شوي وجرّب"): send the request again after that wait. - Bill errors meant for your customer (
BILL_*,NO_BILL_DUE,BAD_NUMBER,BAD_OTP,OTP_*,QUOTE_*,TEMPORARY,RATE_LIMITEDon the bill endpoints) also carrymessage_ar: the Arabic sentence our store shows.
POST/check-player → /orders: vehicle reports (CarFax / AutoCheck / Image)
A vehicle report product has vin_check: true in /products, with report_types (["carfax","autocheck","image"]) and default_report_type. You send the car's VIN as player_id: 17 letters and digits. Lower case, spaces and dashes are fine, and the letters O / Q (read as 0) and I (read as 1) are corrected, so 1hgcm8-2633a-o04352 is the VIN 1HGCM82633A004352.
1. Check the VIN for free: is there a report of this type for this car? Nothing is charged.
curl -X POST https://diamond-cart.com/api/v1/check-player \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"oz-990001","player_id":"1HGCM82633A004352","report_type":"carfax"}'
{ "ok": true, "valid": true, "found": true, "vin": "1HGCM82633A004352", "report_type": "carfax",
"records": 74, "vehicle": "2015 NISSAN ROGUE S", "player_name": "2015 NISSAN ROGUE S · 74 records",
"checked_until": "2026-11-10T10:25:02.000Z" }
No report: still 200, with found: false and the reason (show message_ar / message to your customer). Try another report_type or check the VIN.
{ "ok": true, "valid": false, "found": false, "vin": "1HGCM82633A004352", "report_type": "autocheck",
"records": 0, "vehicle": "", "player_name": null,
"message": "No report for this VIN with this report type (0 records): try another report type",
"message_ar": "ما في تقرير لهالرقم بهالنوع (0 سجلات). جرّب نوع تاني أو تأكّد من الرقم" }
{ "ok": true, "valid": false, "found": false, "vin": "1HGCM82633A004352", "report_type": "carfax",
"records": 0, "vehicle": "", "player_name": null,
"message": "No vehicle found for this VIN", "message_ar": "ما لقينا سيارة بهالرقم. تأكّد من رقم الشاصي" }
Errors (nothing charged; every one has message_ar except BAD_REQUEST):
{ "ok": false, "error": { "code": "BAD_VIN", "message": "player_id must be a 17-character VIN (letters and digits)", "message_ar": "رقم الشاصي لازم يكون 17 حرف ورقم" } } // 400
{ "ok": false, "error": { "code": "BAD_REQUEST", "message": "report_type must be \"carfax\", \"autocheck\" or \"image\" (or 1, 2, 3)" } } // 400
{ "ok": false, "error": { "code": "PRODUCT_UNAVAILABLE", "message": "Product not found or not available", "message_ar": "المنتج مش متوفر" } } // 404
{ "ok": false, "error": { "code": "RATE_LIMITED", "message": "Too many VIN checks this hour (max 60), try again later", "message_ar": "فحصت كتير أرقام شاصي هالساعة. جرّب بعد شوي." } } // 429
{ "ok": false, "error": { "code": "TEMPORARY", "message": "Could not check the VIN right now, try again later", "message_ar": "ما قدرنا نفحص رقم الشاصي هلّق، جرّب بعد شوي" } } // 502 (503: checks are off right now)
2. Order it with the same VIN and report_type (and your client_order_id). The report is a link in delivery.link.
curl -X POST https://diamond-cart.com/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"oz-990001","player_id":"1HGCM82633A004352","report_type":"carfax","client_order_id":"car-1001"}'
{ "ok": true, "duplicate": false, "order": { "id": "api_…", "client_order_id": "car-1001", "status": "completed",
"product_name": "Vehicle Report · CarFax", "player_id": "1HGCM82633A004352", "report_type": "carfax", "total": "5.50", "total_cents": 550,
"delivery": { "kind": "link", "title": "Carfax Report", "link": "https://…", "ref": "…" }, … } }
- We check the VIN again before buying. If you checked the same VIN with the same
report_typefrom your account and the order comes beforechecked_until(10 minutes), that check is used. If there is no report, the order is cancelled and refunded automatically (status: "cancelled",refunded: true): we never buy a report that has no records. - A VIN that is not 17 letters / digits is refused before anything is charged (
400 BAD_VIN), and so is an unknownreport_type(400 BAD_REQUEST).player_idin the order is the corrected VIN. - Orders for vehicle reports have
report_type("carfax","autocheck"or"image") inPOST /ordersandGET /orders. It is the report bought, andproduct_nameends with it (… · CarFax,… · AutoCheck,… · Image). - Up to 60 VIN checks per hour per account (
429 RATE_LIMITEDafter that). A check that was refused before reaching the provider (BAD_VIN,BAD_REQUEST,PRODUCT_UNAVAILABLE,503) is not counted. vehicleis plain text from the provider (can be empty): escape it if you put it in a web page.
GET/orders/{id} or /orders?client_order_id=my-1001
Order status. Poll until it is no longer pending: every 5–10 seconds for codes, every 30–60 seconds for subscriptions. Give your poll loop a time limit: if an order is still pending after 30 minutes (24 hours for subscriptions), contact us with its order_no; our team is alerted too.
| status | Meaning |
|---|---|
pending | Being delivered (usually seconds to a few minutes). |
completed | Delivered. If delivery is not null, give it to your customer, whatever the product type. |
cancelled | Failed. The full amount was refunded to your balance (refunded: true). This is final. |
completed is not always final: our support can later cancel and refund a completed order (for example a code that did not work). It then becomes cancelled, refunded: true, with cancelled_at set and completed_at kept, and delivery becomes null. Rarely, a correction moves an order back to pending (completed_at is then null). Check your recent orders again and reconcile with GET /balance; every cancellation also sends a notification to our app (API orders get no e-mail, see notifications).
When completed, delivery holds what to give the customer (only the fields that apply; every value is a string):
"delivery": { "kind": "code", "code": "1234-5678-9012", "serial": "998877", "expiry": "31-12-2027", "howto": "How to redeem…" }
"delivery": { "kind": "esim", "title": "Turkey 1GB", "qr": "https://… or data:image/png;base64,…",
"lpa": "LPA:1$smdp.example$ACTIVATION", "code": "ACTIVATION", "smdp": "smdp.example", "iccid": "8990…" }
"delivery": { "kind": "creds", "title": "Netflix 1 Month", "email": "acc@example.com", "password": "••••",
"profile": "Profile 2", "pin": "1234", "expiry": "2026-12-08" }
"delivery": { "kind": "creds", "title": "OSN+ 1 Month", "email": "acc@example.com", "profile": "P1",
"otp": "https://…", "expiry": "2026-12-08" }
"delivery": { "kind": "shahid", "title": "Shahid VIP", "email": "acc@example.com", "password": "••••",
"username": "3", "profile": "P1", "expiry": "2026-12-08" }
"delivery": { "kind": "link", "title": "Netflix 1 User", "link": "https://…", "profile": "P2", "pin": "1234", "expiry": "2026-12-08" }
"delivery": { "kind": "link", "title": "Carfax Report", "link": "https://…", "ref": "REF-1" }
"delivery": { "kind": "note", "title": "U-share", "note": "انشحنت الباقة على خطّك ✓" }
"delivery": { "kind": "number", "number": "+12125550100", "expiry": "2026-12-11T19:46:05.000Z" }
| kind | Fields |
|---|---|
code | code, serial, expiry (the card's expiry date as the supplier gives it, usually DD-MM-YYYY), howto: a card code. |
esim | title, qr (image link or data:image), lpa, code (activation code when there is no lpa), smdp, iccid, howto. |
creds, shahid | Login details: title, email, username (the user number on a shared account), password, profile, pin, expiry. OSN has no password: otp is an https link that gives the login code. |
link | title, link (open it), profile, pin, expiry; vehicle reports add ref. |
note | title, note: information only (e.g. a bundle charged on the line). |
number | number, expiry (ISO time): a virtual number you bought or renewed. Its messages are in GET /numbers/{id}/messages; the order also has a number object with the number_id. |
New kinds and fields may appear: show every string field to your customer, and open link / otp values (https) as links.
Alfa / Touch direct recharges: a completed direct recharge keeps "delivery": null and may carry a top-level card object, "card": { "serial": "41000100000001", "pin": "12345678901234" } (only the fields the supplier gave; strings): the card the supplier applied to the line. It is already used: keep it as proof of the recharge; if the balance did not arrive on the line, the PIN can be tried by hand. It is not a new card to give out. Other orders have no card.
Subscriptions can take 1–3 minutes. Sometimes the provider needs longer to prepare the account (rarely up to 24 hours): the order stays pending with no delivery until the real login details are ready. Keep polling until the status changes. If we correct a delivered subscription later, the next GET returns the corrected delivery.
GET/numbers/available → POST/numbers: virtual numbers (SMS codes)
Phone numbers that receive text messages (verification codes). You buy a number for 1 or 12 months, it is registered to your account, and you read the messages sent to it through the API. The number receives SMS only: it cannot call or send messages. The flow:
GET /numbers/available: the numbers you can buy, at your price.POST /numbers: buy one. You get an order,pending.GET /orders/{id}every 5–10 seconds: usually within a minute it iscompleted(the number is yours) orcancelled(refunded). The number's id (number_id) is the id of that order.GET /numbers/{id}/messages: the messages (codes) it received. Poll it while your customer waits for a code.- Before it expires:
POST /numbers/{id}/renew, or switch onPOST /numbers/{id}/auto-renew(it renews for the period the number was bought for). Nothing renews by itself; a number that expires is released and cannot be recovered.
Limits per account: GET /numbers/available 20 a minute (its own counter); purchases and renewals 6 a minute together; the other calls (your numbers, messages, auto-renew) 120 a minute together. Above them: 429 RATE_LIMITED with Retry-After, nothing charged (see Limits).
GET/numbers/available
The numbers on sale right now with your prices. Optional filter: ?country=US (2-letter country code). Refresh the list just before buying: a number can be taken by someone else at any moment.
{ "ok": true, "currency": "USD", "service_available": true, "countries": ["US", "GB"], "count": 2,
"numbers": [
{ "number": "+12125550100", "country": "US", "city": "New York",
"price_1_month": "2.40", "price_1_month_cents": 240, "price_12_months": "24.00", "price_12_months_cents": 2400 },
{ "number": "+447700900000", "country": "GB", "city": "London",
"price_1_month": "4.80", "price_1_month_cents": 480, "price_12_months": "37.20", "price_12_months_cents": 3720 }
] }
service_available: false (with an empty list) means numbers cannot be bought right now: try again later. countries lists every country that has numbers, whatever the filter.
POST/numbers
Buy a number. The price is charged from your balance at once; if the number cannot be bought the order is cancelled and refunded automatically.
{ "number": "+12125550100", "months": 1, "client_order_id": "num-1001", "max_price_cents": 240 }
| Field | Meaning | |
|---|---|---|
number | required | A number from GET /numbers/available, as listed (spaces, dashes and brackets are ignored). |
months | optional | 1 (default) or 12, as a number or the string "1" / "12" (anything else is 400 BAD_REQUEST). It stays the number's period: a renewal sent without months and auto-renew use it. |
client_order_id | recommended | Your own id for this purchase, a string (1-64 chars of A-Z a-z 0-9 _ -), the same rule as POST /orders: sending the same request again returns the same order with "duplicate": true and never charges twice. The same id with another number or period is 409 IDEMPOTENCY_MISMATCH. |
max_price_cents | optional | The most you accept to pay, in cents: a whole number, or a string of digits only. If the price is higher: 409 PRICE_CHANGED (with price_cents), nothing charged. A lower price goes through. |
HTTP/1.1 201 Created
{ "ok": true, "duplicate": false,
"order": { "id": "api_…_num-1001", "order_no": "10073956", "client_order_id": "num-1001", "status": "pending",
"product_id": "fanytel", "product_name": "Virtual number +12125550100 · 1 month", "player_id": "12125550100",
"quantity": 1, "units": null,
"number": { "action": "buy", "number": "+12125550100", "months": 1, "number_id": "api_…_num-1001" },
"total": "2.40", "total_cents": 240, "refunded": false, "created_at": "2026-11-11T19:46:05.000Z",
"completed_at": null, "cancelled_at": null, "delivery": null } }
Then poll GET /orders/{id}. When it is completed, delivery is { "kind": "number", "number": "+12125550100", "expiry": "…" } and the number is in GET /numbers under number.number_id. If our system cannot start buying it within about 15 minutes, the order is cancelled and refunded by itself. If the number is still pending after 30 minutes, contact us with the order_no. If we later refund a completed purchase (its order becomes cancelled, refunded: true), we take the number back: it shows as expired in GET /numbers (its expires_at keeps the end of the period it had), it no longer receives messages and auto-renew is off.
Rarely, when the order could not be read back right after it was placed, the 201 / 200 answer (here and for a renewal) carries "order_no": null and "created_at": null (and, for a renewal sent without months, "months": null in number). The order exists and was charged as shown, but that answer always says "status": "pending", even a "duplicate": true answer for an order that has since completed or been refunded: read it again with GET /orders/{id} for its real status.
Refused before anything is charged: 409 NUMBER_UNAVAILABLE (the number was taken: pick another one from the list), 409 PRICE_CHANGED, 402 INSUFFICIENT_BALANCE, 503 TEMPORARY (numbers cannot be bought right now), 429 RATE_LIMITED (6 purchases / renewals a minute).
GET/numbers
Your numbers, active first, newest first (at most 200). Optional filter: ?status=active or ?status=expired. If your account has more than 500 numbers, the expired part of the list may leave some out, even recent ones: read any number with GET /numbers/{id} (its id is the number.number_id of its purchase order).
{ "ok": true, "count": 1, "numbers": [
{ "id": "api_…_num-1001", "number": "+12125550100", "country": "US", "city": "New York", "status": "active", "months": 1,
"purchased_at": "2026-11-11T19:46:40.000Z", "expires_at": "2026-12-11T19:46:05.000Z",
"auto_renew": false, "renewing": false, "messages_count": 2, "last_message_at": "2026-11-11T19:52:10.000Z" } ] }
| Field | Meaning |
|---|---|
id | The number's id (number_id): use it in the paths below. It is the id of the order that bought it. |
status | active, or expired (its period ended, or we refunded its purchase and took it back: it no longer receives messages and cannot be renewed). A number whose renewal is still being completed (renewing: true) stays active after expires_at and keeps receiving messages; it becomes expired only if that renewal is cancelled and refunded. |
months | The period chosen when the number was bought: 1 or 12. Renewals do not change it. It is the period of a renewal sent without months, and the period auto-renew renews for. |
auto_renew, renewing | Auto-renew is on; a renewal order is in progress right now. |
messages_count, last_message_at | Messages kept for this number (the latest 30; none 30 days after it expired, see GET /numbers/{id}/messages) and the time of the newest one, or null. |
GET/numbers/{id}
One number with its messages and renewal: what a renewal costs you now (null when the number has expired or renewals are not available right now).
{ "ok": true,
"number": { "id": "api_…_num-1001", "number": "+12125550100", "status": "active", "expires_at": "2026-12-11T19:46:05.000Z", "…": "…",
"renewal": { "price_1_month": "2.40", "price_1_month_cents": 240, "price_12_months": "24.00", "price_12_months_cents": 2400 } },
"messages": [ { "id": "…", "from": "WhatsApp", "text": "Your WhatsApp code: 123-456", "code": "123456", "received_at": "2026-11-11T19:52:10.000Z",
"stored_at": "2026-11-11T19:52:24.000Z" } ] }
GET/numbers/{id}/messages
The messages the number received, oldest first by received_at. Every message has an id (stable: the same message always has the same id), received_at (when it was sent to the number) and stored_at (when it reached us).
With ?stored_after= you get only the messages that reached us after that time: send the latest stored_at you have (ISO 8601, URL-encoded, or a time in milliseconds). ?after= filters on received_at (the messages sent after that time), as before; both can be sent together.
GET /numbers/api_…_num-1001/messages?stored_after=2026-11-11T19%3A52%3A24.000Z
{ "ok": true, "number_id": "api_…_num-1001", "number": "+12125550100", "status": "active", "count": 1,
"messages": [ { "id": "…", "from": "Google", "text": "G-482913 is your Google verification code.",
"code": "482913", "received_at": "2026-11-11T19:55:31.000Z", "stored_at": "2026-11-11T19:55:44.000Z" } ] }
- Waiting for a code: poll every 5 seconds with
?stored_after=set to the lateststored_atyou have (the largest one, not the one of the last message in the list: the list is ordered byreceived_at), de-duplicate byid, and stop after a few minutes. Why: a message can reach us late and out of order (several messages at once, or a delay on our side), with areceived_atolder than messages you already have, so?after=with thereceived_atof your last message would never return it. A message usually shows up 10–20 seconds after it was sent. codeis a best guess extracted from the text (4 to 8 digits, or123-456), otherwisenull. It can be wrong: an amount, a year or a date written before the code can be taken for it.textis authoritative: when it matters, read the code fromtext(or showtextto your customer).fromandtextcome from outside as they arrived: treat them as plain text (escape them before showing them in a page).- The latest 30 messages are kept per number. Messages sent before you bought the number, or after it expired, are never shown (while a renewal is still being completed,
renewing: true, the number keeps receiving them). - Messages are deleted 30 days after the number expired (or after we took it back with a refund): the number stays in
GET /numberswithmessages_count: 0, and this endpoint answers"count": 0. Keep the codes you need on your side.
POST/numbers/{id}/renew
Extend the number by 1 or 12 months, charged from your balance at your renewal price (see renewal in GET /numbers/{id}). The answer is an order, like POST /numbers ("number": { "action": "renew", … }): poll it until it is completed (the new expires_at is on the number) or cancelled (refunded, the number keeps its old date). When the provider's first answer is unclear we wait 10 minutes before trying again (so a renewal is never paid twice there): a renewal can then stay pending for up to about 30 minutes and complete after expires_at. Meanwhile the number stays active with renewing: true and keeps receiving messages; if it is still pending after 30 minutes, contact us with its order_no. If we later refund a completed renewal, the period it added is taken off expires_at and auto-renew is switched off.
{ "months": 12, "client_order_id": "renew-1001", "max_price_cents": 2400 }
months defaults to the period the number was bought for (months in GET /numbers), even if you renewed it for another period since: renewing for another period does not change it. client_order_id and max_price_cents work as in POST /numbers, and so does the rare answer with "order_no": null and "created_at": null (read the order again with GET /orders/{id}). Renew at least 10 minutes before expires_at. Refused before anything is charged: 409 NUMBER_EXPIRED, 409 RENEWAL_IN_PROGRESS (a renewal of this number is already running, started by you or by auto-renew: poll GET /numbers/{id} until renewing is false, then expires_at has moved, or is unchanged if that renewal was refunded; a renewal you started yourself can also be followed by its order), 409 PRICE_CHANGED, 402 INSUFFICIENT_BALANCE, 503 TEMPORARY, 404 NOT_FOUND (not one of your numbers).
POST/numbers/{id}/auto-renew
Switch auto-renew on or off for one number (it is off after a purchase). When it is on, in the last 24 hours before expires_at the number is renewed for the period it was bought for (months in GET /numbers: 12 for a number bought for 12 months, even if you renewed it for 1 month since), and the renewal price of that period at that moment (your price, as in renewal of GET /numbers/{id}) is charged from your balance by an order of its own. To renew for another period, switch auto-renew off and renew it yourself with months. If your balance is not enough the number is not renewed. Nothing is charged before that day.
Price limit: auto-renew never charges more than 1.25 × the price you last paid for that period (the purchase, or the last renewal for the same period). If the renewal price is higher, the number is not renewed and nothing is charged; auto-renew stays on and is tried again about every hour until the number expires, so renew it yourself with POST /numbers/{id}/renew (the price is in renewal of GET /numbers/{id}) if you want to keep it. In both cases (balance or price) we send a notification to our app only (no e-mail): if you work only through the API, check in the last day that expires_at moved.
Auto-renew does not depend on API access: if the store switches API access off for your account (403 API_DISABLED), auto-renew that is on keeps renewing from your balance. POST /numbers/{id}/auto-renew with { "enabled": false } still works then (the only request that does; switching it on does not), or switch it off in the store under My virtual numbers, or ask us.
{ "enabled": true }
{ "ok": true, "number": { "id": "api_…_num-1001", "number": "+12125550100", "status": "active", "auto_renew": true, "…": "…" } }
Errors and retries
{ "ok": false, "error": { "code": "INSUFFICIENT_BALANCE", "message": "Balance 3.00 is less than 17.50" } }
{ "ok": false, "error": { "code": "BILL_ALREADY_PAID", "message": "This bill is already paid", "message_ar": "الفاتورة مدفوعة أصلاً، ما في شي تدفعو هلّق" } }
4xx= nothing was charged. Fix the request (or wait, for429). For409 IDEMPOTENCY_MISMATCHthat request took nothing, but an earlier order with the sameclient_order_idexists: check it before buying again.5xx, a timeout, no answer or an answer that is not JSON = the order may exist. Send the same request again with the sameclient_order_id(you get the order back with"duplicate": trueif it was placed, and it is never charged twice), or look it up first withGET /orders?client_order_id=…. Never retry with a newclient_order_id.- Once an order is placed,
POST /ordersanswers201with the order even if the provider is slow: apendingorder is followed up and refunded automatically if the provider refuses it.
| HTTP | code | When |
|---|---|---|
| 401 | UNAUTHORIZED | Missing / wrong / revoked key, or the account is no longer a reseller. |
| 401 | KEY_REVOKED | The key was created before a password reset or a forced sign-out of the account, so it no longer works. Usually only the first request after a reset gets this code; later requests, and keys revoked by our team, get UNAUTHORIZED. Any 401 means this key no longer works: create a new key in My account → API (needs API access switched on for your account and a verified email, see Access), or contact us. Alert on both codes. |
| 403 | API_DISABLED | API access is not enabled for this account (the store enables it per account, see Access). Every endpoint answers this until it is enabled, and nothing is charged through the API, with one exception: auto-renew of a virtual number that was switched on keeps renewing from your balance on the last day (see auto-renew). To stop it, POST /numbers/{id}/auto-renew with { "enabled": false } still works while access is off (the only request that does), or switch it off in the store under My virtual numbers, or ask us. Your key is kept: once access is on again, the same key works. |
| 400 | BAD_REQUEST, BAD_JSON | Missing or invalid fields, a body that is not a JSON object, or a delivery the product doesn't have (e.g. "direct" on a code card). |
| 400 | PLAYER_ID_REQUIRED | This product needs player_id (the message says what: Player ID, Phone number or VIN). |
| 400 | BAD_VIN | Vehicle reports: player_id is not a 17-character VIN (letters and digits), in /check-player or /orders. Nothing is charged. |
| 400 | BAD_NUMBER | Orders: player_id must be a Lebanese line number, 8 digits (Alfa / Touch direct recharges and OneZone line products). Bills: invalid number. Nothing is charged. |
| 400 | PHONE_REQUIRED, BAD_PHONE, NAME_REQUIRED | Subscriptions need phone (10-15 digits with the country code) and first_name + last_name when requires_name. |
| 400 | BAD_QUANTITY, BAD_UNITS | Quantity above max_quantity, or units out of range. |
| 402 | INSUFFICIENT_BALANCE | Top up your balance first. |
| 404 | PRODUCT_UNAVAILABLE, NOT_FOUND | Unknown product / order / endpoint, a product with available: false right now (see unavailable_reason: off hours, paused, sold out), a product filled by hand by our team (store only), or an internet plan (store only). Nothing was charged. |
| 409 | CONFLICT | This client_order_id is already taken by an order that is not one of your API orders. Nothing was charged; send a different client_order_id. |
| 409 | IDEMPOTENCY_MISMATCH | This client_order_id already has an order with other details (error.order_id); for a bill paid without client_order_id: its quote_id was already used. This request was not placed, but that order stands: check it with GET /orders/{order_id} before buying again. Use a new client_order_id only for a new purchase. |
| 409 | PRICE_CHANGED | The price is above your max_total_cents / max_price_cents. Nothing was charged. |
| 409 | NUMBER_UNAVAILABLE, NUMBER_EXPIRED, RENEWAL_IN_PROGRESS | Virtual numbers: the number was taken (pick another one from GET /numbers/available); the number has expired and cannot be renewed or changed; a renewal of this number is already in progress, started by you or by auto-renew (poll GET /numbers/{id} until renewing is false: expires_at has then moved, or is unchanged if that renewal was refunded; a renewal you started yourself can also be followed by its order). Nothing was charged. |
| 400 | QUOTE_REQUIRED, BAD_NUMBER, BAD_OTP | Bills: order without quote_id; missing / invalid number; missing otp. |
| 400 | BILL_NOT_FOUND, NO_BILL_DUE, BILL_ALREADY_PAID, OTP_WRONG | Bills: the provider's answer (see message_ar). |
| 409 | OTP_REQUIRED, QUOTE_MISMATCH, BILL_CHANGED, BILL_PENDING | Bills: send the code first (or, after a 502 on /bills/otp, send that same request again: same quote_id and otp); the quote_id is for another product / number; this bill_id was paid from your account in the last 24 hours, or the number was paid with another bill_id after this quote was fetched (fetch again) — both with error.order_id, the order that paid; a payment for this number is still being processed (error.order_id). |
| 410 | QUOTE_EXPIRED | Bills: the quote_id is older than 10 minutes or already used. Fetch the bill again. |
| 429 | TOO_SOON | Alfa / Touch credit transfers: this phone number got a credit order less than a minute ago (from any account). Nothing was charged; wait error.retry_after seconds and send the order again. |
| 429 | RATE_LIMITED, OTP_TOO_MANY | Too many orders (60 per minute: wait the Retry-After seconds, then send the same request again), VIN checks (60 per hour) or bill lookups (100 per hour per account, 10 per hour per number, or the same number already being looked up for your account: wait the Retry-After seconds), price retries of an accepted bill code (20 per minute); too many wrong codes for a bill (fetch it again). Nothing was charged. Try again later. |
| 502 / 503 / 500 | TEMPORARY, SERVER_ERROR | Try again shortly (a VIN check or bill lookup the provider could not answer, too; 503 TEMPORARY on POST /numbers or a renewal: virtual numbers cannot be bought right now, nothing was charged). For POST /orders, POST /numbers and POST /numbers/{id}/renew the order may exist: retry only with the same client_order_id, or check GET /orders?client_order_id=… first. |
Example (Node.js)
const BASE = "https://diamond-cart.com/api/v1";
const KEY = process.env.DIAMOND_API_KEY; // keep it on your server
// { status, body, retryAfter }: body is null when the answer is not JSON (gateway / timeout), status 0 = no answer
async function call(path, body) {
try {
const r = await fetch(BASE + path, {
method: body ? "POST" : "GET",
headers: { "X-API-Key": KEY, "Content-Type": "application/json" },
body: body ? JSON.stringify(body) : undefined,
signal: AbortSignal.timeout(30000)
});
let json = null;
try { json = await r.json(); } catch {}
return { status: r.status, body: json, retryAfter: Number(r.headers.get("retry-after")) || 0 };
} catch {
return { status: 0, body: null };
}
}
const sleep = ms => new Promise(r => setTimeout(r, ms));
const unsure = r => r.status === 0 || r.status >= 500 || !r.body; // the order MAY exist
// Place an order safely: on 5xx / timeout, send the SAME request (same client_order_id) again
async function placeOrder(order) { // order.client_order_id is required
for (let i = 0; i < 5; i++) {
const r = await call("/orders", order);
if (r.status === 429 && r.retryAfter) { await sleep(r.retryAfter * 1000); continue; } // 60 orders a minute: wait, same request again
if (!unsure(r)) {
if (!r.body.ok) throw new Error(r.body.error.code + ": " + r.body.error.message); // 4xx: nothing charged (IDEMPOTENCY_MISMATCH: see error.order_id first)
return r.body.order; // new, or the existing one ("duplicate": true)
}
await sleep(3000 * (i + 1));
}
throw new Error("Unknown result: check GET /orders?client_order_id=" + order.client_order_id + " before ordering again");
}
// Wait until the order is no longer pending, with a time limit
async function waitOrder(order, maxMs = 30 * 60e3) {
const t0 = Date.now();
while (order.status === "pending") {
if (Date.now() - t0 > maxMs) throw new Error("Still pending: contact support with order " + order.order_no);
await sleep(5000);
const r = await call("/orders?client_order_id=" + encodeURIComponent(order.client_order_id));
if (r.body?.ok) order = r.body.order; // (5xx / timeout: just ask again)
}
return order; // "completed", or "cancelled" (refunded)
}
// Direct top-up
const top = await waitOrder(await placeOrder({ product_id: "dc-107", player_id: "5123456789", client_order_id: "my-1001" }));
console.log(top.status);
// Code card: product_id only, then give the customer what is in delivery
async function buyCode(productId, myId, delivery) {
const o = await waitOrder(await placeOrder({ product_id: productId, client_order_id: myId, ...(delivery ? { delivery } : {}) }));
if (o.status === "cancelled") return null; // refunded to your balance
return o.delivery; // { kind: "code", code, serial?, expiry?, howto? }; null when completed = contact support
}
const card = await buyCode("bc-55", "my-2001");
const alfaCode = await buyCode("bc-12", "my-2002", "code"); // product with delivery_options
// Bill: fetch (+ code if asked), show the price to your customer, then pay with the quote_id
async function payBill(productId, number, myId, askCode) {
let q = (await call("/bills/fetch", { product_id: productId, number })).body;
if (!q?.ok) throw new Error(q ? q.error.code + ": " + q.error.message : "no answer, try again");
if (q.no_bill) return null; // nothing to pay
if (q.otp_required) q = (await call("/bills/otp", { quote_id: q.quote_id, otp: await askCode() })).body;
if (!q?.ok) throw new Error(q ? q.error.code + ": " + q.error.message : "no answer, send the same code again");
if (q.no_bill) return null; // (after the code too)
console.log(q.amount_lbp + " LBP → $" + q.price); // your price
return waitOrder(await placeOrder({ product_id: productId, quote_id: q.quote_id, client_order_id: myId, max_total_cents: q.price_cents }));
}
// Vehicle report: check the VIN (free), then buy the same VIN + report type
async function buyReport(productId, vin, reportType, myId) {
const c = (await call("/check-player", { product_id: productId, player_id: vin, report_type: reportType })).body;
if (!c?.ok) throw new Error(c ? c.error.code + ": " + c.error.message : "no answer, try again"); // BAD_VIN, RATE_LIMITED, TEMPORARY…
if (!c.found) return { noReport: c.message }; // try another report_type
const o = await waitOrder(await placeOrder({ product_id: productId, player_id: c.vin, report_type: c.report_type, client_order_id: myId }));
if (o.status === "cancelled") return null; // no report after all: refunded
return o.delivery?.link; // the report
}
Questions or problems? Email: info@diamond-cart.com or use live support on the site.