> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tagada.io/llms.txt
> Use this file to discover all available pages before exploring further.

# With the Node SDK

> Server-side Rx operations: activation, clinical config, product mapping, case listing, and refills with tagada.rx.

# Tagada Rx with the Node SDK

The [Node SDK](/developer-tools/node-sdk/quick-start) exposes the whole **merchant-side** Rx surface under `tagada.rx.*`. Use it from your backend, ops scripts, or partner provisioning flows — anywhere you hold a Tagada API key.

```bash theme={null}
npm install @tagadapay/node-sdk
```

```ts theme={null}
import { Tagada } from '@tagadapay/node-sdk';

const tagada = new Tagada(process.env.TAGADA_API_KEY!);
```

<Note>
  The Node SDK maps 1:1 onto the REST endpoints under `/api/v1/rx/*`, so everything here is also available as plain HTTP with `Authorization: Bearer <key>`.
</Note>

***

## Setup & configuration

```ts theme={null}
// 1. Activate the integration (creates the pending setup-fee state)
await tagada.rx.requestActivation({
  storeId: 'store_xxx',
  clinicalNetworkSlug: 'mdi',
  operatingMode: 'affiliate',   // or 'direct' — see Operating modes
});

// 2. After the setup fee is captured (billing does this in prod;
//    admins can force it in sandbox):
await tagada.rx.confirmSetupFeePaid({ storeId: 'store_xxx' });

// 3. Wire the clinical-network credentials for your brand
await tagada.rx.configureBrandClinical({
  storeId: 'store_xxx',
  credentials: {
    clientId: '…',
    clientSecret: '…',
    webhookSecret: '…',
    externalEnvironmentId: '…',
  },
});

// 4. Map products to network offerings ("this product requires Rx")
await tagada.rx.setProductOffering({
  storeId: 'store_xxx',
  productId: 'product_xxx',
  externalOfferingId: '<network offering UUID>',
  requiresIdVerification: true,
});
```

Check where you stand at any point:

```ts theme={null}
const status = await tagada.rx.integrationStatus('store_xxx');
// { state: 'not_requested' | 'pending_payment' | 'active', ... }

const networks = await tagada.rx.listNetworks();
const brand = await tagada.rx.getBrandConfig('store_xxx');
```

***

## Working with cases

```ts theme={null}
// List cases for a store (filterable, paginated)
const { cases } = await tagada.rx.cases.list({ storeId: 'store_xxx' });

// One case + its full append-only event timeline
const detail = await tagada.rx.cases.retrieve('rxcase_xxx');
detail.events.forEach((e) => {
  console.log(e.eventType, e.statusAfter, e.postedAt);
  // case.submitted  submitted   2026-07-16T22:01:11Z
  // case.in_review  in_review   2026-07-16T22:16:31Z
  // case.approved   approved    2026-07-16T23:02:05Z
  // shipment.shipped shipped    2026-07-17T14:30:00Z
});
```

You can also submit cases server-side (e.g. from a custom backend that already collected the intake) — but remember the PHI rule: pass it through, never store it:

```ts theme={null}
const result = await tagada.rx.cases.submit({
  orderId: 'order_xxx',
  productId: 'product_xxx',
  patient: { /* … */ },
  intakeAnswers: [{ questionId: 'allergies', value: 'none' }],
});
```

***

## Refills

Refills normally run themselves (ship-day rebill engine, see [How it works](/developer-tools/rx/how-it-works#4-the-ship-day-rebill-engine)). Trigger one manually when support needs it:

```ts theme={null}
await tagada.rx.cases.requestRefill({ caseId: 'rxcase_xxx' });
```

Only cases in `shipped` or `delivered` are refill-eligible.

***

## Affiliate terms (MoR mode)

```ts theme={null}
// Read the active commission terms (rides along the brand config)
const brand = await tagada.rx.getBrandConfig('store_xxx');

// Setting terms is account-manager-restricted:
await tagada.rx.setAffiliateTerms({
  storeId: 'store_xxx',
  basis: 'order_subtotal_bps',   // or 'order_net_bps' | 'flat_per_case_minor'
  value: 1500,                   // 15%
});
```

Accruals post automatically at case submission and reverse automatically on clinician decline — there is nothing to call.

***

## Install the storefront Funnel v2

`tagada.rx.*` is the clinical surface. The **canvas** operators see in the
CRM is a regular Funnel v2. After you activate Rx (or when you seed a
headless store), create the same six-step graph the hosted templates get
on publish:

```ts theme={null}
await tagada.funnels.create({
  storeId,
  isDefault: true,
  config: { id: 'rx-storefront', name: `${brandName} storefront`, /* nodes + edges */ },
});
```

Copy the full graph from
[With the Headless SDK](/developer-tools/rx/headless-sdk#install-the-same-funnel-v2-crm-canvas)
or run the [rx-storefront example](https://github.com/TagadaPay/examples/tree/main/rx-storefront)
(`pnpm seed` calls `funnels.create` and writes `funnel.bundle.json` for
**Funnels → Import bundle**).

***

## Method reference

| Method                                    | What it does                                   |
| ----------------------------------------- | ---------------------------------------------- |
| `tagada.rx.requestActivation(input)`      | Start activation (creates pending setup fee)   |
| `tagada.rx.confirmSetupFeePaid(input)`    | Flip to active after the fee is captured       |
| `tagada.rx.configureBrandClinical(input)` | Wire clinical-network credentials              |
| `tagada.rx.integrationStatus(storeId)`    | `not_requested` / `pending_payment` / `active` |
| `tagada.rx.listNetworks()`                | Clinical networks available to the account     |
| `tagada.rx.getBrandConfig(storeId)`       | Brand clinical config + terms                  |
| `tagada.rx.setAffiliateTerms(input)`      | Version new commission terms (AM only)         |
| `tagada.rx.setProductOffering(input)`     | Map product ↔ network offering                 |
| `tagada.rx.cases.list(params)`            | List cases                                     |
| `tagada.rx.cases.retrieve(caseId)`        | Case + event timeline                          |
| `tagada.rx.cases.submit(input)`           | Submit a case (PHI pass-through)               |
| `tagada.rx.cases.requestRefill(input)`    | Manual refill trigger                          |
