// subscribe to the lastest version of the plan PRO
const { result, error } = await unprice.customers.signUp({
  name: "John Doe",
  email: "customer@example.com",
  planSlug: "PRO",
  externalId: "your_database_id",
  successUrl: "https://example.com/dashboard",
  cancelUrl: "https://example.com/login"
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "success": true,
  "url": "https://example.com/dashboard",
  "customerId": "cus_1234567890"
}

SignUp is the most important method of the SDK because that is how you can seemssly onboard new users into your product. If you are used to used Stripe, the flow is pretty much the same.

// subscribe to the lastest version of the plan PRO
const { result, error } = await unprice.customers.signUp({
  name: "John Doe",
  email: "customer@example.com",
  planSlug: "PRO",
  externalId: "your_database_id",
  successUrl: "https://example.com/dashboard",
  cancelUrl: "https://example.com/login"
});

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "success": true,
  "url": "https://example.com/dashboard",
  "customerId": "cus_1234567890"
}

Request

name
string
required

The name of the customer

email
string
required

The email of the customer

timezone
string

The timezone of the customer. If not provided, the system will use the project timezone

defaultCurrency
string

The default currency of the customer. If not provided, the system will use the project currency. Must be one of: “USD” or “EUR”

billingInterval
string

The billing interval for the customer’s subscription. If plan version is provided, this will match the plan version. If plan slug is provided, this will be the default billing interval of the plan. Must be one of: “month”, “year”, “day”, “minute”, or “onetime”

planSlug
string

The plan slug to sign up for. If provided, the system will intelligently pick the latest plan for that slug. Required if planVersionId is not provided

planVersionId
string

The specific plan version ID to sign up for. Required if planSlug is not provided

config
array

Configuration for subscription items. Required for quantity-based features when customer needs to set them. Leave empty to use plan defaults

config[].featurePlanId
string
required

The feature plan ID of the item

config[].featureSlug
string
required

The feature slug of the item

config[].isUsage
boolean

Whether the item is a usage-based feature

config[].units
number

The number of units the customer is subscribed to

config[].min
number

The minimum number of units for the feature

config[].limit
number

The maximum number of units for the feature

externalId
string

An external ID to associate with the customer (e.g., user ID from your database)

successUrl
string
required

The URL to redirect to after successful signup (typically your dashboard)

cancelUrl
string
required

The URL to redirect to if the customer cancels signup (typically your login page)

Response

success
boolean
required

Whether the signup was successful

url
string
required

The URL to redirect the customer to (either success or cancel URL)

customerId
string
required

The Unprice customer ID generated for this customer