# Functions

## initializeSDK

▸ **initializeSDK**(): `void`

Creates a new Orchestration SDK instance with your client context. On iOS, credentials are configured from the `TransmitSecurity.plist` file. On Android, initialization is performed in the native `MainApplication` class.

### Example

```javascript
import RNTSIdentityOrchestration from 'react-native-ts-identity-orchestration';

if (Platform.OS === 'ios') {
  RNTSIdentityOrchestration.initializeSDK();
}
```

Note
On Android, initialization must be done natively. Add `TsIdentityOrchestrationModule.initializeAndroidSDK(this)` to your `MainApplication.kt` `onCreate()` method.

## setResponseHandler

▸ **setResponseHandler**(`handler`): `void`

Sets a response handler for journey responses and errors. Must be called before `startJourney()` or `startMobileApproveJourney()`.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `handler` | `Object` | Object containing success and error callbacks |
| `handler.success` | `(results: TSIDOModule.ServiceResponse) => void` | Called when a journey step response is received |
| `handler.error` | `(error: TSIDOModule.JourneyErrorType) => void` | Called when a journey error occurs |


### Example

```javascript
import RNTSIdentityOrchestration, { TSIDOModule } from 'react-native-ts-identity-orchestration';

RNTSIdentityOrchestration.setResponseHandler({
    success: (results: TSIDOModule.ServiceResponse) => {
        // Handle journey step
    },
    error: (error: TSIDOModule.JourneyErrorType) => {
        // Handle error
    }
});
```

## startJourney

▸ **startJourney**(`journeyId`, `options?`): `void`

Starts a journey with the given identifier. The response is delivered asynchronously through the handler set via `setResponseHandler()`.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `journeyId` | `string` | Journey identifier as configured in the Admin Portal |
| `options?` | `TSIDOModule.StartJourneyOptions` | `null` | Optional journey start parameters |


The `StartJourneyOptions` object supports:

| Property | Type | Description |
|  --- | --- | --- |
| `additionalParams` | `{ [key: string]: any }` | Key-value parameters passed to the journey, accessible via `@policy.request().params.<key>` |
| `flowId` | `string` | Optional flow identifier for tracking |
| `encrypted` | `boolean` | Enables encryption mode (`true` = full, `false` = none) |


### Example

```javascript
import RNTSIdentityOrchestration, { TSIDOModule } from 'react-native-ts-identity-orchestration';

const options: TSIDOModule.StartJourneyOptions = {
    flowId: 'login-flow',
    additionalParams: { userEmail: 'name@example.com' }
};

RNTSIdentityOrchestration.startJourney('my_journey_id', options);
```

## startMobileApproveJourney

▸ **startMobileApproveJourney**(`payload`, `options?`): `void`

Starts a mobile approve journey to handle approval flows (such as transaction signing or push notifications). The response is delivered asynchronously through the handler set via `setResponseHandler()`.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `payload` | `{ [key: string]: string }` | Key-value object containing approval data |
| `options?` | `TSIDOModule.StartJourneyOptions` | `null` | Optional journey start parameters |


### Example

```javascript
import RNTSIdentityOrchestration, { TSIDOModule } from 'react-native-ts-identity-orchestration';

const payload = { transactionId: '12345', amount: '$100' };

RNTSIdentityOrchestration.startMobileApproveJourney(payload, null);
```

## submitClientResponse

▸ **submitClientResponse**(`clientResponseOptionId`, `data?`): `void`

Submits a client response for the current journey step. This advances the journey to the next step based on the selected response option and any collected data.

### Parameters

| Name | Type | Description |
|  --- | --- | --- |
| `clientResponseOptionId` | `string` | `TSIDOModule.ClientResponseOptionType` | The response option ID, either a standard type or a custom branch ID |
| `data?` | `{ [key: string]: any }` | `null` | Client response data object, required for steps that collect input |


Standard response option types (`TSIDOModule.ClientResponseOptionType`):

| Value | Description |
|  --- | --- |
| `clientInput` | Typical reply to a step with a main or single output path |
| `cancel` | Selects the cancel branch |
| `fail` | Selects the failure branch |


### Example

```javascript
import RNTSIdentityOrchestration, { TSIDOModule } from 'react-native-ts-identity-orchestration';

// Simple response (e.g., information step)
RNTSIdentityOrchestration.submitClientResponse(TSIDOModule.ClientResponseOptionType.clientInput);

// Response with data (e.g., form input)
RNTSIdentityOrchestration.submitClientResponse(
    TSIDOModule.ClientResponseOptionType.clientInput,
    { externalUserId: userId, userPassword: password }
);

// Custom branch response
RNTSIdentityOrchestration.submitClientResponse('passkey', {
    webauthn_encoded_result: encodedResult
});
```

## ServiceResponse

See [ServiceResponse](/sdk-ref/react-native-ts-identity-orchestration/interfaces/serviceresponse) for the full interface reference.

## JourneyActionType

See [JourneyActionType](/sdk-ref/react-native-ts-identity-orchestration/enums/journeyactiontype) for the full enum reference.

## ClientResponseOptionType

See [ClientResponseOptionType](/sdk-ref/react-native-ts-identity-orchestration/enums/clientresponseoptiontype) for the full enum reference.

style
table th:first-of-type {
    width: 20%;
}
table th:nth-of-type(2) {
    width: 40%;
}
table th:nth-of-type(3) {
    width: 40%;
}