Auto-renew
Keep phone-number lines active by renewing them every month from your wallet. Off by default — switch it on per line, or as the default for every line on your account.
How it works
- From 2 days before a line expires, it is renewed by one period through the same flow as Renew eSIM (wallet charged first).
- If your wallet is short, your account email gets one warning per period (from 3 days before expiry), and renewal is retried until the expiry date. After that the line runs out. Auto-renew stays on, so it picks up again once you top up.
- Only lines with
can_extend: truecan auto-renew.
You can also switch it on when ordering: POST /esims/order with "autoRenew": true (see Create Order).
Endpoints
GET /api/v1/business/esims/auto-renew?iccid=<iccid> (one line)
GET /api/v1/business/esims/auto-renew (your account default)
POST /api/v1/business/esims/auto-renew (change a line or the account default)
AI prompt — Auto-renew
Paste into ChatGPT, Claude, Cursor, Copilot or any coding agent to generate this part of your integration. Built-in recommendation: Monthly renewals run on eSIMfly; you switch it per line or account-wide and keep the wallet funded.
Show prompt text (42 lines)
# eSIMfly Business API — Auto-renew (GET/POST /esims/auto-renew) — prompt for AI coding assistants
TASK: let our customers keep phone-number lines active by renewing them every month from our eSIMfly wallet,
per line or as our account default. eSIMfly runs the renewals; we only switch it on/off and keep our wallet funded.
COMMON RULES (apply to every eSIMfly request)
- Base URL: https://esimfly.net/api/v1/business
- Headers on every call: RT-AccessCode (esf_...), RT-RequestID (fresh UUID v4 per request; reuse -> 400 DUPLICATE_REQUEST),
RT-Timestamp (ms since epoch; >5 min old -> 401 INVALID_TIMESTAMP),
RT-Signature = UPPERCASE hex HMAC-SHA256(secretKey, timestamp + requestId + accessCode + rawBody).
rawBody = "" for GET; for POST/PUT sign the exact body string you send, with Content-Type: application/json.
- Keep access code + secret key server-side in env vars. Never ship them to a browser or mobile app.
- Responses: { success: true, ... } or { success: false, message, code }. Branch on `success` and `code`.
- Full multi-endpoint prompt: https://docs.esimfly.net/llm/esimfly-api-full-prompt.txt
BEHAVIOUR
- Off by default. Only lines with can_extend = true.
- From 2 days before expiry the line is renewed by one period (same flow as POST /esims/renew: wallet first).
- Wallet short: our account email gets one warning per period (from 3 days before expiry); renewal is retried
until expiry, then the line runs out. Auto-renew stays on.
- Also settable at purchase: POST /esims/order { packageCode, autoRenew: true } -> response autoRenew: true|false.
ENDPOINTS
GET /esims/auto-renew?iccid=<iccid> (or ?esimId=)
-> { success: true, data: { iccid, esimId, autoRenew, lineSetting: true|false|null, accountDefault,
expiresAt, nextRenewalFrom, lastResult: "renewed"|"pending"|"insufficient_balance"|"not_renewable"|"error"|null,
lastAttemptAt } }
GET /esims/auto-renew -> { success: true, data: { accountDefault } }
POST /esims/auto-renew { "iccid": "...", "enabled": true|false|null } // null = follow the account default
POST /esims/auto-renew { "accountDefault": true|false } // every line without its own setting
ERRORS: 400 INVALID_REQUEST; 400 MISSING_IDENTIFIER; 403 ACCOUNT_SUSPENDED; 404 ESIM_NOT_FOUND (not ours / not renewable).
INTEGRATION PATTERN
1. Show an "Auto-renew monthly" switch on phone-number lines; store the line setting locally too.
2. Keep the wallet funded: watch GET /balance in your hourly low-balance job, especially before nextRenewalFrom dates.
3. Read lastResult when the customer opens the line; "insufficient_balance" = top up the wallet.
4. Renewals happen on eSIMfly's side - do not also call POST /esims/renew for the same line.
DELIVERABLE: getAutoRenew / setAutoRenew(iccid, enabled) / setAccountAutoRenewDefault in the shared client,
the UI switch, and the low-balance alert tie-in.
Authentication
This endpoint requires HMAC authentication. See Authentication for details.
Request Body (POST)
One line — enabled: true, false, or null to follow the account default:
{ "iccid": "8944110068223459012", "enabled": true }
Account default — every line that has no setting of its own:
{ "accountDefault": true }
Response
Line:
{
"success": true,
"data": {
"iccid": "8944110068223459012",
"esimId": 33796,
"autoRenew": true,
"lineSetting": true,
"accountDefault": false,
"expiresAt": "2026-12-25T10:12:00.000Z",
"nextRenewalFrom": "2026-12-23T10:12:00.000Z",
"lastResult": null,
"lastAttemptAt": null
}
}
Account default (GET without identifier, or POST accountDefault):
{ "success": true, "data": { "accountDefault": true } }
| Field | Type | Description |
|---|---|---|
| autoRenew | Boolean | Whether this line will be renewed |
| lineSetting | Boolean/null | The line's own setting; null = follows accountDefault |
| accountDefault | Boolean | Your account default |
| expiresAt | String/null | Current expiry |
| nextRenewalFrom | String/null | When renewal attempts start (null when off) |
| lastResult | String/null | Last attempt: renewed, pending, insufficient_balance, not_renewable or error |
| lastAttemptAt | String/null | When it was |
Error Responses
| HTTP | code | When |
|---|---|---|
| 400 | INVALID_REQUEST | Neither enabled nor accountDefault sent |
| 400 | MISSING_IDENTIFIER | enabled sent without iccid / esimId |
| 403 | ACCOUNT_SUSPENDED | The account is suspended |
| 404 | ESIM_NOT_FOUND | Not your eSIM, or the line cannot be renewed |