# SIMs

> eSIM activation codes and physical SIMs.

## Get the eSIM payload

```http
GET /v1/gather/lines/esim/id?id={line_id}
```

Available once the line is `active` and until the eSIM is installed. The `lpa_code` is the
standard activation code, so you can render it as a QR code if you install by scanning.

```json
{
  "lpa_code": "LPA:1$smdp.example.net$K2-4Z7Q-19XVTP",
  "smdp_address": "smdp.example.net",
  "matching_id": "K2-4Z7Q-19XVTP",
  "status": "ready"
}
```

> **CAUTION** Treat the `lpa_code` like a password. Anyone who has it can install the line.

## Know when it is installed

`esim.status` is `ready` until a device downloads the eSIM, then `installed`. We check the
network for the download, so the change shows up within about 10 minutes of the install (less
often for an eSIM that has waited more than 3 days). At the same moment the line gets its
`iccid` and we send an `esim.installed` webhook. An eSIM line's `iccid` stays empty until then.
After a reissue the new eSIM is `ready` again and its install is found the same way.

In sandbox an eSIM reads as installed about a minute after its line goes `active`.

## Reissue

```http
POST /v1/gather/lines/esim/reissue?id={line_id}
```

Lost a device or wiped the eSIM? A reissue gives the same number a new eSIM and voids the
old one.

Send an `Idempotency-Key` header. On a live line the network takes about a minute, so the call
returns `202` with `esim.status` `reissuing` and no code yet. When it is done you get
`esim.reissued` and [`esim/id`](#get-the-esim-payload) returns the new code. If it fails you get
`esim.reissue_failed` and the line keeps its current eSIM. Asking again while a reissue is under way
returns `202` without starting another. In sandbox the call returns `200` with the new eSIM at once.

Moving the line to a phone that is outside the US? Send `{"roaming": "activation"}` as the body.
Once the line has its new eSIM it gets the same short roaming pass as a line
[ordered for activation abroad](/docs/numbers#activating-abroad), so the new phone can install
the eSIM and register the number. The pass is $1 and needs roaming turned on for your account
(otherwise `403 roaming_unavailable`).

```json
{ "roaming": "activation" }
```

A reissue without roaming is free. `503 reissue_unavailable` means the network cannot do it right now, or the line
has another change in progress (a number or SIM change, roaming). Retry later with the same
`Idempotency-Key`.

To give a line a new number without reinstalling its eSIM, use
[`number/change`](/docs/numbers#change-a-lines-number) instead.

## Open a short roaming window

```http
POST /v1/gather/lines/number/roaming-window?id={line_id}
```

A phone abroad that already has the line's eSIM but shows no network? Turning roaming on for a
few minutes often lets it latch on, with no new eSIM. This adds the same $1 roaming pass as a
[reissue with roaming](#reissue), then turns roaming off again on its own.

Send an `Idempotency-Key` header. The body is optional: `minutes` is how long roaming stays on,
from 5 to 120 (30 if you leave it out). Anything else is `422 invalid_request`.

```json
{ "minutes": 30 }
```

The call returns `202` with the line, its `roaming` showing `mode` `window`, `state` `requested`
and your `minutes`. Once the pass is live you get `line.roaming_on` with `off_by`, the time
roaming goes off, then `line.roaming_off` once it has. If the pass cannot be added (a declined
card included) you get `line.roaming_failed` and the line carries on as before. Asking again
while a window is open returns the line as it is, with no second pass.

Each window buys a 1-day pass, so a line gets one paid window per 24 hours. Asking again within 24
hours of the last pass returns `409 roaming_window_cooldown` with `retry_after`, the time you can
open the next one.

It needs roaming turned on for your account (otherwise `403 roaming_unavailable`) and an active
line on an eSIM: a suspended line, a line being released or a physical SIM is
`422 invalid_request`. `409 line_busy` means the line has another change in progress (an eSIM
reissue, a number or SIM change, a suspend or resume, roaming); retry once it finishes.

## Physical SIMs

We ship you physical SIM cards in bulk, for example a few months of supply at a time. A card
does nothing until you order a line with its `iccid`, so keep them in stock and activate them
as you need. Order more from your account contact; delivery takes a few weeks, so plan ahead.
