# @stigg/bulk-import

> CLI tool to bulk import customers to Stigg

Latest version **1.10.1** (published 2025-01-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @stigg/bulk-import
pnpm add @stigg/bulk-import
yarn add @stigg/bulk-import
bun add @stigg/bulk-import
```

Provides the command `bulk-import`.

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.10.1 |
| Published | 2025-01-21 |
| First published | 2022-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 61.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | guystigg, oratstigg, stiggnpc, nadavstigg, antonzy, royyy, mortal94, yelena-stigg, nadavsho, alexfedin, itzik.stigg, yt-stigg, tom.peri, nehoray_stigg |

## Links

- npm: https://www.npmjs.com/package/@stigg/bulk-import
- Repository: https://github.com/stiggio/bulk-import
- Homepage: https://github.com/stiggio/bulk-import#readme
- Issues: https://github.com/stiggio/bulk-import/issues
- npm.io page: https://npm.io/package/@stigg/bulk-import

## Dependencies (9)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [commander](https://npm.io/package/commander.md) ^9.4.1
- [bottleneck](https://npm.io/package/bottleneck.md) ^2.19.5
- [cli-progress](https://npm.io/package/cli-progress.md) ^3.11.2
- [class-validator](https://npm.io/package/class-validator.md) ^0.14.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13
- [class-transformer](https://npm.io/package/class-transformer.md) ^0.5.1
- [@stigg/node-server-sdk](https://npm.io/package/@stigg/node-server-sdk.md) ^3.60.0
- [class-transformer-validator](https://npm.io/package/class-transformer-validator.md) ^0.9.1

## Recent versions

- 1.10.1 (latest) — 2025-01-21
- 1.10.0 — 2025-01-19
- 1.9.1 — 2024-08-20
- 1.9.0 — 2024-06-03
- 1.8.0 — 2024-05-02
- 1.7.0 — 2024-01-02
- 1.6.3 — 2023-11-28
- 1.6.2 — 2023-11-28
- 1.6.1 — 2023-11-27
- 1.6.0 — 2023-11-27
- 1.5.1 — 2023-11-20
- 1.5.0 — 2023-11-20
- 1.4.0 — 2023-04-30
- 1.3.2 — 2023-04-17
- 1.3.1 — 2023-04-17
- … 20 more at https://npm.io/package/@stigg/bulk-import/versions

## README

# Bulk import customers to Stigg

<img src="docs/images/StiggIcon.svg" width="50" alt="Stigg Logo" style="">

After creating your product catalog in [Stigg](https://stigg.io), you can import your existing customers into Stigg.

This tool will manage the import process:

- It reads the list of customers to import from a `JSON` file.
- It's idempotent - feel safe to re-run it.

## Usage

### Prepare input json files

The CLI support import data of customers, subscriptions and feature usage into Stigg.

#### Import customers

Create a file `customers.json` that contains all the customers.

The file should be in the following schema:

```json5
{
  "customers": [
    {
      "customerId": "lorem-ipsum",
      "email": "lorem@ipsum.com", // optional
      "name": "Lorem-ipsum", // optional
      "billingId": "cus_MvdQq1bVD1BQHe", // optional - if an existing customer in Stripe
      "paymentMethodId": "pm_1N04AHEdaKWoSZ0OgP78RflV", // required for paid customers
      "updatedAt": "2022-01-01T00:00:00.000Z", // optional - indicates the last update of the customer. In case there's already existing customer that was updated after that date, it will skip import this customer
      "metadata": {
        // optional - set metadata for the customer
        "isTest": "true",
      },
    },
    // ...
  ],
}
```

#### Import subscriptions

Create a file `subscriptions.json` that contains all the subscriptions.

```json5
{
  "subscriptions": [
    {
      "customerId": "lorem-ipsum",
      "planId": "plan-1",
      "resourceId": "site-1", // optional - required for multiple subscriptions product
      "billingPeriod": "MONTHLY", // optional - required for paid plan
      "startDate": "2022-01-01T00:00:00.000Z", // optional - used for backdating
      "endDate": "2022-01-01T00:00:00.000Z", // optional - end date for the subscription
      "updatedAt": "2022-01-01T00:00:00.000Z", // optional - indicates the last update of the subscription. In case there's already existing subscription that was updated after that date, it will skip import this subscription
      "unitQuantity": 5, // optional - required for per-unit paid plan (single chargeable feature)
      "billableFeatures": [ // optional - required for per-unit paid plan (multiple chargeable features)
        { "featureId": "feature-seats", "quantity": 5 },
        { "featureId": "feature-projects", "quantity": 25 },
      ],
      "addons": [ // optional - set subscription addons
        { "addonId": "addon-1", "quantity": 6 },
        { "addonId": "addon-2", "quantity": 3 },
      ],
      "metadata": { // optional - set metadata for the subscription
        "isTest": "true"
      }
    },
    // ...
  ]
}
```

#### Import feature usage

Create a file `usage.json` that contains all the features' up-to-date usage.

```json5
{
  "usages": [
    {
      "customerId": "lorem-ipsum",
      "resourceId": "site-1", // optional - required for multiple subscriptions product
      "featureId": "feature-seats",
      "usage": 5
    }
    // ...
  ]
}
```

### Execute bulk import

- Obtain Server API key from https://app.stigg.io/account/settings
- Export it as environment variable:
  ```
  export STIGG_SERVER_API_KEY='<SERVER-API-KEY>'
  ```
- Initiate the bulk import process (you can either import all at once or do it separately):
  ```
  npx @stigg/bulk-import --customers-file customers.json --subscriptions-file subscriptions.json --usage-file usage.json
  ```
- During the import process there will be a progress bar.
- At the end of the process a summary will be displayed.

---
_Source: https://npm.io/package/@stigg/bulk-import · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
