---
page_source: https://juspay.io/in/docs/ec-headless/react-native/base-sdk-integration/initiating-sdk
page_title: 3. Initialize SDK
---


## 3. 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

> **Error**
> Initiate is to be called on render of the homescreen. Not following this will lead to increased latency.




### Step 3.1. Import HyperSDK


Import the HyperSDK namespace to get access to HyperServices class in your code



#### Code Snippets: -

#### Functional Code Snippet:

```functional
import HyperSdkReact from 'hyper-sdk-react';
```

#### Class Code Snippet:

```class
import HyperSdkReact from 'hyper-sdk-react';
```



### Step 3.2. Create an instance of HyperServices


EC SDK exposes the `HyperServices` class. Create an object of this class for all upcoming operations



#### Code Snippets: -

#### Functional Code Snippet:

```functional
HyperSdkReact.createHyperServices();
```

#### Class Code Snippet:

```class
HyperSdkReact.createHyperServices();
```



### Step 3.3. 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: -

#### Functional Code Snippet:

```functional
const initiate_payload = {
      requestId: uuid.v4(),
      service: 'in.juspay.hyperpay',
      payload: {
        action: 'initiate',
        merchantId: '<MERCHANT_ID>',
        clientId: '<CLIENT_ID>',
        XRoutingId: '<X_ROUTING_ID>',
        environment: 'production',
      },
    };
```

#### Class Code Snippet:

```class
const initiate_payload = {
      requestId: uuid.v4(),
      service: 'in.juspay.hyperpay',
      payload: {
        action: 'initiate',
        merchantId: '<MERCHANT_ID>',
        clientId: '<CLIENT_ID>',
        XRoutingId: '<X_ROUTING_ID>',
        environment: 'production',
      },
    };
```



### Step 3.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: -

#### Functional Code Snippet:

```functional
HyperSdkReact.initiate(JSON.stringify(initiate_payload));
```

#### Class Code Snippet:

```class
HyperSdkReact.initiate(JSON.stringify(initiate_payload));
```


## Sample Code Snippets:
### Initiating the SDK:

#### Step 3.1. Import HyperSDK Code Snippet:

```step 3.1. import hypersdk
//block:start:import-hyper-sdk

import HyperSdkReact from 'hyper-sdk-react';

//block:end:import-hyper-sdk
```

#### Step 3.2. Create an instance of HyperServices
 Code Snippet:

```step 3.2. create an instance of hyperservices

// block:start:create-hyper-services-instance

HyperSdkReact.createHyperServices();

// block:end:create-hyper-services-instance
```

#### Step 3.3 Create Initiate payload Code Snippet:

```step 3.3 create initiate payload
// block:start:create-initiate-payload

const initiate_payload = {
    requestId: uuid.v4(),
    service: 'in.juspay.hyperapi',
    payload: {
        "action" : "initiate",
        "merchantId" : "<Merchant Id>",
        "clientId" : "<Client Id>",
        "customerId" : "<Customer Id>", //Any unique refrences to current customer
        "environment" : "prod",
    },
};

// block:end:create-initiate-payload

```

#### Step 3.4. Call initiate Code Snippet:

```step 3.4. call initiate
// block:start:initiate-sdk

HyperSdkReact.initiate(JSON.stringify(initiate_payload));

// block:end:initiate-sdk
```

