cURL
curl --request POST \
--url https://us.api.flexprice.io/v1/commitments/preview \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "<string>",
"scope": {
"entity_id": "<string>"
},
"start_date": "2023-11-07T05:31:56Z",
"active_windows": [
{
"end": {
"hour": 12,
"minute": 29
},
"start": {
"hour": 12,
"minute": 29
}
}
],
"binding": true,
"committed_price": {
"amount": "<string>",
"tiers": [
{
"unit_amount": "<string>",
"flat_amount": "<string>",
"transform_quantity": {
"divide_by": 123
},
"up_to": 123
}
],
"transform_quantity": {
"divide_by": 123
}
},
"end_date": "2023-11-07T05:31:56Z",
"idempotency_key": "<string>",
"invoice_description": "<string>",
"invoice_label": "<string>",
"metadata": {},
"overage_price": {
"amount": "<string>",
"tiers": [
{
"unit_amount": "<string>",
"flat_amount": "<string>",
"transform_quantity": {
"divide_by": 123
},
"up_to": 123
}
],
"transform_quantity": {
"divide_by": 123
}
},
"priority": 123,
"subscription_id": "<string>",
"timezone": "<string>",
"value": "<string>"
}
'from flexprice import Flexprice
from flexprice.utils import parse_datetime
with Flexprice(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.commitments.preview_commitment(measurement="billing_period", name="<value>", scope={
"entity_type": "meter",
}, start_date=parse_datetime("2024-11-23T11:41:25.905Z"), type_="amount")
# Handle response
print(res)import { Flexprice } from "@flexprice/sdk";
const flexprice = new Flexprice({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await flexprice.commitments.previewCommitment({
measurement: "billing_period",
name: "<value>",
scope: {
entityType: "meter",
},
startDate: new Date("2024-11-23T11:41:25.905Z"),
type: "amount",
});
console.log(result);
}
run();package main
import(
"context"
flexprice "github.com/flexprice/go-sdk/v2"
"github.com/flexprice/go-sdk/v2/models/types"
"github.com/flexprice/go-sdk/v2/types"
"log"
)
func main() {
ctx := context.Background()
s := flexprice.New(
flexprice.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Commitments.PreviewCommitment(ctx, types.CreateCommitmentRequest{
Measurement: types.CommitmentMeasurementBillingPeriod,
Name: "<value>",
Scope: types.CommitmentScopeInput{
EntityType: types.CommitmentScopeTypeMeter,
},
StartDate: types.MustTimeFromString("2024-11-23T11:41:25.905Z"),
Type: types.CommitmentTypeAmount,
})
if err != nil {
log.Fatal(err)
}
if res.CommitmentResponse != nil {
// handle response
}
}{
"active_windows": [
{
"end": {
"hour": 12,
"minute": 29
},
"start": {
"hour": 12,
"minute": 29
}
}
],
"binding": true,
"collection_method": "per_period",
"commitment_status": "active",
"commitment_value": "<string>",
"committed_price_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"currency": "<string>",
"customer_id": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"environment_id": "<string>",
"id": "<string>",
"idempotency_key": "<string>",
"instalment_invoicing": "<string>",
"invoice_description": "<string>",
"invoice_label": "<string>",
"measurement": "billing_period",
"metadata": {},
"name": "<string>",
"on_early_termination": "forfeit",
"overage_price_id": "<string>",
"priority": 123,
"scope_entity_id": "<string>",
"scope_entity_type": "subscription",
"start_date": "2023-11-07T05:31:56Z",
"status": "published",
"subscription_id": "<string>",
"tenant_id": "<string>",
"terminated_at": "2023-11-07T05:31:56Z",
"termination_invoice_id": "<string>",
"timezone": "<string>",
"total_amount": "<string>",
"type": "amount",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"value": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Commitments
Preview commitment
Validates a commitment and returns its computed value without creating it.
POST
/
commitments
/
preview
cURL
curl --request POST \
--url https://us.api.flexprice.io/v1/commitments/preview \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "<string>",
"scope": {
"entity_id": "<string>"
},
"start_date": "2023-11-07T05:31:56Z",
"active_windows": [
{
"end": {
"hour": 12,
"minute": 29
},
"start": {
"hour": 12,
"minute": 29
}
}
],
"binding": true,
"committed_price": {
"amount": "<string>",
"tiers": [
{
"unit_amount": "<string>",
"flat_amount": "<string>",
"transform_quantity": {
"divide_by": 123
},
"up_to": 123
}
],
"transform_quantity": {
"divide_by": 123
}
},
"end_date": "2023-11-07T05:31:56Z",
"idempotency_key": "<string>",
"invoice_description": "<string>",
"invoice_label": "<string>",
"metadata": {},
"overage_price": {
"amount": "<string>",
"tiers": [
{
"unit_amount": "<string>",
"flat_amount": "<string>",
"transform_quantity": {
"divide_by": 123
},
"up_to": 123
}
],
"transform_quantity": {
"divide_by": 123
}
},
"priority": 123,
"subscription_id": "<string>",
"timezone": "<string>",
"value": "<string>"
}
'from flexprice import Flexprice
from flexprice.utils import parse_datetime
with Flexprice(
api_key_auth="<YOUR_API_KEY_HERE>",
) as f_client:
res = f_client.commitments.preview_commitment(measurement="billing_period", name="<value>", scope={
"entity_type": "meter",
}, start_date=parse_datetime("2024-11-23T11:41:25.905Z"), type_="amount")
# Handle response
print(res)import { Flexprice } from "@flexprice/sdk";
const flexprice = new Flexprice({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await flexprice.commitments.previewCommitment({
measurement: "billing_period",
name: "<value>",
scope: {
entityType: "meter",
},
startDate: new Date("2024-11-23T11:41:25.905Z"),
type: "amount",
});
console.log(result);
}
run();package main
import(
"context"
flexprice "github.com/flexprice/go-sdk/v2"
"github.com/flexprice/go-sdk/v2/models/types"
"github.com/flexprice/go-sdk/v2/types"
"log"
)
func main() {
ctx := context.Background()
s := flexprice.New(
flexprice.WithSecurity("<YOUR_API_KEY_HERE>"),
)
res, err := s.Commitments.PreviewCommitment(ctx, types.CreateCommitmentRequest{
Measurement: types.CommitmentMeasurementBillingPeriod,
Name: "<value>",
Scope: types.CommitmentScopeInput{
EntityType: types.CommitmentScopeTypeMeter,
},
StartDate: types.MustTimeFromString("2024-11-23T11:41:25.905Z"),
Type: types.CommitmentTypeAmount,
})
if err != nil {
log.Fatal(err)
}
if res.CommitmentResponse != nil {
// handle response
}
}{
"active_windows": [
{
"end": {
"hour": 12,
"minute": 29
},
"start": {
"hour": 12,
"minute": 29
}
}
],
"binding": true,
"collection_method": "per_period",
"commitment_status": "active",
"commitment_value": "<string>",
"committed_price_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"currency": "<string>",
"customer_id": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"environment_id": "<string>",
"id": "<string>",
"idempotency_key": "<string>",
"instalment_invoicing": "<string>",
"invoice_description": "<string>",
"invoice_label": "<string>",
"measurement": "billing_period",
"metadata": {},
"name": "<string>",
"on_early_termination": "forfeit",
"overage_price_id": "<string>",
"priority": 123,
"scope_entity_id": "<string>",
"scope_entity_type": "subscription",
"start_date": "2023-11-07T05:31:56Z",
"status": "published",
"subscription_id": "<string>",
"tenant_id": "<string>",
"terminated_at": "2023-11-07T05:31:56Z",
"termination_invoice_id": "<string>",
"timezone": "<string>",
"total_amount": "<string>",
"type": "amount",
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>",
"value": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Authorizations
Enter your API key in the format x-api-key <api-key>*
Body
application/json
Commitment
Available options:
billing_period, window Maximum string length:
255Show child attributes
Show child attributes
Available options:
amount, quantity Show child attributes
Show child attributes
default false
Available options:
per_period, billing_terms Show child attributes
Show child attributes
EndDate is exclusive; omit it for an open-ended commitment, which bills every period until terminated.
Maximum string length:
128Maximum string length:
500Maximum string length:
255Show child attributes
Show child attributes
Show child attributes
Show child attributes
SubscriptionID is required on POST /commitments and set server-side on inline commitments.
Response
OK
Show child attributes
Show child attributes
Available options:
per_period, billing_terms Available options:
active, ended, terminated EndDate is exclusive; nil for an open-ended commitment, which runs until terminated.
Available options:
billing_period, window Show child attributes
Show child attributes
Available options:
forfeit, credit_note, bill_remaining Available options:
subscription, group, meter, price Available options:
published, deleted, archived Available options:
amount, quantity 
