Skip to main content
POST
/
v1
/
customers
Node.js
import { PriceOS } from "priceos";
import type { MyFeatures } from "./priceos.types";

const priceos = new PriceOS<MyFeatures>(process.env.PRICEOS_API_KEY!);

const customer = await priceos.customers.create({
  customerId: "customer_123",
  email: "alex@acme.com",
  name: "Alex Johnson",
});
{
  "customerId": "customer_123",
  "stripeCustomerId": "cus_abc123",
  "hasPaymentMethod": true,
  "name": "Ada Lovelace",
  "email": "ada@example.com",
  "created": 1735689600000,
  "usageStartedAt": 1735689600000,
  "enviroment": "test",
  "products": [
    {
      "id": "prod_123",
      "key": "starter",
      "name": "Starter",
      "type": "stripe",
      "isDefault": false,
      "status": "active",
      "version": 1,
      "metadata": {
        "tier": "starter"
      },
      "canceledAt": null,
      "startedAt": 1735689600000,
      "currentPeriodStart": 1735689600000,
      "currentPeriodEnd": 1738368000000,
      "prices": [
        {
          "stripePriceId": "price_123",
          "quantity": 1,
          "currency": "usd",
          "unitAmount": 2000,
          "recurringInterval": "month",
          "isActive": true,
          "isDefault": true,
          "recurringIntervalCount": 1
        }
      ]
    }
  ],
  "featureAccess": {
    "api_calls": {
      "hasAccess": true,
      "type": "limit",
      "limit": 1000,
      "isUnlimited": false,
      "usage": {
        "used": 120,
        "remaining": 880,
        "bonusRemaining": 25,
        "hasReachedLimit": false,
        "bonusUsed": 5,
        "nextReset": 1738368000000,
        "lastReset": 1735689600000
      }
    },
    "team_seats": {
      "hasAccess": true,
      "type": "boolean"
    }
  },
  "bonuses": [
    {
      "bonusId": "9e9be7e5-55d2-4b44-93af-c3687f4b8af5",
      "featureKey": "api_calls",
      "amount": 50,
      "remainingAmount": 50,
      "expiresAt": 1738368000000,
      "reason": "Support credit",
      "metadata": {
        "source": "support"
      },
      "createdAt": 1735689600000,
      "updatedAt": 1735689600000
    }
  ]
}

Headers

x-api-key
string
required

API key from your PriceOS dashboard.

Body

application/json
customerId
string
required

Internal customer ID.

name
string

Customer name.

email
string

Customer email address.

usageStartedAt
integer

Unix timestamp (ms) when usage tracking started. This will determine when usage gets reset for your limit features if a customer is assigned a custom product.

customProductKeys
string[]

Assigned custom product keys.

Response

Customer created

Customer info.

hasPaymentMethod
boolean
required

Whether the Stripe customer has at least one saved payment method.

enviroment
enum<string>
required

Customer environment.

Available options:
test,
live
products
object[]
required

Subscribed or assigned products.

featureAccess
object
required

Feature access map.

bonuses
object[]
required

Customer bonuses.

customerId
string

Internal customer ID.

stripeCustomerId
string

Stripe customer ID.

name
string

Customer name.

email
string

Customer email address.

created
integer

Unix timestamp (ms) when the customer was created.

usageStartedAt
integer

Unix timestamp (ms) when usage tracking started. This will determine when usage gets reset for your limit features if a customer is assigned a custom product.