Onboard new customer

Creates a new customer with Stripe account and payment method setup

📘

API Refs

Request body

NameTypeDescriptionRequired
emailstringCustomer email addressyes
firstNamestringCustomer first nameno
lastNamestringCustomer last nameno
phonestringCustomer phone numberno
addressobjectCustomer addressno

Address Object Structure

NameTypeDescriptionRequired
streetstringStreet addressno
citystringCityno
statestringState or provinceno
postalCodestringPostal/ZIP codeno

Example Request

{
  "email": "[email protected]",
  "firstName": "John",
  "lastName": "Doe",
  "phone": "+1234567890",
  "address": {
    "street": "123 Main St",
    "city": "New York",
    "state": "NY",
    "postalCode": "10001"
  }
}

Response

Success Response (201 Created)

FieldTypeDescription
customerobjectThe created/found customer object
stripeCustomerIdstringThe Stripe customer ID
messagestringSuccess message

Customer Object Structure

FieldTypeDescription
idstringCustomer ID
emailstringCustomer email address
firstNamestringCustomer first name
lastNamestringCustomer last name
phonestringCustomer phone number
addressobjectCustomer address
stripeCustomerIdstringStripe customer ID
createdAtstringCustomer creation date
updatedAtstringLast update date

Response

{
  "customer": {
    "id": "123",
    "email": "[email protected]",
    "firstName": "John",
    "lastName": "Doe",
    "phone": "+1234567890",
    "address": {
      "street": "123 Main St",
      "city": "New York",
      "state": "NY",
      "postalCode": "10001"
    },
    "stripeCustomerId": "cus_ExampleCustomerID123",
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-01T00:00:00.000Z"
  },
  "stripeCustomerId": "cus_ExampleCustomerID123",
  "message": "Customer successfully onboarded"
}

Important Notes

  1. Idempotent Operation: If a customer with the same email already exists, the API will return the existing customer instead of creating a duplicate.

  2. Stripe Integration: This endpoint automatically creates a corresponding customer in Stripe, enabling payment processing capabilities.

  3. Payment Method: While this endpoint creates the customer, you'll need to use Stripe's payment method APIs or the billing portal to add payment methods.

  4. Required Fields: Only email is required. Other fields can be added later using the update customer endpoint.

Error Responses

  • 400 Bad Request: Invalid customer data or payment method setup failed
  • 401 Unauthorized: Invalid or missing authorization token
  • 403 Forbidden: Insufficient permissions

Use Cases

  1. New Customer Registration: Use when a new customer signs up for your service
  2. Pre-subscription Setup: Create customer account before setting up subscriptions
  3. Customer Import: Bulk import customers from other systems