Renew eSIM
Renew a phone-number line by one more period (usually 30 days), paid from your wallet.
Only packages with can_extend: true in Get All Packages can be renewed. Lines are sold for one period at a time; renew them here, or switch on Auto-renew to have it done every month.
Endpoints
GET /api/v1/business/esims/renew?iccid=<iccid> (price and eligibility — nothing is charged)
POST /api/v1/business/esims/renew (renew)
AI prompt — Renew eSIM
Paste into ChatGPT, Claude, Cursor, Copilot or any coding agent to generate this part of your integration. Built-in recommendation: Phone-number lines: GET the price, POST with an Idempotency-Key, treat 202 "processing" as paid and never renew twice.
Show prompt text (50 lines)
# eSIMfly Business API — Renew eSIM (GET/POST /esims/renew) — prompt for AI coding assistants
TASK: let our customers (or our support team) renew a phone-number line by one more period (usually 30 days),
paid from our eSIMfly wallet. Only packages with can_extend = true are renewable. Lines are sold one period at
a time; the `recurring` order flag is ignored.
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`.
- Rate limits are per API key, shown in the business dashboard (typically 100/minute, 1,000/hour, 10,000/day) -> RATE_LIMIT_EXCEEDED.
- Read `currency` from responses (the account wallet currency). Never hard-code it. IQD amounts are integers.
- Full multi-endpoint prompt: https://docs.esimfly.net/llm/esimfly-api-full-prompt.txt
ENDPOINTS
GET https://esimfly.net/api/v1/business/esims/renew?iccid=<iccid> (or ?esimId=) — nothing is charged
-> { success: true, data: { iccid, esimId, renewable, reason|null, price, currency, days, expiresAt, pendingRenewal } }
POST https://esimfly.net/api/v1/business/esims/renew
Headers: + Idempotency-Key: <our renewal id, <= 100 chars> (or body field idempotencyKey)
Body: { "iccid": "8944110068223459012" } // or { "esimId": 33796 }
RESPONSES
200 { success: true, message: "eSIM renewed", data: { status: "completed", iccid, esimId, renewalReference,
orderId, newExpiryDate, amount, currency, duplicate } }
202 same shape with status: "processing", newExpiryDate: null — PAID; eSIMfly support completes the extension
(or refunds the wallet). Do NOT renew again; re-read the eSIM later for the new expiry.
duplicate: true = same Idempotency-Key already processed; nothing charged again.
ERRORS: 400 MISSING_IDENTIFIER; 400 NOT_RENEWABLE (show message; renewal allowed until 7 days after expiry);
400 INSUFFICIENT_BALANCE { currentBalance, requiredBalance, currency }; 403 ACCOUNT_SUSPENDED;
404 ESIM_NOT_FOUND (not ours / not a renewable line); 409 RENEWAL_IN_PROGRESS; 409 RENEWAL_PENDING;
500/502 RENEW_FAILED (nothing charged or refunded).
INTEGRATION PATTERN
1. Show "Renew" only for lines whose package has can_extend = true (from your synced packages table).
2. On click: GET for the price, show it, then POST with an Idempotency-Key derived from your own renewal row
(create the row first, status pending). Persist renewalReference, amount, currency, newExpiryDate.
3. 202 "processing": mark the renewal paid/processing and the line "renewal in progress"; refresh the eSIM
(GET /esims?search=<iccid>) later. Never fire a second renewal for the same line meanwhile.
4. On timeout retry ONCE with the SAME Idempotency-Key and a new RT-RequestID.
5. For lines that should never lapse, use POST /esims/auto-renew instead of renewing by hand.
DELIVERABLE: renewQuote(iccid) + renewLine(iccid, idempotencyKey) in the shared client, the renew action
with price confirmation, and local renewal bookkeeping.
Authentication
This endpoint requires HMAC authentication. See Authentication for details.
Check price and eligibility (GET)
Query parameters: iccid, or esimId instead.
{
"success": true,
"data": {
"iccid": "8944110068223459012",
"esimId": 33796,
"renewable": true,
"reason": null,
"price": 8.34,
"currency": "USD",
"days": 30,
"expiresAt": "2026-12-25T10:12:00.000Z",
"pendingRenewal": false
}
}
| Field | Type | Description |
|---|---|---|
| renewable | Boolean | Whether a renewal can be bought now |
| reason | String/null | Why not, when renewable is false |
| price | Number | Price of one renewal in your wallet currency |
| currency | String | Your wallet currency |
| days | Integer | Days one renewal adds |
| expiresAt | String/null | Current expiry (ISO 8601) |
| pendingRenewal | Boolean | A paid renewal of this line is still being completed — do not renew again |
A line can be renewed until 7 days after it expired; after that, buy a new line.
Renew (POST)
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
| RT-AccessCode, RT-RequestID, RT-Timestamp, RT-Signature | String | Yes | See Authentication |
| Content-Type | String | Yes | Must be "application/json" |
| Idempotency-Key | String | Recommended | Your own id for this renewal (max 100 characters). A retry with the same key returns the first renewal instead of charging again. You may send it as idempotencyKey in the body instead |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| iccid | String | Yes* | The ICCID of the line |
| esimId | Integer | Yes* | The eSIM id (used if iccid is not provided) |
* Provide either iccid or esimId.
{ "iccid": "8944110068223459012" }
Success Response (200 OK) — renewed
{
"success": true,
"message": "eSIM renewed",
"data": {
"status": "completed",
"iccid": "8944110068223459012",
"esimId": 33796,
"renewalReference": "business_renewal_1795612345678_ab1cd",
"orderId": 51234,
"newExpiryDate": "2027-01-24T10:12:00.000Z",
"amount": 8.34,
"currency": "USD",
"duplicate": false
}
}
Accepted (202) — paid, being completed
Rarely the network does not confirm the extension straight away. The renewal is then paid and held: our team completes the extension (or refunds your wallet), and the new expiry appears on the eSIM once it is done. Do not renew again — a new attempt returns RENEWAL_PENDING until it is settled.
{
"success": true,
"message": "Payment received. The line is being extended by our team - the new expiry appears on the eSIM once it is done.",
"data": { "status": "processing", "iccid": "8944110068223459012", "esimId": 33796, "renewalReference": "business_renewal_1795612345678_ab1cd", "orderId": 51234, "newExpiryDate": null, "amount": 8.34, "currency": "USD", "duplicate": false }
}
duplicate: true means the same Idempotency-Key was already processed; the first renewal is returned and nothing is charged again.
Error Responses
| HTTP | code | When |
|---|---|---|
| 400 | MISSING_IDENTIFIER | Neither iccid nor esimId |
| 400 | NOT_RENEWABLE | The line cannot be renewed (see message, e.g. expired more than 7 days ago) |
| 400 | INSUFFICIENT_BALANCE | Wallet too low; includes currentBalance, requiredBalance, currency |
| 403 | ACCOUNT_SUSPENDED | The account is suspended |
| 404 | ESIM_NOT_FOUND | Not your eSIM, or not a renewable line |
| 409 | RENEWAL_IN_PROGRESS | Another renewal of this line is running right now |
| 409 | RENEWAL_PENDING | A paid renewal of this line is still being completed |
| 500/502 | RENEW_FAILED | Nothing was charged, or the charge was refunded |
{ "success": false, "message": "Insufficient USD balance. Required: 8.34, Available: 2.10", "code": "INSUFFICIENT_BALANCE", "currentBalance": 2.1, "requiredBalance": 8.34, "currency": "USD" }
Notes
- Call GET first to show the price; POST charges the current price.
- Always send an
Idempotency-Keyso a network retry can never renew twice. - To renew every month without calling this endpoint, use Auto-renew.