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

# Provisioning customers

## Overview

In this quick start guide we'll demonstrate how to provision customers in Stigg.

**Customers** in Stigg should be provisioned when a customer is created in your application, for example: as part of your registration or onboarding process.

## Before we begin

In order to complete this guide in your application code, please make sure that you have:

* [Modeled your pricing in Stigg](/documentation/modeling-your-pricing-in-stigg/overview)
* [Installed the Stigg Node.js server SDK](/api-and-sdks/integration/backend/nodejs#installing-the-sdk)
* [A Stigg **full access** key](/api-and-sdks/integration/backend/nodejs#retrieving-the-full-access-key)

## Initializing the server SDK

The first step is to initialize Stigg's server SDK with the full access key of the environment that's integrated with Stigg:

```typescript TypeScript theme={null}
import Stigg from '@stigg/node-server-sdk';

const stiggClient = await Stigg.initialize({ apiKey: 'YOUR_FULL_ACCESS_KEY' });

export default stiggClient;
```

<Warning>
  The Stigg SDK instance has an internal cache and supports retries for certain API calls on network errors. In general, you should initialize it once per process (for example: using a singleton design-pattern) and use the same instance throughout the codebase.
</Warning>

## Provision a customer

When a new customer is provisioned within your application (for example: as part of your registration or onboarding process), you should also provision them in Stigg.

You can optionally pass `subscriptionParams` to create subscription for that customer using a single operation. Doing so, will allow Stigg admins to override the requested subscription with no-code from the Stigg app using the [product's Customer Journey configuration](../../documentation/modeling-your-pricing-in-stigg/products#defining-the-customer-journey).

```typescript TypeScript theme={null}
const customer = await stiggClient.provisionCustomer({ 
    customerId: 'test-customer-id',
    name: 'John Doe',
    email: 'john@example.com',
    subscriptionParams: {
      planId: 'plan-basic'
    }
});
```

### Excluding customers from experiment

When running experiments, in some cases we would want to exclude customer from participating in the experiment. For example if we have a marketing campaign for new users that creates new subscriptions to specific plans. We will need to use the `excludeFromExperiment` flag. In case the flag is provided, customer will have the subscription according to the customer journey.

```typescript TypeScript theme={null}
const customer = await stiggClient.provisionCustomer({ 
    customerId: 'test-customer-id',
    name: 'John Doe',
    email: 'john@example.com',
      excludeFromExperiment: true,
    subscriptionParams: {
      planId: 'plan-basic'
    }
});
```

## Additional resources

<Card title="REST API: Create Customer" href="/api-and-sdks/api-reference/rest/customers-create" icon="server" horizontal />

<Card title="REST SDKs" href="/api-and-sdks/references/sdk/backend/rest/index" icon="code" horizontal />

<Card title="Node.js SDK: Provisioning Customers (Legacy)" href="/api-and-sdks/integration/backend/nodejs#provisioning-customers" icon="code" horizontal />
