---
updatedAt: 2026-11-24T23:55:19.000Z
agentTools:
  projectIndex: https://apidocs.taxbit.com/llms.txt
---

# Questionnaire integration guide

Collect W-9, W-8 (BEN, BEN-E, IMY), MRDP (DAC7), CRS, and CARF tax documentation inside your React application with a drop-in, fully customizable component. Submitted data flows into the Taxbit platform, undergoes TIN matching where applicable, and feeds end-of-year information returns. Completed forms are available from the Taxbit Dashboard and the Tax Documentation API.

The SDK supports three questionnaire types:

| Questionnaire                        | Use it for                                                                                            |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| **Forms W-8 / W-9** (`W-FORM`)       | Collect and validate Forms W-8 and W-9 ahead of payment and reporting for 1099-B, DIV, INT, and more. |
| **Digital Platform Seller** (`DPS`)  | Satisfy MRDP obligations under DAC7 (EU), and equivalents in the UK, New Zealand, and Canada.         |
| **Self-Certification** (`SELF-CERT`) | Collect CRS, CARF, and DAC8 self-certifications based on OECD guidance for global reporting.          |

You'll pick the one that fits your users under Configure for your use case.

# Set up locally

Render a dry run to verify the SDK works in your app. A dry run without a token makes no requests to Taxbit and stores nothing.

## Install the SDK

Install [`@taxbit/react-sdk`](https://www.npmjs.com/package/@taxbit/react-sdk)

```bash
npm install @taxbit/react-sdk
```

Compatible with React 18–19 and TypeScript 5.

**Bundlers handle the language files automatically.** `import` gets the ES build (`dist/taxbit-react-sdk.js`) and `require` gets the CommonJS build (`dist/taxbit-react-sdk.cjs`). Both keep each language in its own file next to the entry and load it the first time that language is shown. Webpack, Vite, Rollup, Parcel and esbuild emit and serve these files for you, so no setup is needed. If you copy the entry file to a CDN or static folder by hand, copy every `.js` file in `dist/` with it and keep them in the same folder. There's no `<script>`-tag (UMD) build; load the SDK through a bundler.

## Server rendering (Next.js)

Under server rendering, the questionnaire renders its loading screen, so the page hydrates without a mismatch. To skip the server render entirely, import the component client-side only:

```jsx
import dynamic from 'next/dynamic';

const TaxbitQuestionnaire = dynamic(
  () => import('@taxbit/react-sdk').then((m) => m.TaxbitQuestionnaire),
  { ssr: false },
);
```

## Render a dry run

```jsx
import '@taxbit/react-sdk/style/inline.css';
import { TaxbitQuestionnaire } from '@taxbit/react-sdk';

export default function App() {
  return <TaxbitQuestionnaire questionnaire="W-FORM" dryRun />;
}
```

A dry run stores nothing. Without a token it makes no API calls and simulates the IRS checks: in a real-time TIN check, a TIN containing `0` is valid, `6` invalid, anything else pending. Set `questionnaire` to `"DPS"` or `"SELF-CERT"` to render the other forms. `onProgress`, `onSubmit` and `onSettled` fire in a dry run, so you can inspect the data the SDK collects.

Once you have a token (step 2), you can keep `dryRun` on to run the real IRS checks against Taxbit while still storing nothing — useful in staging.

## What you should see

The component renders the questionnaire as a multi-step form: a progress indicator, one group of questions per step, inline validation, and Back / Next / Submit controls. `onProgress` and `onSubmit` fire as the user moves through it, so you can confirm data is flowing.

**The styling is Taxbit's default, not a fixed design.** The form is plain semantic HTML with `taxbit-` class names — point it at your own stylesheet to match your product. See [Style it to your brand](#style-it-to-your-brand).

If the form doesn't render, verify the stylesheet import resolved and your React version is supported. Next, connect your backend to submit real data.

# Connect your backend

The SDK authenticates with a bearer token scoped to a single Account Owner — the user you're collecting documentation from. Mint the token on your server; token requests from the browser are rejected.

## Gather your credentials `Required`

Log in to the Taxbit Dashboard and navigate to **Settings > Developer Settings** to find your environment-specific credentials.

| Credential      | Purpose                                       |
| --------------- | --------------------------------------------- |
| `client_id`     | Public identifier for your integration        |
| `client_secret` | Server-side only. Never expose to the browser |
| `tenant_id`     | Identifies your organization in Taxbit        |

**Keep your&#x20;**`client_secret`**&#x20;secure.** Store it in a secrets manager or environment variable. Anyone with the secret can impersonate your tenant.

**Non-US tenants and proxied networks.** EU-provisioned tenants set `config.connection.region` to `"EU"` (the default is `"US"`); the server-side API host is region-specific too. Where direct access to Taxbit is restricted, route requests through your own gateway with `config.connection.proxyDomain`, plus `config.connection.proxyHeaders` for custom auth (your proxy must strip them before forwarding). If your proxy forwards only an allowlist of paths, add `telemetry/events`. See [Usage telemetry](#usage-telemetry).

```jsx
<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={accountOwnerToken}
  config={{ connection: { proxyDomain: 'https://taxbit-proxy.your-corp.com' } }}
/>
```

## Create an Account Owner `Required`

Create an Account Owner for each user you collect from. Authorize this tenant-wide call with a tenant-scoped token from `POST /v1/oauth/token`. Only `id` and `account_owner_type` are required.

| Method | Endpoint             |
| ------ | -------------------- |
| `POST` | `/v1/account-owners` |

```javascript
const aoResponse = await fetch(
  "https://api.multi1.enterprise.taxbit.com/v1/account-owners",
  {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${tenantToken}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      id: "d290f1ee-6c54-4b01-90e6-d701748f0851",  // V4 UUID recommended
      account_owner_type: "INDIVIDUAL",            // INDIVIDUAL or ENTITY
    }),
  }
);
```

The `id` you provide is how you refer to this Account Owner from then on — it is what you send as `id` when requesting an account-owner-scoped token, and what identifies the Account Owner in later calls.

**Provisioning strategy.** For new users, create the Account Owner during onboarding, when the user creates their account in your system — only the ID is needed. For existing users, both the API and file ingestion are available for backfilling Account Owner data.

**Account creation is optional for the SDK.** The SDK doesn't require an Account. You may need Accounts later for transaction reporting — see the Accounts API.

## Mint an Account Owner token

Exchange your credentials for an Account Owner–scoped token and pass `access_token` to your client.

```javascript
async function requestAccountOwnerToken(accountOwnerId) {
  const response = await fetch(
    "https://api.multi1.enterprise.taxbit.com/v1/oauth/account-owner-token",
    {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      body: new URLSearchParams({
        grant_type:       "client_credentials",
        client_id:        process.env.TAXBIT_CLIENT_ID,
        client_secret:    process.env.TAXBIT_CLIENT_SECRET,
        tenant_id:        process.env.TAXBIT_TENANT_ID,
        id: accountOwnerId,
      }),
    }
  );
  if (!response.ok) {
    throw new Error(`Account owner token request failed: ${response.status}`);
  }
  return response.json(); // { access_token, expires_in, token_type }
}
```

### Reuse the token until it expires

Request one Account Owner token per Account Owner and reuse it until shortly before it expires. Each token request is a network round trip your user waits on, so requesting one on every page load slows the questionnaire for no benefit.

Cache the token on your server, keyed by Account Owner ID, and use `expires_in` from the response to decide when to request the next one:

```javascript
const REFRESH_MARGIN_MS = 5 * 60 * 1000; // request a new token 5 minutes before expiry
const tokenCache = new Map();            // accountOwnerId -> { accessToken, expiresAt }

async function getAccountOwnerToken(accountOwnerId) {
  const cached = tokenCache.get(accountOwnerId);
  if (cached && cached.expiresAt - Date.now() > REFRESH_MARGIN_MS) {
    return cached.accessToken;
  }

  const { access_token, expires_in } = await requestAccountOwnerToken(accountOwnerId);
  tokenCache.set(accountOwnerId, {
    accessToken: access_token,
    expiresAt: Date.now() + expires_in * 1000,
  });
  return access_token;
}
```

Call `getAccountOwnerToken` from the endpoint your client uses to load the questionnaire. A page reload or a second visit within the hour then returns the cached token and makes no request to Taxbit. The `Map` in this example keeps every entry until your server restarts, so in production use a cache that removes expired entries. If you run more than one server instance, keep the cache in a store they share, such as Redis, and set each entry to expire with its token.

## Token expiration

If a token expires mid-session, API calls return `401 Unauthorized` and surface through your `onError` callback. See [Handling token expiration](https://apidocs.taxbit.com/docs/handling-token-expiration) for how to detect and recover from it.

## Render with real data

Replace `dryRun` with the `bearerToken` prop. The same component now submits to Taxbit:

```jsx
<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={accountOwnerToken}
  onSuccess={handleSuccess}
/>
```

Submissions appear in your Taxbit Dashboard and are retrievable from the tax-documentation-status endpoint. `onSuccess` fires when Taxbit receives the submission, not when validation completes — see Handle validation and status.

**Submission shape.** Submitted documents carry the certification statements and the no-other-tax-residencies confirmations as optional boolean fields, affirmed by default. They can also carry `usTinIsValid` / `giinIsValid` (the user confirmed a TIN or GIIN the IRS check couldn't match) and `passiveNffeUsSubstantialOwner`. If your code validates the submission shape strictly, allow these fields. If it ignores unknown fields, no change is needed.

**Check the document before it's stored.** `onSubmit` receives the signed document before Taxbit stores it, and the SDK waits for it. Return a rejected promise to stop the submit; the user stays on the form and `onError` is called.

**Offer the signed PDF.** Set `config.documentDownload` to `true` and, once the document is stored, the user sees a page with a button that downloads the PDF they signed. Not available for DPS. To build your own download link instead, see [Offer a PDF download](#offer-a-pdf-download-on-the-confirmation-screen).

## Update your Content Security Policy `If applicable`

If your app uses a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP), add the following directive to allow the SDK to reach the Taxbit API:

```
connect-src https://*.taxbit.com;
```

Without this, the SDK renders but API calls will fail — check your browser's network and console errors and your `onError` handler before testing in production. Usage telemetry goes to the same host, so this directive already covers it.

## Usage telemetry

On by default. `TaxbitQuestionnaire` posts usage events to `telemetry/events`. It uses the same environment, region or `proxyDomain` as its other requests, with the same bearer token. Taxbit uses the events to see where users get stuck and which validation errors they hit.

| Sent                                                                                                                                                                              | Never sent                                                               |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| Questionnaire load, each step shown, Next / Back / Edit / Submit presses, validation errors shown, real-time TIN and GIIN outcomes, submission, the configuration props in effect | Anything the user typed: names, TINs, addresses, dates, or other answers |
| Step ids, field keys, coded validation keys (for example `required`, `mustBeNineDigits`), check status codes                                                                      |                                                                          |

If an event fails, the SDK drops it quietly. It doesn't block the questionnaire, interrupt the user, or call `onError`.

To opt out, set `config.telemetry` to `false`. The SDK then makes no telemetry requests.

```jsx
<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={accountOwnerToken}
  config={{ telemetry: false }}
/>
```

What to check:

* **Proxy allowlists.** If you use `proxyDomain` and your proxy forwards only listed paths, add `telemetry/events`. Without it, events fail quietly and the questionnaire still works normally.
* **Content Security Policy.** If your CSP already allows the SDK's API host, you don't need to change it.
* **Dry runs.** Without a `bearerToken`, nothing is sent.
* **Curing.** `TaxbitCuringDocumentation` doesn't send usage events and has no `telemetry` setting.

# Configure for your use case

With real data flowing, shape the flow to fit your users: which questionnaire you need, and how to avoid asking for data you already have.

## Pick your questionnaire

Each pattern below leads with the situation that determines the configuration. If more than one applies to your user base — for example, U.S. and non-U.S. payees — render the component multiple times with different `questionnaire` values per Account Owner.

<details className="uc" open>
<summary>Paying U.S. persons subject to 1099 reporting</summary>

**W-FORM.** Collect Form W-9 from U.S. individuals or entities who'll receive a 1099 at year-end. Use this whenever you need a certified U.S. TIN before making a reportable payment.

| Prop or setting                      | Value                                                                                                        |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
| `questionnaire`                      | `"W-FORM"`                                                                                                   |
| `config.wForm.realTimeTinValidation` | `true` if your tenant is configured for RTT — surfaces TIN mismatches at submission rather than at year-end. |
| `config.wForm.treatyClaims`          | Omit — treaty claims don't apply to W-9 filers.                                                              |

**Watch for:** a returning `tinStatus` of `MISMATCH` or `INVALID_DATA` after submission — these need a B-notice flow. See [TIN validation](#handle-validation-and-status).

</details>

<details className="uc">
<summary>Paying foreign persons U.S.-source income (FDAP)</summary>

**W-FORM.** Collect Form W-8BEN or W-8BEN-E. If the payee may claim reduced withholding under a tax treaty, enable `config.wForm.treatyClaims` to surface the additional questions about treaty country, article, and claimed rate.

| Prop                                 | Setting                                                                                                                                                                                                               |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `questionnaire`                      | `"W-FORM"`                                                                                                                                                                                                            |
| `config.wForm.treatyClaims`          | `true` if any of your foreign payees may claim treaty benefits. Safe to leave on universally — payees not claiming a treaty move through the questions without committing to anything. Requires `typesOfIncome`.      |
| `config.wForm.typesOfIncome`         | Required whenever `treatyClaims` is `true`. The income types the account can generate — drives per-country treaty eligibility. See [Declare income types for treaty claims](#declare-income-types-for-treaty-claims). |
| `config.wForm.fatca`                 | `true` to collect Chapter 4 classification, certifications, and GIIN. Forced on when `typesOfIncome` includes `INTEREST` or `DIVIDENDS`. See [Enable FATCA collection](#enable-fatca-collection).                     |
| `config.wForm.realTimeTinValidation` | No effect — RTT applies only to W-9 submissions.                                                                                                                                                                      |

**Watch for:** `treatyClaimStatus: 'INVALID'` and the `TREATY_COUNTRY_MISMATCH` issue type both mean the treaty claim won't apply as submitted. The `needsResubmission` flag on `wFormQuestionnaire` tracks whether the user needs to return. See [validation and status](#handle-validation-and-status).

</details>

<details className="uc">
<summary>Collecting CRS, CARF, or DAC8 self-certification</summary>

**SELF-CERT.** Collect tax residences, citizenship, and TINs from individuals or entities on platforms subject to CRS, CARF, or DAC8 reporting. The same questionnaire serves both, with the payload shape differing by entity type.

| Prop                              | Setting                                                                                                                                                                                                 |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `questionnaire`                   | `"SELF-CERT"`                                                                                                                                                                                           |
| `data.accountHolder.isIndividual` | `true` for individuals; `false` for entities. Entities also need `selfCertificationAccountType` set to `"FINANCIAL_INSTITUTION"`, `"ACTIVE_NON_FINANCIAL_ENTITY"`, or `"PASSIVE_NON_FINANCIAL_ENTITY"`. |
| `config.locale.language`          | Defaults to `en-gb`. Set explicitly for non-English markets.                                                                                                                                            |

**Watch for:** tax residences in high-risk jurisdictions trigger an additional `accountHolderTaxResidenciesConfirmation` step. Controlling-person data on entity flows cannot be pre-populated — those questions are always shown, even with [adaptive mode](#adaptive-mode-skip-pre-filled-questions) enabled.

</details>

<details className="uc">
<summary>Running a digital platform with MRDP reporting obligations</summary>

**DPS.** Collect seller information for DAC7 (EU) and equivalents in the UK, New Zealand, and Canada. The SDK collects tax identification, address, business registration, and (where applicable) VAT.

| Prop                     | Setting                                                                                      |
| ------------------------ | -------------------------------------------------------------------------------------------- |
| `questionnaire`          | `"DPS"`                                                                                      |
| `config.locale.language` | Defaults to `en-gb`. Set per-seller based on locale; full EU language coverage is supported. |

**Watch for:** VAT validation via VIES is asynchronous — `vatStatus` may return `'PENDING'` on first submission and resolve later. See [VAT validation](#handle-validation-and-status). A VAT number that failed VIES doesn't block submission. An "Invalid" badge appears beside the VAT label on the tax information step and the summary, and the user can resubmit without changing it. Use `vatStatus` (or the webhook) to follow up on an `INVALID` VAT. DPS submissions don't have a downloadable PDF — `canGetDocumentUrl` on the hook will be `false`.

</details>

# Adaptive mode: skip pre-filled questions

Use Adaptive mode when you already collect user data upstream — during onboarding, KYC, KYB, or account maintenance — and want the SDK to ask only for what's still missing, invalid, or required for the tax form.

Think of it as a bridge between your application flow and Taxbit's tax documentation flow: you keep your existing upstream experience, pass known data in through the `data` prop, and the SDK shortens the questionnaire by hiding fields already satisfied with valid values. It evaluates each field independently:

* Valid values hide the question.
* Invalid or incomplete values are shown so the user can correct them.
* Required fields still appear when missing.

**Note:** Adaptive mode reduces duplicate data entry, but it doesn't remove required certification, confirmation, or review steps. Some sections also can't be pre-populated — controlling-person data in certain Self-Cert entity flows, for example.

## What it does and doesn't do

It **does**:

* Hide questions for fields you already provided with valid values.
* Shorten the flow so users focus only on what still needs attention.
* Support different review experiences depending on whether skipped values should be locked or editable.

It **doesn't**:

* Bypass required tax logic or certification requirements.
* Silently accept invalid upstream data — invalid or incomplete values are still shown for correction.
* Guarantee every section can be pre-populated — some are always collected directly in the SDK.

## When to use it

Adaptive mode is a strong fit when you already collect some or most of the same information upstream and want tax documentation to feel like a continuation of your existing flow rather than a separate questionnaire. Common cases:

* End-of-onboarding tax documentation after KYC or KYB.
* Existing-user resubmission or change-in-circumstance flows.
* Account settings or maintenance flows where you re-open the SDK with as much prior data preserved as possible.

## Choose a mode

```jsx
<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={token}
  config={{ rules: { adaptiveMode: "skipLock" } }}
  data={{
    accountHolder: {
      isUsPerson: true, usAccountType: "INDIVIDUAL",
      name: "Jane Doe", tin: "776568989",
      address: { firstLine: "123 Main St", city: "Seattle",
        stateOrProvince: "WA", postalCode: "98101", country: "US" },
    },
  }}
/>
```

| Mode             | In the flow                                  | On the review screen       | Best for                                                                        |
| ---------------- | -------------------------------------------- | -------------------------- | ------------------------------------------------------------------------------- |
| `full` (default) | Nothing skipped; supplied data is pre-filled | All fields editable        | Prefill only, without hiding questions                                          |
| `skipLock`       | Questions with valid data are hidden         | Skipped fields are locked  | Onboarding flows where upstream data should change only when strictly necessary |
| `skipEdit`       | Questions with valid data are hidden         | All fields remain editable | Resubmission or maintenance flows where users may need to adjust prior values   |

## How skip logic works

Adaptive reads three signals per field: whether it's present in `data`, whether the value is valid, and whether it's required for the form type.

| What you pass             | In the flow                   | Review (`skipLock`)                  |
| ------------------------- | ----------------------------- | ------------------------------------ |
| Valid value               | Hidden                        | Locked                               |
| Invalid or incomplete     | Shown to fix                  | Editable                             |
| `""` on an optional field | Hidden                        | Locked                               |
| `""` on a required field  | Shown — never skipped on `""` | Editable                             |
| Omitted (optional)        | Hidden                        | Editable — generally nothing to lock |
| Omitted (required)        | Shown                         | Editable                             |

Invalid or incomplete data — a partial address, an invalid postal code, a wrong date format, a malformed TIN — is always shown so the user can correct it.

## Empty string vs. omitted

Pass `""` only for a field you already showed the user in your own UI and they chose to leave blank; the SDK reads it as "asked and intentionally skipped" and won't ask again. This applies to optional fields only — a required field with `""` is treated as missing and still shown.

Don't pass `""` to shorten the flow for a field the user never saw. Some fields — a W-8 mailing address, a W-8 U.S. TIN — are optional in the SDK but should still be offered; an empty string there produces a form that's valid in the SDK but invalid under tax rules.

## FTIN

Non-U.S. TINs with syntax warnings are still skipped (and locked under `skipLock`). Setting `ftinNotLegallyRequired: true` overrides the FTIN entirely — the SDK treats the field as not required.

**Brazil entity TINs (CNPJ).** The SDK accepts the alphanumeric CNPJ: 12 letters or digits followed by 2 check digits. It can be entered as 14 characters or in the formatted style `XX.XXX.XXX/XXXX-NN`. You can pass either form in `data`.

**Postal codes and TINs are submitted without separators.** A U.S. ZIP or Canadian postal code is formatted as it's typed (`62701-1234`, `K1A 0B1`) and submitted without the dash or space (`627011234`, `K1A0B1`). Values you pass in `data` with a dash or space are normalized the same way.

**Dates of birth.** A date of birth in `data` that isn't a valid date shows its format error once the user moves on. With `config.rules.minimumAge`, a date of birth under that age is refused, and one whose year the picker doesn't offer opens with the year blank.

## Example: what the user still sees

Suppose you collected a user's name, address, and TIN during onboarding and passed those into the SDK. If the values are valid:

* The user doesn't re-enter them in the SDK.
* The SDK asks only for fields that are still missing, invalid, or required for the tax form.
* The user still completes any required certifications, confirmations, or always-collected sections.

The more complete and valid your upstream data, the shorter the SDK flow — which is why Adaptive mode works best paired with a clear upstream data strategy.

## Prefill data by form type

Adaptive reads the `data` prop. The fields it accepts differ by form type — expand a shape to see what you can pre-fill. Which props to set for each questionnaire is covered under [Pick your questionnaire](#pick-your-questionnaire).

<details className="uc">
<summary>W-9 — Individual</summary>

```json
{
  "accountHolder": {
    "isUsPerson": true,
    "usAccountType": "INDIVIDUAL",
    "name": "Jane Doe",
    "tin": "776568989",
      "address": {
        "firstLine": "123 Main St",
        "secondLine": "",
        "city": "Seattle",
        "stateOrProvince": "WA",
        "postalCode": "98101",
        "country": "US"
      }
  }
}
```

</details>

<details className="uc">
<summary>W-9 — Entity (C Corporation)</summary>

```json
{
  "accountHolder": {
    "isUsPerson": true,
    "usAccountType": "C_CORPORATION",
    "name": "Martinez Corporation",
    "dbaName": "Martinez Solutions",
    "tin": "776568989",
      "address": {
        "firstLine": "123 Main St",
        "secondLine": "",
        "city": "Seattle",
        "stateOrProvince": "WA",
        "postalCode": "98101",
        "country": "US"
      }
  }
}
```

</details>

<details className="uc">
<summary>W-8BEN</summary>

```json
{
  "accountHolder": {
    "isUsPerson": false,
    "accountOwnerType": "INDIVIDUAL",
    "name": "Maria Fernandez",
    "ftin": "A1234567",
    "address": {
      "firstLine": "45 Calle Real",
      "secondLine": "Apt 3",
      "city": "Madrid",
      "stateOrProvince": "MD",
      "postalCode": "28001",
      "country": "ES"
    },
    "mailingAddress": {
      "firstLine": "PO Box 123",
      "secondLine": "",
      "city": "Madrid",
      "stateOrProvince": "MD",
      "postalCode": "28002",
      "country": "ES"
    },
    "mailingAddressIsDifferent": true,
    "countryOfCitizenship": "ES",
    "dateOfBirth": "01/01/1990",
    "ftinNotLegallyRequired": false
  }
}
```

</details>

<details className="uc">
<summary>W-8BEN-E</summary>

```json
{
  "accountHolder": {
    "isUsPerson": false,
    "accountOwnerType": "ENTITY",
    "countryOfCitizenship": "US",
    "foreignAccountType": "CORPORATION",
    "name": "Fernandez Consulting Group",
    "ftin": "B9876543",
    "tin": "",
    "address": {
      "firstLine": "100 Business Rd",
      "secondLine": "Suite 500",
      "city": "Barcelona",
      "stateOrProvince": "BC",
      "postalCode": "08001",
      "country": "ES"
    },
    "mailingAddress": {},
    "mailingAddressIsDifferent": false,
    "ftinNotLegallyRequired": false
  }
}
```

</details>

<details className="uc">
<summary>Self-Certification — Individual</summary>

```json
{
  "accountHolder": {
    "isIndividual": true,
    "name": "Ray Holt",
    "address": {
      "firstLine": "100 Harbour Road",
      "secondLine": "",
      "city": "Dublin",
      "stateOrProvince": "",
      "postalCode": "D02",
      "country": "IE"
    },
    "countryOfCitizenship": "IE",
    "dateOfBirth": "05/31/1994",
    "taxResidences": [
      { "country": "IE", "tin": "2342344T" }
    ]
  }
}
```

</details>

<details className="uc">
<summary>Self-Certification — Managed Investment Entity</summary>

**Controlling-person data cannot be pre-populated at this time.**

```json
{
  "accountHolder": {
    "isIndividual": false,
    "selfCertificationAccountType": "FINANCIAL_INSTITUTION",
    "financialInstitutionType": "INVESTMENT_ENTITY",
    "investmentEntityManaged": true,
    "entityType": "TRUST",
    "name": "Managed Investments Ltd.",
    "address": {
      "firstLine": "100 Harbour Road",
      "secondLine": "",
      "city": "Dublin",
      "stateOrProvince": "",
      "postalCode": "D02",
      "country": "IE"
    },
    "countryOfCitizenship": "IE",
    "taxResidences": [
      { "country": "IE", "tin": "2342344T" },
      { "country": "AU", "tin": "51824753556" }
    ]
  }
}
```

</details>

# Skip server-side prefill

By default, `<TaxbitQuestionnaire />` fetches the account owner's prior submission on mount and prefills the form with it, so a returning user lands on a completed summary. Prior W-9, W-8BEN, W-8BEN-E, W-8IMY, self-certification and digital-platform-seller submissions repopulate in full, including regarded-owner submissions, which reopen on the disregarded-entity path, and submissions saved through the API. For most products that's what you want — it's the same saved data Adaptive mode compares against. For stricter security postures, `config.prepopulateWithSavedData` opts out of that fetch.

Setting `config.prepopulateWithSavedData` to `false`:

* Skips the `GET /tax-documentation/submissions` call entirely — no prior PII is sent over the wire on mount. (The SDK normally appends `?unmask=true&questionnaire=…` to this same path; with the prop disabled, the request isn't made at all.)
* Forces the form to start on step one — the user walks the questionnaire from the beginning, even if they previously submitted a completed form.
* Leaves the status fetch unaffected — `useTaxbit().statusData` still works exactly as before; status, issues, expiration, and curing signals are all still available.
* Leaves submission unaffected — `POST /tax-documentation/submissions` works the same. Submitting populates the user's record as a fresh submission.

Omitting it keeps the default — this is an opt-in change.

| Value              | Effect                                                                                      |
| ------------------ | ------------------------------------------------------------------------------------------- |
| `true` *(default)* | Fetches the prior submission, prefills the form, and routes returning users to the summary. |
| `false`            | Doesn't fetch the prior submission. The form starts fresh on step one.                      |

## When to use it

Set it to `false` when:

* You gate the SDK behind step-up auth (2FA, recent-auth) and don't want previously collected data rendered into the DOM during the session.
* Your security posture requires the SDK to display only data the user enters in the current authenticated session.
* The user is expected to re-attest from scratch — compliance-driven re-collection or periodic reverification.

Leave it at the default for the standard onboarding pattern, where returning users review their prior submission and continue from where they left off.

## Usage

```jsx
<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={accountOwnerToken}
  config={{ prepopulateWithSavedData: false }}
  onError={(err) => reportToSentry(err)}
  onSuccess={() => router.push('/done')}
/>
```

That's the whole integration — no other props or callbacks change because of this setting.

## Interaction with other props

`data`**&#x20;(host-supplied prefill).** This setting gates *server-saved* data only — the submission Taxbit has on file. It does not suppress prefill you pass via `data`. With `prepopulateWithSavedData: false` and a populated `data` prop, the SDK skips the server fetch but still prefills from `data`. For a fully blank form, omit `data`.

`config.rules.adaptiveMode`**.** Adaptive mode compares submitted state against the host-supplied `data` or the server-fetched submission. With the server side turned off, it has only `data` to work from: no `data` means nothing to compare against, so the user sees every field (same as `adaptiveMode: 'full'`); a populated `data` means it skips or locks those fields only. If your goal is "no prior PII," Adaptive mode against a `data` prop you control is still consistent with that.

`useTaxbit`**.** `statusData` is unaffected — it's metadata from a different endpoint, not PII. But `serverData` returns an empty object when the hook's `prepopulateWithSavedData` is `false`, and `refreshSubmission()` is a no-op since there's nothing fetched to refresh. Account for the empty case if any UI outside the SDK reads `serverData`.

## Pitfalls

* **The setting means server-saved data, not all prefill.** It does not suppress the `data` prop. If a security review hinges on "no prefill at all," set the flag *and* omit (or audit) what you pass to `data`.
* **The prior submission still exists server-side.** This flag changes only what the SDK fetches and renders — it doesn't delete or hide prior data on the Taxbit side. A token capable of rendering the SDK can still retrieve the prior submission via a direct API call.

# W-8 expansion: FATCA and income types

Two W-FORM settings extend what the W-8 flows collect. `config.wForm.fatca` turns on Chapter 4 collection. `config.wForm.typesOfIncome` tells the SDK what income the filer's account can generate, which drives treaty eligibility and can force FATCA on. Both apply to `questionnaire="W-FORM"` only.

## Enable FATCA collection

FATCA is off by default. Turn it on with `config.wForm.fatca`:

```jsx
<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={accountOwnerToken}
  config={{ wForm: { fatca: true } }}
  onSuccess={handleSuccess}
/>
```

With `fatca: true`, the W-FORM questionnaire additionally collects Chapter 4 classification, applicable certifications, GIIN (for FFIs), and — for Passive NFFEs that declare US-owner presence — up to five substantial US owner records. All of this happens inside the questionnaire component: you don't render additional UI or call additional endpoints. The collected values come back on `ClientTaxDocumentation`, alongside the rest of the submission.

### Required when income types trigger Chapter 4

If `typesOfIncome` includes `INTEREST` or `DIVIDENDS`, the SDK forces `fatca: true` at initialization. Explicitly setting `fatca: false` in that case throws a configuration error — remove the prop or set it to `true`.

## Declare income types for treaty claims

If you enable treaty claims (`config.wForm.treatyClaims`), you must also pass `config.wForm.typesOfIncome`. This lets the SDK determine treaty eligibility per country and drive the right claim questions.

```jsx
<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={accountOwnerToken}
  config={{
    wForm: { treatyClaims: true, typesOfIncome: ['royalties-other', 'interest'] },
  }}
  onSuccess={handleSuccess}
/>
```

Accepts a single value or an array. Hyphenated and underscored forms are both accepted — `royalties-other` and `ROYALTIES_OTHER` resolve to the same value. Unrecognized values throw at initialization.

### Accepted values

| Value                             | Hyphenated alias                  | Notes                |
| --------------------------------- | --------------------------------- | -------------------- |
| `INTEREST`                        | `interest`                        | Forces `fatca: true` |
| `DIVIDENDS`                       | `dividends`                       | Forces `fatca: true` |
| `BUSINESS_PROFITS`                | `business-profits`                |                      |
| `ROYALTIES_MOTION_PICTURE_AND_TV` | `royalties-motion-picture-and-tv` |                      |
| `ROYALTIES_OTHER`                 | `royalties-other`                 |                      |
| `OTHER_INCOME`                    | `other-income`                    |                      |

The example above includes `interest`, so FATCA collection is on for that integration whether or not `fatca` is passed. Pick the values that reflect what the account can actually pay out — over-declaring `INTEREST` or `DIVIDENDS` lengthens the questionnaire for every filer.

# Handle validation and status

TIN matching with the IRS, VAT validation via VIES, and downstream changes all resolve *after* the user submits.

## Received vs. validated

`onSuccess` is the callback the SDK fires once a submission reaches Taxbit and is accepted. It confirms receipt — **not** that the TIN matched, the VAT validated, or the form is final.

Validation continues after the user leaves:

* **W-9** — TIN matched against the IRS
* **DPS** — VAT validated against VIES

Either can take minutes to hours, so don't mark a form "complete" on `onSuccess` alone. Read the final result from `tinStatus` / `vatStatus`, covered next.

## Read status with the useTaxbit hook

```jsx
import { useTaxbit } from '@taxbit/react-sdk';

const { statusData } = useTaxbit({ bearerToken, questionnaire: 'W-FORM' });

if (statusData?.wFormQuestionnaire?.tinStatus === 'PENDING') {
  return <Badge>Validation in progress</Badge>;
}
```

Both fields begin `PENDING` and resolve after submission:

* `tinStatus` (W-9, IRS match) — `MISMATCH` and `INVALID_DATA` feed a B-notice flow; a `VALID_*_MATCH` clears it. `config.wForm.realTimeTinValidation` attempts the match at submission and reflects it inline.
* `vatStatus` (DPS, VIES) — resolves to `VALID`, `INVALID`, `INSUFFICIENT_DATA`, `NOT_REQUIRED`, or `NON_EU`. An `INVALID` VAT doesn't block a resubmission. The form shows an "Invalid" badge and lets the user submit, so follow up from this status rather than relying on the form to stop them.

See the [reference](https://apidocs.taxbit.com/docs/component-and-hook-reference#status-enums) for every value.

## Respond to changes with webhooks

Submissions can change state long after the user is gone — a W-8 may need resubmission after a change in circumstances, a TIN may flip from `VALID` to `MISMATCH` on a re-check, an issue may be cured in the Taxbit Dashboard. These surface as webhook events.

Use the [Webhooks Guide](https://apidocs.taxbit.com/docs/webhooks-guide) for the full event taxonomy. A few notes specific to SDK integrations:

* The account-owner status webhook fires for *any* change to the status object, not just user-initiated submissions — don't trigger user-facing notifications directly from it.
* To detect a genuinely new submission, compare the document ID from the status API: a changed ID means new data; the same ID means existing data was re-evaluated.
* Delivery retries; if it ultimately fails, file a support ticket to redrive events, and keep your own monitoring on top of Taxbit's.

When `needsResubmission` is set, route the user back to the same component with `config.rules.adaptiveMode` set to `"skipEdit"`. To set it yourself, for a change you detected outside Taxbit or a periodic re-collection, call [Request New Tax Documentation](https://apidocs.taxbit.com/reference/post_account-owners-id-tax-documentation-data-resubmission-requests); the documentation on file stays valid until the account owner resubmits.

## Cure post-submission issues

Some W-8 validation issues can be resolved without re-collecting the whole form. When `statusData` surfaces an `OPEN` curable issue, route the user to `<TaxbitCuringDocumentation />` instead of the full questionnaire — it gathers only the evidence and reasonable explanation needed to clear the open issue.

```jsx
import { useTaxbit, TaxbitCuringDocumentation } from '@taxbit/react-sdk';

const { needsCuringDocumentation, isLoading, refresh } =
  useTaxbit({ bearerToken, questionnaire: 'W-FORM' });

if (!isLoading && needsCuringDocumentation) {
  return <TaxbitCuringDocumentation bearerToken={bearerToken} onSuccess={refresh} />;
}
```

Gate the mount on `needsCuringDocumentation`. Curing is W-8 only — W-9 users with issues go back through `<TaxbitQuestionnaire />` with `adaptiveMode: "skipEdit"`. See the [Curing integration guide](https://apidocs.taxbit.com/docs/curing-integration-guide) for the full walkthrough: when to use it, curable issue types, what the user sees, and the post-submission lifecycle.

## Offer a PDF download on the confirmation screen

This sits at the end of the flow — the confirmation screen you render after `onSuccess`, not your styling layer. Available for W-Form and Self-Certification submissions, not DPS.

**The simplest option is built in.** Set `config.documentDownload: true` and the questionnaire shows a download page itself once the document is stored, laid out like its other pages. Use the hook below only when you render your own confirmation screen.

`useTaxbit` mints a short-lived download URL; gate the link on `canGetDocumentUrl`.

```jsx
const { canGetDocumentUrl, generateDocumentUrl, documentUrl } =
  useTaxbit({ bearerToken, questionnaire });

useEffect(() => { if (canGetDocumentUrl) generateDocumentUrl(); }, [canGetDocumentUrl]);

return documentUrl ? <a href={documentUrl} download>Download form</a> : null;
```

# Customize and ship

## Style it to your brand

The form is semantic HTML with namespaced `taxbit-` classes, and those class names are a stable contract. Import at most one base stylesheet, then write your overrides after it — order decides which rules win.

```jsx
import '@taxbit/react-sdk/style/inline.css'; // or 'basic.css' / 'minimal.css' / none
import './taxbit-overrides.css';             // yours, always imported after
```

```css
button.taxbit-button { background: #0B1B33; border-radius: 8px; }
.taxbit-input:focus { outline: 2px solid #2EE5C8; }
```

With `inline.css` or `basic.css`, you can change colors without rewriting rules. Override the `--taxbit-color-*` tokens on `:root` and every control picks them up:

```css
:root {
  --taxbit-color-primary: #0a5;
  --taxbit-color-primary-hover: #084;
  --taxbit-color-on-primary: #fff;
}
```

You can tweak the default look or replace the styling outright. `TaxbitQuestionnaire` and `TaxbitCuringDocumentation` render the same classes, so one stylesheet covers both.

See [Customizing look and feel](https://apidocs.taxbit.com/docs/customizing-look-and-feel) for the full class reference, what each base stylesheet gives you, brand override patterns, and the agent skill that writes the overrides for you.

## Meet accessibility requirements

The questionnaire targets WCAG 2.1 AA. Inside the component, the SDK handles labels, group semantics, live-region announcements, focus between steps and autofill hints. Some criteria depend on your page:

* **A `<title>` per step.** The `onProgress` callback's `stepTitle` is made for this — it's the heading the page shows. `onProgress` and `onError` fire once per event even when you pass an inline function, so you don't need `useCallback`.

  ```jsx
  <TaxbitQuestionnaire
    questionnaire="W-FORM"
    bearerToken={accountOwnerToken}
    onProgress={({ stepTitle }) => { document.title = `${stepTitle} – Tax information`; }}
  />
  ```

* **`<html lang>`.** Set the page language. The SDK marks the language of its own language-picker options.

* **A heading level that fits.** Section titles render as `<h4>`. Embed the SDK at a point in your heading outline where `h4` makes sense.

When the step changes, focus moves to the new step's title, so the browser scrolls it into view. The first step never takes focus from your page. `ACCESSIBILITY.md`, shipped in the package, lists everything the SDK handles and what the host provides.

## Test your integration

The questionnaire's DOM follows accessible patterns. Write tests against labels and roles:

* **Find controls by visible label or `id`.** Use `getByLabelText('Name')` or the `id`. Controls no longer carry an `aria-label` equal to the field key. Accessible names don't include the asterisk, so match `Name` rather than `Name*`. Required fields expose `aria-required`.
* **Find buttons by name, not position.** Use `getByRole('button', { name: 'Next' })`. Next and Submit come before Back in the DOM.
* **Check `aria-disabled`, not `toBeDisabled()`.** While Next or Submit is working, or after a submit, it carries `aria-disabled="true"` instead of the `disabled` attribute, so focus stays on the button. It carries `aria-busy="true"` while a real-time TIN or GIIN check runs.
* **Use groups for composite fields.** Radio sets are `role="radiogroup"`. Phone, date, address, tax-residency and controlling-person sections are `role="group"` with an accessible name, so `getByRole('group', { name: 'Address' })` is the most stable selector.
* **Date and phone-country selects start with a disabled placeholder option.** Account for it if you pick options by position or assert the option list.
* **Use a dry run in end-to-end tests.** `dryRun` without a token makes no API calls and simulates the IRS checks, so tests are fast and store nothing.

## Support mobile

To use the SDK in a mobile app, render it in a webview and bridge callbacks to native code, reusing the same token flow. This is the supported way to add the SDK to an iOS, Android or React Native app today.

> 📘 Want a fully native experience?
>
> Native Mobile Tax Documentation Collection (Beta) is in development. It draws the questionnaire with each platform's own UI tools instead of a webview. See the [Native collection overview](https://apidocs.taxbit.com/docs/native-tax-documentation-collection-overview).

Host a page that posts each callback to whichever bridge is present:

```jsx
function notifyNative(event, payload) {
  const msg = JSON.stringify({ event, payload });
  window.ReactNativeWebView?.postMessage(msg);              // React Native
  window.webkit?.messageHandlers?.taxbit?.postMessage(msg); // iOS WKWebView
  window.TaxbitBridge?.postMessage(msg);                    // Android interface
}

<TaxbitQuestionnaire
  questionnaire="W-FORM"
  bearerToken={bearerToken}
  onSuccess={(d) => notifyNative('success', d)}
  onError={(e) => notifyNative('error', e)}
/>
```

Load that page in your platform's webview:

* **React Native** — `react-native-webview`
* **iOS** — `WKWebView`, with `WKUserContentController` message handlers
* **Android** — `android.webkit.WebView`, with a JavaScript interface

For production:

* Pre-warm the webview off-screen
* Enable DOM storage
* Handle load errors with a native offline screen
* Set the viewport meta tag:

```html
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
```

## Languages

Set `config.locale.language` to pre-select the locale; account owners can also switch via an in-form dropdown (hideable with CSS). The SDK loads only the language it is showing. The loading screen shows while the first language downloads. When the user switches language, the current one stays on screen until the new one arrives. If that fetch fails, the form keeps the current language. `config.locale.language` accepts the full `Locale` set (53 tags); the in-form picker shows a subset — roughly 45 for DPS and Self-Certification and 19 for W-Form. See [Supported languages](https://apidocs.taxbit.com/docs/component-and-hook-reference#supported-languages) for the full list of locale codes.

# Next steps

* [Customizing look and feel](https://apidocs.taxbit.com/docs/customizing-look-and-feel) — the full class reference and brand override patterns
* [Component and hook reference](https://apidocs.taxbit.com/docs/component-and-hook-reference) — every prop, hook return value, and type
* [Webhooks Guide](https://apidocs.taxbit.com/docs/webhooks-guide) — full event taxonomy
* [Curing integration guide](https://apidocs.taxbit.com/docs/curing-integration-guide) — clear open W-8 validation issues in place
* [Tax documentation FAQ](https://apidocs.taxbit.com/docs/tax-documentation-guide) — what each form collects and why
* [Remediation FAQ](https://apidocs.taxbit.com/docs/remediation-faq) — handling W-8/9 issues
* [Upgrade guide](https://apidocs.taxbit.com/docs/upgrade-guide) — moving from 6.3 to 7.0, and earlier versions

# Sibling pages

* [How the SDK works](https://apidocs.taxbit.com/docs/how-the-sdk-works.md)
* [Customizing look and feel](https://apidocs.taxbit.com/docs/customizing-look-and-feel.md)
* [Handling token expiration](https://apidocs.taxbit.com/docs/handling-token-expiration.md)
* [Curing integration guide](https://apidocs.taxbit.com/docs/curing-integration-guide.md)
* [Component and hook reference](https://apidocs.taxbit.com/docs/component-and-hook-reference.md)
* [Upgrade guide](https://apidocs.taxbit.com/docs/upgrade-guide.md)

# Sibling pages

* [How the SDK works](https://apidocs.taxbit.com/docs/how-the-sdk-works.md)
* [Customizing look and feel](https://apidocs.taxbit.com/docs/customizing-look-and-feel.md)
* [Handling token expiration](https://apidocs.taxbit.com/docs/handling-token-expiration.md)
* [Curing integration guide](https://apidocs.taxbit.com/docs/curing-integration-guide.md)
* [Component and hook reference](https://apidocs.taxbit.com/docs/component-and-hook-reference.md)
* [Upgrade guide](https://apidocs.taxbit.com/docs/upgrade-guide.md)