Cancel an eSIM
const url = 'https://api.roamex.com/v1/esims/cancel';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"esimId":"00000000-0000-4000-8000-0000000000c1"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.roamex.com/v1/esims/cancel \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "esimId": "00000000-0000-4000-8000-0000000000c1" }'Cancels an eSIM that has not been used and credits your balance; refund states the amount. For a provisioned eSIM the status is checked live before anything is cancelled. A cancelled eSIM cannot be restored.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
An eSIM id from /esims/purchase or /esims/list.
Example
{ "esimId": "00000000-0000-4000-8000-0000000000c1"}Responses
Section titled “Responses”The eSIM is cancelled and your balance is credited.
object
The amount credited to your balance.
object
Euro cents.
object
Euro cents.
Example
{ "success": true, "cancelled": true, "refund": { "amount": 450, "currency": "EUR", "formatted": "€4.50" }, "newBalance": { "amount": 24550, "currency": "EUR", "formatted": "€245.50" }, "message": "eSIM cancelled. €4.50 refunded to your balance."}Headers
Section titled “Headers”Calls allowed per minute for this endpoint group.
Calls left in the current minute.
When the current window ends, in Unix seconds.
INVALID_JSON: the body is missing or not a JSON object.MISSING_ESIM_ID:esimIdis missing.ALREADY_CANCELLED: the eSIM is already cancelled.CANNOT_CANCEL: the eSIM is spent or no longer exists on the network.CANNOT_CANCEL_ACTIVE: the eSIM has used data or has connected to a network.NO_ORDER_REFERENCE: the eSIM has no order reference to cancel with.CUSTOMER_TOPUP_EXISTS: the traveller paid for top-ups on this eSIM that were delivered.NOTHING_TO_CREDIT: what this eSIM cost your balance was already returned.STOREFRONT_ESIM: this eSIM was not charged to your balance.CANCEL_FAILED: the cancel was refused. Nothing changed.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false}AUTH_ERROR: the key is missing, malformed, unknown or revoked. The message says which, for example Missing Authorization header, Invalid Authorization header format. Use: Bearer <api_key>, Invalid API key format or Invalid API key.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false, "error": { "code": "AUTH_ERROR", "message": "Invalid API key" }}AUTH_ERROR: the account is suspended (Your account is suspended. Please contact support.) or rejected (Account is not approved for API access).
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false}ESIM_NOT_FOUND: no eSIM with this id belongs to your account.NOT_FOUND: the API is switched off on the platform.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false}SHOP_ORDER_IN_FLIGHT: the shop order this eSIM belongs to is still open. Nothing was cancelled.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false}PAYLOAD_TOO_LARGE: the Content-Length header is over 100 KB.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false}RATE_LIMITED: the account’s per-minute budget for this endpoint group is used up, or too many refused keys came from this IP address. Wait the Retry-After seconds.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false, "error": { "code": "RATE_LIMITED", "message": "Rate limit exceeded. Please wait 42 seconds before retrying." }}Headers
Section titled “Headers”Calls allowed per minute for this endpoint group.
Calls left in the current minute.
When the current window ends, in Unix seconds.
Seconds to wait before retrying.
REFUND_FAILED: the eSIM was cancelled but the credit to your balance failed. Roamex has been notified and reconciles it.INTERNAL_ERROR, orAUTH_ERRORwith status 500: see the shared errors.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false}Nothing was credited.
STATUS_UNVERIFIED: the eSIM’s current status could not be verified. Retry with backoff.TOPUP_CHECK_UNAVAILABLE: the traveller’s top-ups could not be checked. Retry with backoff.CANCEL_CHECK_UNAVAILABLE: what this eSIM cost your balance could not be read. Retry with backoff.CANCEL_FAILED: the cancel could not be completed and nothing changed. Retry with backoff.CANCEL_OUTCOME_UNKNOWN: it is not known whether the eSIM was cancelled. Roamex checks it by hand. Do not retry.
object
object
Machine-readable. Branch on this.
A sentence for people. It can change.
Example
{ "success": false}
