# Order an eSIM `POST /esims` Orders an eSIM and creates a new profile in a single operation. Returns the eSIM details including the activation code (LPA string) for device installation, along with the newly created profile reference for future API calls. To port an existing number onto the new eSIM, include the optional `portIn` block — an eSIM that waits for its port then stays pre-active (installable, but no service) until the port completes. See the Porting tag for the full workflow. Requires OAuth2 client-credentials authentication: send `Authorization: Bearer {token}`. ## Header parameters | Name | Type | Required | Description | | --- | --- | --- | --- | | `X-Idempotency-Key` | string | No | Optional idempotency key for requests that change state. If provided, duplicate requests with the same key within 48 hours will return the cached original response without duplicating side effects. **Behavior:** - Same key + same method, path and request body → returns cached response (prevents duplicate operations) - Same key + different method, path or request body → returns 422 error - Same key + in-flight request → returns 423 error - Keys are held for at least 48 hours; use a fresh key for every new request **Request Body Matching:** Request bodies are compared by their JSON content. Object key order, including in nested objects, and whitespace do not affect matching. This means: - `{"a":1,"b":2}` and `{"b":2,"a":1}` are treated as identical ✓ - Whitespace differences are ignored ✓ - The method and the full path, query included, must match as well; headers are not compared **Best Practices:** - Use UUIDs or client-generated unique strings - Store keys on your side to support retries - Don't reuse keys across different operations | ## Request body (application/json) | Field | Type | Required | Description | | --- | --- | --- | --- | | `externalProfileId` | string | No | Optional client-provided external ID to associate with this eSIM. Must be unique per client. | | `esimVariant` | string | No | The eSIM variant of the new eSIM (e.g. 'travel'), one of those `GET /catalog/esim-variants` lists. Name it on every order. | | `iccid` | string | No | The ICCID of the physical SIM delivered to the customer. Required when the ordered variant's `type` is `psim`, and only accepted for one; the SIM must belong to that variant. | | `portIn` | object | No | Optional port-in of an existing number onto the ordered eSIM. When present, the response contains a `portIn` object, and an eSIM that waits for its port stays pre-active until the port completes. | | `portIn.msisdn` | string | Yes | The number to port, in international format (E.164 without a leading `+`) — i.e. the country code, not the national `0` trunk prefix. Belgium: `324` + 8 digits, e.g. `32470123456`; Netherlands: `316` + 8 digits, e.g. `31612345678`. | | `portIn.details` | one of Donor SIM or account | Account or SMS code | Yes | Donor details of the number to port. Their shape is the one the selected eSIM's variant takes: proof by the donor SIM, or by the customer's account number with SMS confirmation without one. Unknown fields are rejected. | | `portIn.details.Donor SIM or account` | object | No | Donor details proven by the donor SIM or the account. A `prepaid` contract takes `donorIccid` and/or `donorSimNumber`; a `postpaid` contract any of `donorIccid`, `donorSimNumber` and `donorAccountNumber`; a `business` contract `donorAccountNumber` only. | | `portIn.details.Donor SIM or account.donorContractType` | string | Yes | Contract type of the number at the donor operator | | `portIn.details.Donor SIM or account.donorIccid` | string | No | ICCID of the donor SIM card, with a valid check digit. The preferred proof of a donor SIM: most donor operators accept it. | | `portIn.details.Donor SIM or account.donorSimNumber` | string | No | The number printed on the donor SIM card. Send it only when the donor SIM's ICCID is not available; `donorIccid` is accepted by more donor operators. | | `portIn.details.Donor SIM or account.donorAccountNumber` | string | No | Account/customer number at the donor operator | | `portIn.details.Account or SMS code` | object | No | Donor details proven by the account, or by SMS without one. A `postpaid` contract requires `donorAccountNumber` and `donorContractAction`; a `prepaid` one refuses `donorContractAction`. Without `donorAccountNumber`, the customer confirms the port-in with a code sent by SMS to the number being ported. The request stays `requested` until they do; an unconfirmed code expires after 24 hours and the port-in is rejected. | | `portIn.details.Account or SMS code.donorContractType` | string | Yes | Contract type of the number at the donor operator | | `portIn.details.Account or SMS code.donorAccountNumber` | string | No | Customer number at the donor operator | | `portIn.details.Account or SMS code.donorContractAction` | string | No | [Extensible enum](https://opensource.zalando.com/restful-api-guidelines/#112). What happens to the customer's contract at the donor operator. Required for a `postpaid` contract and refused for a `prepaid` one, which has no contract to end or keep. `terminate_at_expiry` ends it where it can end; the donor may refuse the port while a commitment period runs. `terminate_early` ends it even during a commitment period, which may cost the customer an early-termination fee at the donor. `keep_with_new_number` keeps the contract running at the donor under a new number. | | `communicationLanguageCode` | string | No | The language to message the customer in, as a two-character lowercase ISO 639-1 code, stored on the created profile. Set it whenever you know the customer's language, `en` included: a profile without one is messaged in your account's default language, which can change. Change it later with `PATCH /profiles/{profileReference}`. Independent of `numberRegistration.languageCode`, which is registry data. | | `packages` | array of OrderPackageRequest | No | Packages ordered with the eSIM. Each is created `pending` as an order of the package itself would be, so a plan that cannot be ordered on this eSIM fails the whole order, and is loaded once the eSIM has network service, for example after its installation, its activation request or a port-in. Its validity counts from its activation; until then it has no `expiresAt`. | | `packages.planReference` | string | Yes | Plan reference | | `packages.externalTransactionId` | string | No | Optional client-provided external transaction ID to associate with this package. | | `packages.validity` | object | No | Optional validity of the package, counted from the start of its validity: its order, or its activation for a package ordered with its eSIM. Without it the package stays valid for its plan's validity. It cannot exceed the plan's validity, and for a recurring plan it cannot be shorter than one renewal. A plan without a validity, or whose periods follow the calendar, does not accept it. | | `packages.validity.unit` | string | Yes | [Extensible enum](https://opensource.zalando.com/restful-api-guidelines/#112). `day` or `month`. A day is 24 hours; a month ends on the same day of the month, or on the last day of a shorter month. | | `packages.validity.count` | integer | Yes | At most 365 days or 12 months. | | `numberRegistration` | one of Person | Organization | No | Optional subscriber facts to register the number in its country's number registry, required in markets whose regulator mandates it. Applies to the preloaded number, or to the ported number when `portIn` is present. A registration that cannot be captured fails the order: a country whose registry is not supported is a 422; a country that does not match the number, or subscriber details the registry cannot accept, are a 400 with field errors under `numberRegistration`. | | `numberRegistration.Person` | object | No | What a person's and an organization's registration have in common. | | `numberRegistration.Person.countryCode` | string | Yes | The number's country as a two-character uppercase ISO 3166-1 alpha-2 code (malformed: 400). A country whose registry is not supported is rejected with a 422. | | `numberRegistration.Person.languageCode` | string | Yes | Subscriber's communication language as a two-character lowercase ISO 639-1 code. A language a registry does not accept is rejected with a descriptive error. | | `numberRegistration.Person.address` | object | Yes | | | `numberRegistration.Person.address.streetName` | string | Yes | | | `numberRegistration.Person.address.houseNumber` | string | Yes | | | `numberRegistration.Person.address.unit` | string | No | Bus/box/apartment, when present. | | `numberRegistration.Person.address.postalCode` | string | Yes | | | `numberRegistration.Person.address.city` | string | Yes | | | `numberRegistration.Person.firstName` | string | No | | | `numberRegistration.Person.lastName` | string | Yes | | | `numberRegistration.Person.organizationName` | any | No | | | `numberRegistration.Person.legalForm` | any | No | | | `numberRegistration.Person.vatNumber` | any | No | | | `numberRegistration.Organization` | object | No | What a person's and an organization's registration have in common. | | `numberRegistration.Organization.countryCode` | string | Yes | The number's country as a two-character uppercase ISO 3166-1 alpha-2 code (malformed: 400). A country whose registry is not supported is rejected with a 422. | | `numberRegistration.Organization.languageCode` | string | Yes | Subscriber's communication language as a two-character lowercase ISO 639-1 code. A language a registry does not accept is rejected with a descriptive error. | | `numberRegistration.Organization.address` | object | Yes | | | `numberRegistration.Organization.address.streetName` | string | Yes | | | `numberRegistration.Organization.address.houseNumber` | string | Yes | | | `numberRegistration.Organization.address.unit` | string | No | Bus/box/apartment, when present. | | `numberRegistration.Organization.address.postalCode` | string | Yes | | | `numberRegistration.Organization.address.city` | string | Yes | | | `numberRegistration.Organization.organizationName` | string | Yes | | | `numberRegistration.Organization.legalForm` | string | No | The organization's legal form, for example `NV` or `BV`. | | `numberRegistration.Organization.vatNumber` | string | No | The organization's VAT number. | | `numberRegistration.Organization.firstName` | any | No | | | `numberRegistration.Organization.lastName` | any | No | | ```json { "externalProfileId": "my-customer-123", "esimVariant": "travel", "iccid": "89012345678901234567", "portIn": { "msisdn": "32470123456", "details": { "donorContractType": "postpaid", "donorIccid": "8932031234567890128", "donorSimNumber": "1234567890128", "donorAccountNumber": "123456789" } }, "communicationLanguageCode": "nl", "packages": [ { "planReference": "OV89DVPL5XS7QN", "externalTransactionId": "order-12345", "validity": { "unit": "day", "count": 7 } } ], "numberRegistration": { "countryCode": "BE", "languageCode": "nl", "address": { "streetName": "Grote Markt", "houseNumber": "1", "unit": "A", "postalCode": "1000", "city": "Brussel" }, "firstName": "Jane", "lastName": "Doe" } } ``` ## Example request ```bash curl https://connect.test.firsty.app/api/v3/esims \ --request POST \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'Content-Type: application/json' \ --header 'X-Idempotency-Key: ' \ --data '{ "externalProfileId": "my-customer-123", "esimVariant": "travel", "iccid": "89012345678901234567", "portIn": { "msisdn": "32470123456", "details": { "donorContractType": "postpaid", "donorIccid": "8932031234567890128", "donorSimNumber": "1234567890128", "donorAccountNumber": "123456789" } }, "communicationLanguageCode": "nl", "packages": [ { "planReference": "OV89DVPL5XS7QN", "externalTransactionId": "order-12345", "validity": { "unit": "day", "count": 7 } } ], "numberRegistration": { "countryCode": "BE", "languageCode": "nl", "address": { "streetName": "Grote Markt", "houseNumber": "1", "unit": "A", "postalCode": "1000", "city": "Brussel" }, "firstName": "Jane", "lastName": "Doe" } }' ``` ## Responses ### 201 — Profile created and eSIM successfully ordered ```json { "data": { "profileReference": "1234567890123456", "externalProfileId": "my-customer-123", "esimReference": "123456000000000001", "iccid": "89012345678901234567", "activationCode": "LPA:1$provider.example.com$ACTIVATION_CODE_HERE", "pin1": "1234", "puk1": "12345678", "pin2": "5678", "puk2": "87654321", "esimVariant": "travel", "status": "released", "lifecycleStatus": "preactive", "msisdns": [ { "msisdn": "32123456789", "primary": true } ], "createdAt": "2026-01-15T09:30:00Z", "portIn": { "portInRequestReference": "K7Q2M9XA", "status": "requested", "reason": { "code": "msisdn_sim_mismatch", "message": "MSISDN/SIM number mismatch" } }, "numberRegistration": { "numberRegistrationReference": "A1B2C3D4", "registry": "be_cndb", "msisdn": "32470123456", "status": "processing", "reason": { "code": "5130", "message": "CustomerAliasLastName is missing" } }, "packages": [ { "packageReference": "OV89DVPL5XS7QN_A1B2C3D4E5F6", "planReference": "OV89DVPL5XS7QN", "externalTransactionId": "order-12345" } ] } } ``` ### 400 — Bad request - invalid parameters ### 401 — Unauthorized - missing or invalid API key ### 403 — Forbidden - client does not have access to this resource ### 404 — No available eSIM found ```json { "type": "https://developers.firsty.app/errors/not_found", "code": "not_found", "title": "Not found", "status": 404, "detail": "No available eSIM found" } ``` ### 409 — A profile with this externalProfileId already exists ```json { "type": "https://developers.firsty.app/errors/conflict", "code": "conflict", "title": "Conflict", "status": 409, "detail": "A profile with this externalProfileId already exists" } ``` ### 422 — The request was well-formed but cannot be applied as given, for example an idempotency key reused for a different request, or a physical SIM its network refuses for good (`code` `sim_refused_by_network`; the SIM stays assigned to the profile). The `detail` field identifies the cause. ```json { "type": "https://developers.firsty.app/errors/not_found", "title": "Not found", "status": 404, "detail": "eSIM not found", "code": "bad_request" } ``` ### 423 — A request with this idempotency key is still being processed ### 429 — Rate limit exceeded. A `429` can also arrive without these headers or this body; handle it by its status code. ### 500 — Internal server error