---
page_title: 3. Initialize SDK
product: EC Headless
platform: Cordova
page_source: https://juspay.io/in/docs/ec-headless/cordova/base-sdk-integration/initiating-sdk
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/ec-headless/llms.txt
---


## 2. Initiating the SDK



To initialise the SDK, client needs to call the `initiate` SDK API. The initiate api call boots up EC SDK and makes it ready for all other operations

Follow the below steps to make an initiate SDK call


### Step 2.1. Create an instance of HyperServices


EC SDK exposes the `HyperSDKPlugin` object. This object can be accessed via `cordova.plugins.HyperSDKPlugin`

> **Warning**
> The HyperSDKPlugin instance should be created only after the [onDeviceReady event](https://cordova.apache.org/docs/en/4.0.0/cordova/events/events.deviceready.html) is fired.





#### Code Snippets: -

#### Javascript Code Snippet:

```javascript
{"success":false,"message":"Failed to fetch snippet"}
```



### Step 2.2. Create Initiate payload


Initiate API takes two parameters as input. One of the parameter is a JSON object referred as `InitiatePayload`. This payload contains certain key value pairs used by the SDK to perform a successful initiate

Refer to the following table for information about the description and sample payload.


### Payload
- **RequestId**:
  - Description: Unique uuid-v4 string
  - Value: $requestId
  - Tags: String, Mandatory
- **Service**:
  - Description: Value: in.juspay.hyperapi
  - Tags: String, Mandatory
- **Payload**:
  - Description: Parameters required to call Hyper SDK API
  - Value:
    - **Action**:
      - Description: Value: initiate
      - Tags: String, Mandatory
    - **MerchantId**:
      - Description: Unique merchant id shared during onboarding
      - Tags: String, Mandatory
    - **ClientId**:
      - Description: Unique Client id shared during onboarding
      - Tags: String, Mandatory
    - **Environment**:
      - Description: Environment to be used for the session. Accepted value is production
      - Tags: String, Mandatory
  - Tags: JSON, Mandatory




#### Code Snippets: -

#### Javascript Code Snippet:

```javascript
{"success":false,"message":"Failed to fetch snippet"}
```



### Step 2.3. Create CallbackHandler


During its lifecycle, SDK emits multiple events to communicate about the transaction status. All of these events are received by the `hyperSDKCallback` function.

This callback handler is passed as the second argument to the initiate API call.



#### Code Snippets: -

#### Javascript Code Snippet:

```javascript
{"success":false,"message":"Failed to fetch snippet"}
```



### Step 2.4. Call initiate


The final step is to call the `Initiate SDK API`.

The initiate method takes stringifed `InitiatePayload` as argument. Use the functions created in the above steps to create the parameters

> **Warning**
> Initiate is a fire-and-forget call. For every HyperService instance you should **call initiate only once.** 





#### Code Snippets: -

#### Javascript Code Snippet:

```javascript
{"success":false,"message":"Failed to fetch snippet"}
```


---

## Complete Code Reference

The following code files are referenced in the steps above:

### snippets.txt

```
{"success":false,"message":"Failed to fetch snippet"}
```

### snippets.txt

```
{"success":false,"message":"Failed to fetch snippet"}
```


---

## See Also

- [2. Creating a Customer](https://juspay.io/in/docs/ec-headless/cordova/base-sdk-integration/creating-a-customer)
- [4. Rendering the Checkout Screen](https://juspay.io/in/docs/ec-headless/cordova/base-sdk-integration/rendering-the-checkout-screen)
