The one-line change
Keep the base URL and key in configuration, never in code. Then the migration is a config edit per environment.
# handler_api reference: https://otpwatch.com/migrate-base-url
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
# before
SMS_API_BASE_URL=https://old-provider.example/stubs/handler_api.php
SMS_API_KEY=old-key
# after
SMS_API_BASE_URL=https://sim-aggregator.org/stubs/handler_api.php
SMS_API_KEY=key-from-the-dashboardIf the URL is hardcoded today, move it to configuration first and ship that change alone. A diff that changes a constant and behaviour at the same time is hard to roll back.
What works without changes
The core loop and the reference calls use the same action names and the same reply strings:
getBalance,getPrices,getCountries,getServicesListgetNumberandgetNumberV2(withdurationandmaxPrice)getStatuswithSTATUS_WAIT_CODE,STATUS_OK:<code>,STATUS_WAIT_RETRY:<code>,STATUS_CANCELsetStatuswith 3 (another code), 6 (finish) and 8 (cancel)getCurrentActivationsList
Anything outside those nine actions answers BAD_ACTION. Grep your code for every action= value before the switch, and for every status= value you send: only 3, 6 and 8 are accepted. The compat check does that grep in your browser and lists each call with its line number.
Seven assumptions to re-check
1. Country and service ids
Ids that match on one provider can mean a different country on another. Do not carry the old mapping over blindly. Pull both reference lists and compare them with what your code hardcodes.
// handler_api reference: https://otpwatch.com/migrate-base-url
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
// node check-ids.mjs — prints every hardcoded id the new endpoint does not know
const API = process.env.SMS_API_BASE_URL ?? "https://sim-aggregator.org/stubs/handler_api.php";
const KEY = process.env.SMS_API_KEY;
const mine = { countries: { GB: "16", DE: "43", US: "187" }, services: ["tg", "wa", "go"] }; // your config
const get = async (action) => (await fetch(`${API}?action=${action}&api_key=${KEY}`)).text();
const countries = JSON.parse(await get("getCountries"));
const services = JSON.parse(await get("getServicesList")).services.map((s) => s.code);
for (const [iso, id] of Object.entries(mine.countries)) {
const row = countries[id];
if (!row) console.log(`country id ${id} (${iso}): unknown`);
else if (row.eng !== iso) console.log(`country id ${id}: expected ${iso}, endpoint says ${row.eng}`);
}
for (const code of mine.services) if (!services.includes(code)) console.log(`service ${code}: unknown`);The check on row.eng works because getCountries currently returns the ISO code in its rus, eng and chn fields.
2. The code-wait timer
A one-off activation stays open for a window the catalog sets per service; currently one hour for every service. A single global timeout is wrong in both directions: give up early and you cancel an order whose SMS was about to land; wait past the window and you keep polling an order that has already closed and refunded itself. Store a timeout per service.
3. Cancels refused as too early
setStatus with 8 can answer EARLY_CANCEL_DENIED: too early to cancel, repeat the request later. The docs do not say how long. Bots that cancel immediately on any error need a delayed retry with a cap on attempts. The cancel and refund page has a helper.
4. Request budget
The limit is 600 requests per minute per key, and every action counts. Thirty open orders polled once a second is 1,800 requests a minute, three times the limit. Polled every five seconds they cost 360 and leave room for everything else.
# handler_api reference: https://otpwatch.com/migrate-base-url
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
open orders × (60 / poll interval in seconds) + other calls ≤ 600When the key goes over, the reply is REQUEST_LIMIT. Back off and retry; do not read it as "no code".
5. Refund logic
If no SMS arrives within the window, the order closes and the money returns to the balance without any call. A cancel before the code also returns it. Once an SMS has been received the order counts as delivered and is not refunded, even if the target service then rejects the sign-up. Refunds land on the internal balance only. If your bot keeps its own ledger per order, check it against these rules.
6. Currency
Prices, maxPrice and the balance are US dollars. Convert any thresholds in your config that were set in another currency, or your price ceiling will be off by the exchange rate.
7. Extra parameters
Remove any query parameters your old setup appended that are not in the reference. Unknown values can be rejected instead of ignored, and a rejected order looks like an outage.
Staging run: five calls, two activations
Issue a separate key in the dashboard and name it staging. The key string is shown once, so put it in your secrets store right away. Then:
getBalance
Proves the key works and shows the balance. You need enough for two activations of your most common pair.
getPrices
For each service and country you sell or test, check a price comes back. Missing pairs answer BAD_COUNTRY or BAD_SERVICE.
getNumber
Order one number. Confirm your code stores the activation id and the number, and that the + is added where a form expects it.
getStatus at production rate
Poll at the interval you will use in production and watch that the run stays under the request budget.
A second order, cancelled
Order again and send setStatus with 8; while it answers EARLY_CANCEL_DENIED, repeat it with a pause. Expect ACCESS_CANCEL and the amount back on the balance.
Cutting over
- Drain the old side first: open orders there stay there. Finish or cancel them before the URL flips.
- Give every environment its own named key (
prod-bot,staging,local). The limit is per key, so a test run cannot starve production. - Each key shows its last-used date in the dashboard. After the switch, staging should go quiet; revoke it when it does.