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",
});curl -X POST "https://api.priceos.com/v1/customers" \
-H "x-api-key: PRICEOS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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
}
]
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Create Customer
Create a customer record.
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",
});curl -X POST "https://api.priceos.com/v1/customers" \
-H "x-api-key: PRICEOS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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
}
]
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Headers
API key from your PriceOS dashboard.
Body
Internal customer ID.
Customer name.
Customer email address.
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.
Assigned custom product keys.
Response
Customer created
Customer info.
Whether the Stripe customer has at least one saved payment method.
Customer environment.
test, live Subscribed or assigned products.
Show child attributes
Show child attributes
Feature access map.
Show child attributes
Show child attributes
Customer bonuses.
Show child attributes
Show child attributes
Internal customer ID.
Stripe customer ID.
Customer name.
Customer email address.
Unix timestamp (ms) when the customer was created.
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.