> For the complete documentation index, see [llms.txt](https://en-api.decisiontele.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://en-api.decisiontele.com/esim-api/provision-an-esim.md).

# Provision an eSIM

Step-by-step guide to create a client, allocate an eSIM, assign a data package, and retrieve the activation QR code.

Follow the steps below to provision a new eSIM for an end user.

### 1. Create a B2C Client

Create a client of type b2c. B2C clients do not have platform access and cannot create packages.

#### Request

POST /api/v1/clients

```
 curl -X POST "https://esim-api.it-decision.com/api/v1/clients" \
  -H "Authorization: Bearer <TOKEN>" \
  -F "name=My B2C Client" \
  -F "email=b2c-client@example.com" \
  -F "type=b2c" \
  -F "identifier=my_b2c_client_001" \
  -F "platformAccess=false" \
  -F "packageCreation=false"
```

#### Result

A new B2C client is created. The response contains a clientId that is used in the next provisioning steps.

{% hint style="info" %}
Save the returned clientId. You will need it when assigning the eSIM to the client.
{% endhint %}

### 2. Get an Available eSIM

Retrieve a list of eSIMs that are not yet assigned to any client or package.

#### Request

GET /api/v1/esims?allocated=false

```
curl --location \
"https://esim-api.it-decision.com/api/v1/esims?allocated=false" \
--header "Authorization: Bearer <TOKEN>"
```

#### Result

the response contains a list of unallocated eSIMs. Select the required esimId for the next step.

{% hint style="info" %}
Save the selected esimId. It will be used to find compatible packages and assign the eSIM.
{% endhint %}

### 3. Find Compatible Packages

Retrieve a list of data packages that are compatible with the selected eSIM.

#### Request

POST /api/v1/esims/find-packages

```
curl --location "https://esim-api.it-decision.com/api/v1/esims/find-packages" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <TOKEN>" \
--data '{
  "esims": [
    "<ESIM_ID>"
  ]
}'
```

#### Result

The response contains the data packages available for the selected eSIM. Select the required packageId.

{% hint style="info" %}
Save the selected packageId. You will use it together with clientId and esimId in the next step.
{% endhint %}

### 4. Assign eSIM + Package + Client

Assign the selected eSIM and data package to the B2C client.

#### Request Body

```
{
  "esims": [
    "<ESIM_ID>"
  ],
  "packages": [
    "<PACKAGE_ID>"
  ],
  "client": "<CLIENT_ID>"
}
```

#### Result

The eSIM becomes allocated to the client, the selected data package is assigned, and the eSIM is ready for activation.

{% hint style="info" %}
Use the clientId, esimId, and packageId returned or selected in the previous steps.
{% endhint %}

### 5. Retrieve the QR Code

Once the eSIM is allocated, retrieve its activation QR code or activation data.

#### Request

```
curl --location
"https://esim-api.it-decision.com/api/v1/esims?allocated=true&ids=<ESIM_ID>"
--header "Authorization: Bearer "
```

#### Result

The response returns the QR code or activation data for the allocated eSIM.

{% hint style="info" %}
Provide the returned QR code to the end user to activate the eSIM on their device.
{% endhint %}
