Replace API
Add a Replace button to your website. Your customer enters the email of an account, and gets a working replacement account back, the same way the Telegram bot does it.
ملخص بالعربية
- تحتوي هذه الصفحة على كل ما يحتاجه المبرمج أو مساعد الذكاء الاصطناعي لإضافة زر Replace إلى موقعك.
- يحفظ المفتاح على الخادم الخاص بك، ولا يوضع في صفحات الموقع أو في كود JavaScript الذي يصل إلى متصفح الزائر.
- يعمل المفتاح من عنوان الخادم الذي أرسلته إلينا. وإذا انتقلت إلى خادم آخر، يرجى إرسال العنوان الجديد إلينا قبل الانتقال.
- في نهاية الصفحة كود جاهز بلغتي Node.js و PHP، ويمكنك تقديمه لمساعد الذكاء الاصطناعي مع طلب: «أضف هذه الصفحة إلى موقعي».
1. How it works
- The customer types an email on your page and presses Replace.
- Your page sends it to your own server (not to us).
- Your server calls
POST https://api.chat-techno.com/v1/replacewith your secret key. You get back a requestid. - Your server checks
GET https://api.chat-techno.com/v1/replace/{id}every 3 seconds until the status isdoneorfailed. Most replacements take 10 to 30 seconds; when it's busy the request waits in a queue. - Your page shows the new email and password to the customer.
- Please keep the key on your server (an environment variable, or a config file outside the public folder). It shouldn't be placed in HTML or browser JavaScript, where visitors could see it.
- The key works from the server address (IP) you registered with us. Requests from other addresses are declined automatically.
- Replacements apply to your own accounts. Other emails return
not_found. - If you think your key may have been exposed, just ask us for a new one; the old key stops working right away.
2. Authentication
Send your key in the Authorization header on every request:
Authorization: Bearer rk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Base URL: https://api.chat-techno.com. All responses are JSON. Every response has ok (true/false). Customer-facing responses also have message.en and message.ar, ready to show on your page as they are.
3. Endpoints
POST /v1/replace — start a replacement
POST https://api.chat-techno.com/v1/replace
Content-Type: application/json
{ "email": "customer@example.com", "ref": "optional-your-own-reference" }
Accepted (HTTP 202):
{ "ok": true, "id": "rq_8kD2...", "status": "queued", "position": 1, "eta_seconds": 15,
"message": { "en": "Your request is in the queue (position 1)", "ar": "طلبك في قائمة الانتظار (رقم 1)" } }
Pressing twice is safe: if the same email is already in the queue, you get the same id back.
Already replaced before (HTTP 200) — no new replacement is made, you get the current account:
{ "ok": true, "status": "already_replaced", "email": "customer@example.com",
"account": { "email": "current@...", "password": "...", "expires": "2026-12-21" }, "message": {...} }
GET /v1/replace/{id} — check the result
{ "ok": true, "id": "rq_8kD2...", "status": "running", "message": {...} }
{ "ok": true, "id": "rq_8kD2...", "status": "done",
"account": { "email": "new@...", "password": "...", "expires": "2026-12-21" },
"message": { "en": "Your new account is ready", "ar": "حسابك الجديد جاهز" } }
{ "ok": true, "id": "rq_8kD2...", "status": "failed", "error": "busy", "message": {...} }
Status is one of queued, running, done, failed. Stop checking when it's done or failed.
GET /v1/check?email=… — check an email without replacing
Optional. Tells you if an email can be replaced (status: ok, already_replaced, expired, not_found, not_replaceable). Doesn't count toward your daily limit.
GET /v1/me — your usage
{ "ok": true, "daily_limit": 200, "used_today": 37, "remaining_today": 163, "done_this_month": 512, "your_ip": "185.22.10.4" }
Tip: call this once after setup. your_ip shows the address we see for your server.
4. Errors
Messages for your customer (you can show message as it is):
| error / status | HTTP | Meaning |
|---|---|---|
invalid_email | 400 | Not a valid email |
not_found | 404 | The account wasn't found among your accounts |
expired | 409 | The subscription has expired, it can't be replaced |
not_replaceable | 409 | This account can't be replaced |
busy | 503 / in result | Temporarily busy, try again in a few minutes |
failed | in result | The replacement didn't succeed, the customer can try again |
daily_limit | 429 | Your daily limit is reached (message is neutral for the customer) |
Setup messages (for you; best not shown to customers):
| error | HTTP | Fix |
|---|---|---|
invalid_key | 401 | The key is incorrect or has been replaced by a newer one |
ip_not_allowed | 403 | The request came from an address that isn't registered. The message shows the address we received, so you can send it to us |
paused | 403 | The key is paused for now; please contact us |
rate_limited | 429 | More than 60 requests per minute; please space them out |
blocked | 429 | Several incorrect keys were sent from your address; access resumes automatically within an hour |
5. Ready-made code
Give this section to your developer or to an AI assistant with: "Add this Replace page to my website. The API key must stay on the server."
Node.js (no packages, Node 18+)
// server.js — run: API_URL=https://api.chat-techno.com API_KEY=rk_xxx node server.js
const http = require('http');
const API_URL = process.env.API_URL, API_KEY = process.env.API_KEY;
async function api(method, path, body) {
const r = await fetch(API_URL + path, {
method,
headers: { authorization: 'Bearer ' + API_KEY, 'content-type': 'application/json' },
body: body ? JSON.stringify(body) : undefined,
signal: AbortSignal.timeout(20000),
});
return r.json();
}
http.createServer(async (req, res) => {
const send = (o) => { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify(o)); };
try {
if (req.method === 'POST' && req.url === '/api/replace') {
let s = ''; for await (const c of req) s += c;
const { email } = JSON.parse(s || '{}');
return send(await api('POST', '/v1/replace', { email }));
}
const m = /^\/api\/status\/(rq_[A-Za-z0-9]{16})$/.exec(req.url);
if (req.method === 'GET' && m) return send(await api('GET', '/v1/replace/' + m[1]));
// ... serve your page here
} catch (e) { send({ ok: false, status: 'failed' }); }
}).listen(3000);
PHP
<?php // replace.php — put the key in an environment variable or a config file outside public_html
$API_URL = 'https://api.chat-techno.com';
$API_KEY = getenv('REPLACE_API_KEY');
function api($method, $path, $body = null) {
global $API_URL, $API_KEY;
$ch = curl_init($API_URL . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 20,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $API_KEY, 'Content-Type: application/json'],
]);
if ($body !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
$out = curl_exec($ch);
curl_close($ch);
return $out ?: json_encode(['ok' => false, 'status' => 'failed']);
}
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$in = json_decode(file_get_contents('php://input'), true);
echo api('POST', '/v1/replace', ['email' => $in['email'] ?? '']);
} elseif (isset($_GET['id']) && preg_match('/^rq_[A-Za-z0-9]{16}$/', $_GET['id'])) {
echo api('GET', '/v1/replace/' . $_GET['id']);
}
The page (browser side) — talks only to your server
<input id="email" type="email" placeholder="name@example.com">
<button id="go">Replace</button>
<div id="msg"></div>
<script>
const msg = (d) => document.getElementById('msg').textContent =
(d.message && d.message.en) || d.status; // use d.message.ar for Arabic
document.getElementById('go').onclick = async () => {
// PHP: '/replace.php' — Node: '/api/replace'
let d = await fetch('/api/replace', { method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ email: document.getElementById('email').value.trim() }) }).then(r => r.json());
msg(d);
while (d.id && (d.status === 'queued' || d.status === 'running')) {
await new Promise(r => setTimeout(r, 3000));
d = await fetch('/api/status/' + d.id).then(r => r.json()); // PHP: '/replace.php?id=' + d.id
msg(d);
}
if (d.account) document.getElementById('msg').textContent +=
'\n' + d.account.email + '\n' + d.account.password;
};
</script>
6. Checklist before going live
- Send us your server's IP address. We register it and send you the key.
- Put the key on your server (an environment variable), outside your pages.
- Call
GET /v1/mefrom your server: you should getok: true. - Replace one real account from your page and check the result.
- Optionally, view your page's source in the browser to confirm the key isn't included.