Why eSIM Profiles Need Strong Lifecycle State Management
An eSIM profile is not a file you hand to a customer. It is a stateful object that moves through a series of conditions, some of them controlled by your backend and some by a device and a remote server you do not own. If you model it as a single "active" flag, you will eventually sell the same profile twice, lose track of a download that half finished, or refuse a legitimate retry. This post argues for explicit lifecycle states and shows how to design them.
Two lifecycles, not one
The first thing to separate is the state of the profile on the SM-DP+ from the state of the profile on the device. They are related, but they are not the same thing.
The SM-DP+ side follows the specification's profile states, in simplified form:
- Available: the profile exists and is not yet allocated to an order.
- Allocated: it has been reserved for a particular order.
- Linked: it has been tied to a particular EID.
- Confirmed: the order has been confirmed and the profile is ready for download.
- Released: it can now be downloaded.
- Downloaded: the download has been performed.
- Installed: the device reported a successful installation.
- Error, or unavailable: the profile can no longer be used.
On the device, an installed profile is either enabled or disabled, and it can later be deleted. A deleted profile is gone from the chip, and the SM-DP+ may be told about it through a notification.
Your own system adds a third layer: the commercial state. That covers the customer order, payment, delivery of the code, and refunds. Keep all three apart in your model.
Why a flag is not enough
Consider what can happen to one order:
- The customer pays, and the profile is reserved.
- The customer scans the code, and the download starts.
- The phone loses connectivity partway through. The profile on the SM-DP+ might be downloaded, but the install notification never comes.
- The customer asks for support, and an agent has to decide whether to issue a new profile.
With a boolean, you cannot answer whether to reissue. With explicit states and timestamps you can: the profile is in "downloaded, no install confirmation", and policy says to wait a defined time, query the SM-DP+, and then either mark it installed or release it for a retry.
Designing the state machine
A few rules keep this manageable:
- Enumerate states and allowed transitions explicitly. Anything not in the table is rejected.
- Make transitions the only way to change state. No code path should update the status column directly.
- Record every transition with a timestamp, the actor or event that caused it, and the previous state.
- Treat events as unreliable. Notifications can arrive late, twice, or out of order, so a transition must be safe to apply again.
A minimal version in Python:
from enum import Enum
class ProfileState(str, Enum):
AVAILABLE = "available"
RESERVED = "reserved"
DELIVERED = "delivered" # activation code issued to the customer
DOWNLOADED = "downloaded" # SM-DP+ says a download happened
INSTALLED = "installed" # install notification received
ENABLED = "enabled"
DISABLED = "disabled"
DELETED = "deleted"
FAILED = "failed"
ALLOWED = {
ProfileState.AVAILABLE: {ProfileState.RESERVED},
ProfileState.RESERVED: {ProfileState.DELIVERED, ProfileState.AVAILABLE},
ProfileState.DELIVERED: {ProfileState.DOWNLOADED, ProfileState.FAILED, ProfileState.AVAILABLE},
ProfileState.DOWNLOADED: {ProfileState.INSTALLED, ProfileState.FAILED},
ProfileState.INSTALLED: {ProfileState.ENABLED, ProfileState.DISABLED, ProfileState.DELETED},
ProfileState.ENABLED: {ProfileState.DISABLED, ProfileState.DELETED},
ProfileState.DISABLED: {ProfileState.ENABLED, ProfileState.DELETED},
ProfileState.FAILED: {ProfileState.AVAILABLE},
ProfileState.DELETED: set(),
}
def transition(current: ProfileState, target: ProfileState) -> ProfileState:
if current == target:
return current # idempotent: replayed event
if target not in ALLOWED[current]:
raise ValueError(f"illegal transition {current} -> {target}")
return target
The line that returns early when the state is unchanged is what makes a duplicate notification harmless.
Persistence matters
The table above is only half the design. The transition has to be applied atomically with a check of the current state, otherwise two workers can both read "reserved" and both move on. In a relational database, that usually means a conditional update:
UPDATE profiles
SET state = 'delivered', updated_at = now()
WHERE iccid = :iccid
AND state = 'reserved';
-- check the affected row count: 0 means someone else moved it first
An append-only transition log in the same transaction gives you an audit trail for support questions.
Handling the unknowns
Some states cannot be decided locally. When a download seems stuck, the answer is on the SM-DP+. Build a reconciliation job that periodically asks it for the status of profiles that have sat in an intermediate state too long, then applies the result through the same transition function. Do not patch rows by hand.
What to expose
Support tools and customer-facing pages should show the real state in plain language, such as "code sent", "download started" or "installed", and not a vague "active". It cuts support effort and prevents wrong refunds.
Takeaways
- Separate SM-DP+ state, device state and commercial state.
- Make transitions explicit, atomic, idempotent and logged.
- Add reconciliation for the states you cannot confirm from your own database.
About the author: I work on content and web development at eSIMCircle, a travel eSIM provider. This series comes from the engineering side of that work.
About the author
- eSIMCircle provides affordable global eSIM plans with reliable data in 200+ countries.
Comments
Join the discussionNo comments yet. Be the first to comment.
