Logo

Get Started

To get started with customers, follow these steps:

1. Create a Customer

To create a customer, you can use the API or the dashboard.

Node.js Example

const customer = await openmeter.customers.create({
  name: 'ACME, Inc.',
  key: 'my-database-id',
  usageAttribution: { subjects: ['my-identifier'] },
});

cURL Example

curl -X POST 'https://dev.openmeter.cloud/api/v1/customers' \
  --header 'Accept: */*' \
  --header 'Authorization: Bearer my-token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "name": "ACME, Inc.",
    "key": "my-database-id",
    "usageAttribution": { "subjects": ["my-identifier"] }
  }'

Learn more about how usage attribution works in OpenMeter in the Usage Attribution documentation.

2. Set a Stripe Customer ID

Optionally, if you want to use the Stripe app to collect payments, you can set the Stripe Customer ID for the customer.

Stripe App

You need to install first the Stripe App to set be able to set a Stripe Customer ID.

Node.js Example

await openmeter.customers.stripe.upsert('customer-id-or-key', {
  stripeCustomerId: 'cus_123',
  // Optionally set the default payment method
  // stripeDefaultPaymentMethodId: 'pm_123',
});

cURL Example

curl  -X PUT \
  'https://dev.openmeter.cloud/api/v1/customers/01JDJM1WF8Y461YQ9F0EW4WHY2/stripe' \
  --header 'Accept: */*' \
  --header 'Authorization: Bearer my-token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "stripeCustomerId": "cus_123"
  }'

Last updated on