Every eSIM installation in the world reduces to one short string and one server conversation. The eSIM LPA on the device is what reads that string, and it is where most support tickets end up. The string is the activation code, the server is an SM-DP+, and the component on the phone that reads both is the LPA. Getting any of the three wrong produces the same user-visible result: a QR code that “does not work”.

This page is about the string. What is actually inside it, how to parse it without corrupting it, why it only works once, and where the boundary sits between what your app can do and what the operating system will not let it do.

What does an eSIM LPA code actually contain?

An activation code is a URI, not a random token. The GSMA defines it as part of the consumer eSIM architecture described in its eSIM specification material , and the format is stable:

LPA:1$smdp.example.com$04386-AGYFT-A74Y8-3F815

Three fields, separated by $:

FieldExampleWhat it isWho controls it
LPA:LPA:Scheme. Tells the phone an LPA handles itFixed
Version1Activation code versionFixed today
SM-DP+ addresssmdp.example.comThe server that will issue the profileProvider
Matching ID04386-AGYFT-A74Y8-3F815Lookup key for one prepared profileProvider

Some codes carry a fourth field, an OID or confirmation code used by specific carrier flows. Treat anything after the matching ID as opaque: copy it verbatim or drop the whole code, never reconstruct it.

The QR code on a delivery email is nothing more than this string encoded. That matters, because it means every failure mode of the string is also a failure mode of the QR, and the QR gets blamed instead.

How do you parse one without breaking it?

Parse conservatively. You are not repairing a code, you are validating one and passing it through unchanged.

function parseActivationCode(raw) {
  const s = String(raw || '').trim();
  const m = /^LPA:(\d+)\$([^\s$]+)\$([^\s$]+)(?:\$([^\s$]+))?$/i.exec(s);
  if (!m) return { ok: false, reason: 'format' };
  const [, version, smdp, matchingId, extra] = m;
  if (version !== '1') return { ok: false, reason: 'version' };
  if (!/^[a-z0-9.-]+\.[a-z]{2,}$/i.test(smdp)) return { ok: false, reason: 'smdp' };
  if (matchingId.length < 8) return { ok: false, reason: 'matching-id' };
  return { ok: true, smdp, matchingId, extra: extra || null };
}

Four rules that prevent most of the damage:

  • Do not uppercase or lowercase anything. Matching IDs are case sensitive on some platforms. Normalising turns a working code into a failed one.
  • Do not trim internal whitespace by splitting on spaces. A code pasted out of an HTML email can contain a line break in the middle. Strip newlines only at the ends, then validate the whole string.
  • Do not “fix” a code that fails validation. Reject it and regenerate through your provider’s API. Silent repair is how you ship a plausible string that installs nothing.
  • Store the raw string, not your parsed fields. You will need to redisplay it later, and reconstruction loses the fourth field.

Why does the same code fail on the second phone?

Because a profile is consumed by the first successful download, not by the first scan. Four distinct failures all look identical to the customer:

Already downloaded. The first install succeeded, on this phone or another one. The matching ID is now bound. The fix is a new profile from your supplier, not a retry.

Matching ID mismatch. The code was regenerated on the supplier side and your delivery email still holds the old one. This happens constantly when orders are edited after issue.

Expired reservation. Most suppliers hold a prepared profile for a fixed window. A code sent weeks before departure can be dead on arrival.

Device or region restriction. The plan covers Japan, the phone was bought in a market where eSIM is disabled, or the handset is carrier-locked. The code is fine and the device is not.

The diagnostic order matters: check download status first, then code freshness, then device compatibility. Most support scripts do it in the opposite order and burn twenty minutes on reinstalling a profile that was already consumed.

Where does SM-DP+ stop and SM-DS begin?

Two servers with different jobs, and mixing them up produces a confusing error.

SM-DP+ prepares and delivers a profile. It is the address embedded in the activation code. If the code is a shopping voucher, the SM-DP+ is the shop.

SM-DS is a discovery server. A device can ask it whether any profile is waiting for it, which is how push provisioning works with no QR code at all. The user opens settings, the phone checks the discovery server, and a profile appears.

SM-DP+SM-DS
JobIssue a specific profileAnnounce profiles to a device
Address in the codeYesNo
Needed for QR installYesNo
Needed for push installYes, behind the scenesYes
Failure looks like“code invalid”“nothing appeared”

If a customer says nothing appeared after following a push flow, you are debugging SM-DS and the EID, not the activation code. Sending them the QR instead is a workaround, not a fix.

Which parts of this can an app not touch?

Most of the interesting ones. The LPA lives in the device’s secure element management stack, and third-party apps sit outside it.

On iOS, apps cannot enumerate profiles, trigger installation, or read the EID without a carrier entitlement. The system Settings flow owns installation, and the standard setup steps are what your customer will actually follow.

On Android, the eUICC APIs exist and are documented, but ordinary apps do not get carrier privileges. You can usually deep-link into the system flow and you cannot silently install a profile.

What this means for your product: your job is to deliver a valid code, explain where to paste or scan it, and detect whether it worked. Treating installation as something your app performs leads to a UI that promises more than the platform allows.

Should your error message name the cause?

Specific beats apologetic. Replace “something went wrong” with the cause, because the cause determines the customer’s next action.

SituationBad messageMessage that helps
Code already usedInvalid eSIMThis eSIM was already installed. We are issuing a replacement.
Reservation expiredTry againThis code expired before use. Here is a fresh one.
Device unsupportedContact supportThis handset does not support eSIM. Here is the refund link.
Carrier lockedError 4001Your phone is locked to a carrier. That is a call to your carrier.
Wrong network selectedNo connectionData is on, but the eSIM line is not selected. Turn on this line.

The last row is the one that costs the most support time in the whole category, and it has nothing to do with the activation code. A profile can be installed, activated, and still not carry traffic because the phone is using the primary line for data.

When should you stop handling codes yourself?

When installation becomes the support queue. Three signals:

More than a fifth of tickets are installation issues. At that point the cheapest fix is a hosted installation page from your supplier, not better copy in your own app.

You are storing matching IDs you did not generate. If you cannot tell which order produced which code, reconciliation is already broken and no parser saves it.

Your provider changes format. A new field, a new version, a different separator. Every hand-rolled parser becomes a liability on that day, which is why the parser above rejects unknown versions instead of guessing.

If you are building the integration rather than fixing one, the API integration guide covers the six calls around this string, including the idempotency rules that stop one order becoming two profiles. And if you are still choosing between building and buying, the wholesale overview puts the engineering cost next to the dashboard option.