---
title: "Headless SDK (v4)"
url: "https://docs.wayflyer.com/embedded-journey-v5-overview/v4-legacy/using-the-sdk/v4-headless-sdk"
image: "https://docs.wayflyer.com/_og/d/c_Ocean.takumi,title_Headless+SDK+(v4),props_eyJ0aGVtZSI6eyJtb2RlIjoibGlnaHQiLCJjb2xvcnMiOnsicHJpbWFyeSI6IiMyMzIzMmQifX19,p_Ii9lbWJlZGRlZC1qb3VybmV5LXY1LW92ZXJ2aWV3L3Y0LWxlZ2FjeS91c2luZy10aGUtc2RrL3Y0LWhlYWRsZXNzLXNkayI,s_I3OBTvoksRaLrGff.png"
---

> **This page documents v4 (Hosted Application).** v4 is in maintenance mode. New integrations should use [v5 (Embedded Journey)](https://docs.wayflyer.com/embedded-journey-v5-overview). Existing partners can follow the [Migration Guide](https://docs.wayflyer.com/embedded-journey-v5-overview/v4-legacy/migration-guide-v4-to-v5) to upgrade.

# Headless SDK

The headless SDK provides a typesafe wrapper around the Hosted Capital API.

## [Installation](#installation)

Install the package directly from NPM with `npm install @wf-financing/headless-sdk@release-v4`.

To minimize bundle size and reduce the impact on partners' page load times, the SDK uses dynamic imports to load the required components of the SDK on demain.

## [Instantiation](#instantiation)

Initialize the Wayflyer headless SDK by passing the `companyToken` and an optional `options` object with a type of `HeadlessSdkOptions` that specifies additional functionality of SDK instance - e.g. consuming sandbox API instead of the production.

```jsx
import { WayflyerHeadlessSdk, HeadlessSdkOptions } from '@wf-financing/headless-sdk';

// instantiation in production mode
const wayflyerHeadlessSdk = await WayflyerHeadlessSdk.loadSdk(companyToken);

// instantiation in sandbox mode, `options` type of HeadlessSdkOptions
const options: HeadlessSdkOptions = { isSandbox: true };
const wayflyerHeadlessSdk = await WayflyerHeadlessSdk.loadSdk(companyToken, options);
```

Note: The companyToken should be minted using the Company Token endpoint on the partner's backend. See the Authentication section [here](https://docs.wayflyer.com/embedded-journey-v5-overview/shared/authentication) for more details.

## [SDK Methods](#sdk-methods)

### [getCta](#getcta)

Returns the configuration for the CTA to show to the user.

```typescript
import type { CtaResponseType } from '@wf-financing/headless-sdk';

const cta: CtaResponseType = await wayflyerSdk.getCta();
```

### [startHostedApplication](#starthostedapplication)

Initiates a Wayflyer funding application for the customer. Returns a URL to a personalized Wayflyer landing page that the user should be redirected to.

```typescript
import type { StartHostedApplicationRequestType, StartHostedApplicationResponseType } from '@wf-financing/headless-sdk';

const merchantData: StartHostedApplicationRequestType = {
company_data: {},
user_data: {},
partner_data: {},
};

const startHostedApplication: StartHostedApplicationResponseType = await wayflyerSdk.startHostedApplication(merchantData);
```

### [continueHostedApplication](#continuehostedapplication)

Use this to continue a hosted application when the `getCta()` method returns a Continue Hosted Application CTA, as described in the "Continuing a hosted application" guide. Returns a URL to a personalized Wayflyer landing page that the user should be redirected to.

```typescript
import type { ContinueHostedApplicationResponseType } from '@wf-financing/headless-sdk';

const continueHostedApplication: ContinueHostedApplicationResponseType = await wayflyerSdk.continueHostedApplication();
```

### [dismissCta](#dismisscta)

Use this method to notify that the user wants to dismiss the current CTA. Subsequent calls to `getCta` for this user will return `null` for a few days. Repeated dismissals will result in an exponential backoff.

```jsx
await wayflyerSdk.dismissCta();
```