@metronome/sdk 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/bin/cli +5 -12
- package/internal/to-file.d.mts +1 -1
- package/internal/to-file.d.ts +1 -1
- package/internal/to-file.js +1 -1
- package/internal/to-file.mjs +1 -1
- package/package.json +1 -1
- package/resources/shared.d.mts +129 -5
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +129 -5
- package/resources/shared.d.ts.map +1 -1
- package/resources/v1/alerts.d.mts +68 -64
- package/resources/v1/alerts.d.mts.map +1 -1
- package/resources/v1/alerts.d.ts +68 -64
- package/resources/v1/alerts.d.ts.map +1 -1
- package/resources/v1/alerts.js +40 -39
- package/resources/v1/alerts.js.map +1 -1
- package/resources/v1/alerts.mjs +40 -39
- package/resources/v1/alerts.mjs.map +1 -1
- package/resources/v1/contracts/contracts.d.mts +28 -6
- package/resources/v1/contracts/contracts.d.mts.map +1 -1
- package/resources/v1/contracts/contracts.d.ts +28 -6
- package/resources/v1/contracts/contracts.d.ts.map +1 -1
- package/resources/v1/contracts/contracts.js +4 -3
- package/resources/v1/contracts/contracts.js.map +1 -1
- package/resources/v1/contracts/contracts.mjs +4 -3
- package/resources/v1/contracts/contracts.mjs.map +1 -1
- package/resources/v1/customers/alerts.d.mts +98 -77
- package/resources/v1/customers/alerts.d.mts.map +1 -1
- package/resources/v1/customers/alerts.d.ts +98 -77
- package/resources/v1/customers/alerts.d.ts.map +1 -1
- package/resources/v1/customers/alerts.js +65 -46
- package/resources/v1/customers/alerts.js.map +1 -1
- package/resources/v1/customers/alerts.mjs +65 -46
- package/resources/v1/customers/alerts.mjs.map +1 -1
- package/resources/v1/customers/customers.d.mts +17 -16
- package/resources/v1/customers/customers.d.mts.map +1 -1
- package/resources/v1/customers/customers.d.ts +17 -16
- package/resources/v1/customers/customers.d.ts.map +1 -1
- package/resources/v1/customers/customers.js +7 -4
- package/resources/v1/customers/customers.js.map +1 -1
- package/resources/v1/customers/customers.mjs +7 -4
- package/resources/v1/customers/customers.mjs.map +1 -1
- package/resources/v1/customers/index.d.mts +1 -1
- package/resources/v1/customers/index.d.mts.map +1 -1
- package/resources/v1/customers/index.d.ts +1 -1
- package/resources/v1/customers/index.d.ts.map +1 -1
- package/resources/v1/customers/index.js.map +1 -1
- package/resources/v1/customers/index.mjs.map +1 -1
- package/resources/v1/customers/invoices.d.mts +117 -2
- package/resources/v1/customers/invoices.d.mts.map +1 -1
- package/resources/v1/customers/invoices.d.ts +117 -2
- package/resources/v1/customers/invoices.d.ts.map +1 -1
- package/resources/v1/customers/invoices.js +49 -0
- package/resources/v1/customers/invoices.js.map +1 -1
- package/resources/v1/customers/invoices.mjs +49 -0
- package/resources/v1/customers/invoices.mjs.map +1 -1
- package/resources/v1/index.d.mts +1 -0
- package/resources/v1/index.d.mts.map +1 -1
- package/resources/v1/index.d.ts +1 -0
- package/resources/v1/index.d.ts.map +1 -1
- package/resources/v1/index.js +3 -1
- package/resources/v1/index.js.map +1 -1
- package/resources/v1/index.mjs +1 -0
- package/resources/v1/index.mjs.map +1 -1
- package/resources/v1/payments.d.mts +116 -0
- package/resources/v1/payments.d.mts.map +1 -0
- package/resources/v1/payments.d.ts +116 -0
- package/resources/v1/payments.d.ts.map +1 -0
- package/resources/v1/payments.js +71 -0
- package/resources/v1/payments.js.map +1 -0
- package/resources/v1/payments.mjs +67 -0
- package/resources/v1/payments.mjs.map +1 -0
- package/resources/v1/usage.d.mts +4 -2
- package/resources/v1/usage.d.mts.map +1 -1
- package/resources/v1/usage.d.ts +4 -2
- package/resources/v1/usage.d.ts.map +1 -1
- package/resources/v1/usage.js +4 -2
- package/resources/v1/usage.js.map +1 -1
- package/resources/v1/usage.mjs +4 -2
- package/resources/v1/usage.mjs.map +1 -1
- package/resources/v1/v1.d.mts +4 -0
- package/resources/v1/v1.d.mts.map +1 -1
- package/resources/v1/v1.d.ts +4 -0
- package/resources/v1/v1.d.ts.map +1 -1
- package/resources/v1/v1.js +4 -0
- package/resources/v1/v1.js.map +1 -1
- package/resources/v1/v1.mjs +4 -0
- package/resources/v1/v1.mjs.map +1 -1
- package/resources/v2/contracts.d.mts +109 -3
- package/resources/v2/contracts.d.mts.map +1 -1
- package/resources/v2/contracts.d.ts +109 -3
- package/resources/v2/contracts.d.ts.map +1 -1
- package/src/internal/to-file.ts +1 -1
- package/src/resources/shared.ts +160 -5
- package/src/resources/v1/alerts.ts +68 -64
- package/src/resources/v1/contracts/contracts.ts +32 -6
- package/src/resources/v1/customers/alerts.ts +98 -77
- package/src/resources/v1/customers/customers.ts +18 -15
- package/src/resources/v1/customers/index.ts +1 -0
- package/src/resources/v1/customers/invoices.ts +142 -1
- package/src/resources/v1/index.ts +11 -0
- package/src/resources/v1/payments.ts +170 -0
- package/src/resources/v1/usage.ts +4 -2
- package/src/resources/v1/v1.ts +26 -0
- package/src/resources/v2/contracts.ts +144 -3
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -7,16 +7,15 @@ import { RequestOptions } from '../../internal/request-options';
|
|
|
7
7
|
|
|
8
8
|
export class Alerts extends APIResource {
|
|
9
9
|
/**
|
|
10
|
-
* Create a new
|
|
11
|
-
* in real-time. Metronome's
|
|
12
|
-
* immediate evaluation capabilities, enabling you to
|
|
13
|
-
* accounts and prevent revenue leakage.
|
|
10
|
+
* Create a new threshold notification to monitor customer spending, balances, and
|
|
11
|
+
* billing metrics in real-time. Metronome's notification system provides
|
|
12
|
+
* industry-leading speed with immediate evaluation capabilities, enabling you to
|
|
13
|
+
* proactively manage customer accounts and prevent revenue leakage.
|
|
14
14
|
*
|
|
15
|
-
* This endpoint creates configurable
|
|
16
|
-
* billing thresholds including spend limits, credit balances,
|
|
17
|
-
* utilization, and invoice totals.
|
|
18
|
-
* customers or targeted to specific customer accounts.
|
|
19
|
-
* on certain alert types to further target alerts to groups of customers.
|
|
15
|
+
* This endpoint creates configurable threshold notifications that continuously
|
|
16
|
+
* monitor various billing thresholds including spend limits, credit balances,
|
|
17
|
+
* commitment utilization, and invoice totals. Threshold notifications can be
|
|
18
|
+
* configured globally for all customers or targeted to specific customer accounts.
|
|
20
19
|
*
|
|
21
20
|
* ### Use this endpoint to:
|
|
22
21
|
*
|
|
@@ -32,26 +31,27 @@ export class Alerts extends APIResource {
|
|
|
32
31
|
*
|
|
33
32
|
* A successful response returns a CustomerAlert object containing:
|
|
34
33
|
*
|
|
35
|
-
* - The
|
|
34
|
+
* - The threshold notification configuration with its unique ID and current status
|
|
36
35
|
* - The customer's evaluation status (ok, in_alarm, or evaluating)
|
|
37
|
-
* -
|
|
36
|
+
* - Threshold notification metadata including type, threshold values, and update
|
|
37
|
+
* timestamps
|
|
38
38
|
*
|
|
39
39
|
* ### Usage guidelines:
|
|
40
40
|
*
|
|
41
41
|
* - Immediate evaluation: Set `evaluate_on_create` : `true` (default) for instant
|
|
42
42
|
* evaluation against existing customers
|
|
43
|
-
* - Uniqueness constraints: Each
|
|
44
|
-
* your organization. Use `release_uniqueness_key` :
|
|
45
|
-
* reuse keys
|
|
46
|
-
* -
|
|
47
|
-
* `billable_metric_id` for usage
|
|
48
|
-
*
|
|
49
|
-
* - Webhook delivery:
|
|
50
|
-
* integration with your systems. Configure webhook endpoints before
|
|
51
|
-
*
|
|
52
|
-
* - Performance at scale: Metronome's event-driven architecture processes
|
|
53
|
-
* evaluations in real-time as usage events stream in,
|
|
54
|
-
* rely on periodic polling or batch evaluation cycles
|
|
43
|
+
* - Uniqueness constraints: Each threshold notification must have a unique
|
|
44
|
+
* `uniqueness_key` within your organization. Use `release_uniqueness_key` :
|
|
45
|
+
* `true` when archiving to reuse keys
|
|
46
|
+
* - Notification type requirements: Different threshold notification types require
|
|
47
|
+
* specific fields (e.g., `billable_metric_id` for usage notifications,
|
|
48
|
+
* `credit_type_id` for credit-based threshold notifications)
|
|
49
|
+
* - Webhook delivery: Threshold notifications trigger webhook notifications for
|
|
50
|
+
* real-time integration with your systems. Configure webhook endpoints before
|
|
51
|
+
* creating threshold notifications
|
|
52
|
+
* - Performance at scale: Metronome's event-driven architecture processes
|
|
53
|
+
* threshold notification evaluations in real-time as usage events stream in,
|
|
54
|
+
* unlike competitors who rely on periodic polling or batch evaluation cycles
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
57
|
* ```ts
|
|
@@ -70,33 +70,34 @@ export class Alerts extends APIResource {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Permanently disable
|
|
74
|
-
* customers. Archived
|
|
75
|
-
* release their uniqueness key for reuse
|
|
73
|
+
* Permanently disable a threshold notification and remove it from active
|
|
74
|
+
* monitoring across all customers. Archived threshold notifications stop
|
|
75
|
+
* evaluating immediately and can optionally release their uniqueness key for reuse
|
|
76
|
+
* in future threshold notification configurations.
|
|
76
77
|
*
|
|
77
78
|
* ### Use this endpoint to:
|
|
78
79
|
*
|
|
79
|
-
* - Decommission
|
|
80
|
-
* - Clean up test or deprecated
|
|
81
|
-
* - Free up uniqueness keys for reuse with new
|
|
82
|
-
* - Stop
|
|
80
|
+
* - Decommission threshold notifications that are no longer needed
|
|
81
|
+
* - Clean up test or deprecated threshold notification configurations
|
|
82
|
+
* - Free up uniqueness keys for reuse with new threshold notifications
|
|
83
|
+
* - Stop threshold notification evaluations without losing historical
|
|
84
|
+
* configuration data
|
|
83
85
|
* - Disable outdated monitoring rules during pricing model transitions
|
|
84
86
|
*
|
|
85
87
|
* ### Key response fields:
|
|
86
88
|
*
|
|
87
|
-
* - data: Object containing the archived
|
|
88
|
-
* - Alert evaluation stops immediately for all affected customers
|
|
89
|
-
* - Historical alert data and configurations remain accessible for audit purposes
|
|
89
|
+
* - data: Object containing the archived threshold notification's ID
|
|
90
90
|
*
|
|
91
91
|
* ### Usage guidelines:
|
|
92
92
|
*
|
|
93
|
-
* - Irreversible for evaluation: Archived
|
|
94
|
-
* new
|
|
93
|
+
* - Irreversible for evaluation: Archived threshold notifications cannot be
|
|
94
|
+
* re-enabled; create a new threshold notification to resume monitoring
|
|
95
95
|
* - Uniqueness key handling: Set `release_uniqueness_key` : `true` to reuse the
|
|
96
|
-
* key in future
|
|
97
|
-
* - Immediate effect:
|
|
98
|
-
*
|
|
99
|
-
*
|
|
96
|
+
* key in future threshold notifications
|
|
97
|
+
* - Immediate effect: Threshold notification evaluation stops instantly across all
|
|
98
|
+
* customers
|
|
99
|
+
* - Historical preservation: Archive operation maintains threshold notification
|
|
100
|
+
* history and configuration for compliance and auditing
|
|
100
101
|
*
|
|
101
102
|
* @example
|
|
102
103
|
* ```ts
|
|
@@ -120,7 +121,7 @@ export interface AlertArchiveResponse {
|
|
|
120
121
|
|
|
121
122
|
export interface AlertCreateParams {
|
|
122
123
|
/**
|
|
123
|
-
* Type of the
|
|
124
|
+
* Type of the threshold notification
|
|
124
125
|
*/
|
|
125
126
|
alert_type:
|
|
126
127
|
| 'low_credit_balance_reached'
|
|
@@ -139,70 +140,72 @@ export interface AlertCreateParams {
|
|
|
139
140
|
| 'invoice_total_reached';
|
|
140
141
|
|
|
141
142
|
/**
|
|
142
|
-
* Name of the
|
|
143
|
+
* Name of the threshold notification
|
|
143
144
|
*/
|
|
144
145
|
name: string;
|
|
145
146
|
|
|
146
147
|
/**
|
|
147
|
-
* Threshold value of the
|
|
148
|
-
* may represent a financial amount, the days remaining, or a
|
|
148
|
+
* Threshold value of the notification policy. Depending upon the notification
|
|
149
|
+
* type, this number may represent a financial amount, the days remaining, or a
|
|
150
|
+
* percentage reached.
|
|
149
151
|
*/
|
|
150
152
|
threshold: number;
|
|
151
153
|
|
|
152
154
|
/**
|
|
153
|
-
* For
|
|
154
|
-
* track the usage for.
|
|
155
|
+
* For threshold notifications of type `usage_threshold_reached`, specifies which
|
|
156
|
+
* billable metric to track the usage for.
|
|
155
157
|
*/
|
|
156
158
|
billable_metric_id?: string;
|
|
157
159
|
|
|
158
160
|
/**
|
|
159
|
-
* An array of strings, representing a way to filter the credit grant this
|
|
160
|
-
* applies to, by looking at the credit_grant_type field on
|
|
161
|
-
* field is only defined for CreditPercentage and
|
|
161
|
+
* An array of strings, representing a way to filter the credit grant this
|
|
162
|
+
* threshold notification applies to, by looking at the credit_grant_type field on
|
|
163
|
+
* the credit grant. This field is only defined for CreditPercentage and
|
|
164
|
+
* CreditBalance notifications
|
|
162
165
|
*/
|
|
163
166
|
credit_grant_type_filters?: Array<string>;
|
|
164
167
|
|
|
165
168
|
/**
|
|
166
|
-
* ID of the credit's currency, defaults to USD. If the specific
|
|
169
|
+
* ID of the credit's currency, defaults to USD. If the specific notification type
|
|
167
170
|
* requires a pricing unit/currency, find the ID in the
|
|
168
171
|
* [Metronome app](https://app.metronome.com/offering/pricing-units).
|
|
169
172
|
*/
|
|
170
173
|
credit_type_id?: string;
|
|
171
174
|
|
|
172
175
|
/**
|
|
173
|
-
* A list of custom field filters for
|
|
174
|
-
* Only present for contract invoices.
|
|
176
|
+
* A list of custom field filters for threshold notification types that support
|
|
177
|
+
* advanced filtering. Only present for contract invoices.
|
|
175
178
|
*/
|
|
176
179
|
custom_field_filters?: Array<AlertCreateParams.CustomFieldFilter>;
|
|
177
180
|
|
|
178
181
|
/**
|
|
179
|
-
* If provided, will create this
|
|
180
|
-
*
|
|
182
|
+
* If provided, will create this threshold notification for this specific customer.
|
|
183
|
+
* To create a notification for all customers, do not specify a `customer_id`.
|
|
181
184
|
*/
|
|
182
185
|
customer_id?: string;
|
|
183
186
|
|
|
184
187
|
/**
|
|
185
|
-
* If true, the
|
|
186
|
-
*
|
|
187
|
-
* trigger the
|
|
188
|
+
* If true, the threshold notification will evaluate immediately on customers that
|
|
189
|
+
* already meet the notification threshold. If false, it will only evaluate on
|
|
190
|
+
* future customers that trigger the threshold. Defaults to true.
|
|
188
191
|
*/
|
|
189
192
|
evaluate_on_create?: boolean;
|
|
190
193
|
|
|
191
194
|
/**
|
|
192
|
-
* Only present for `spend_threshold_reached`
|
|
193
|
-
* group key on individual line items.
|
|
195
|
+
* Only present for `spend_threshold_reached` notifications. Scope notification to
|
|
196
|
+
* a specific group key on individual line items.
|
|
194
197
|
*/
|
|
195
198
|
group_values?: Array<AlertCreateParams.GroupValue>;
|
|
196
199
|
|
|
197
200
|
/**
|
|
198
|
-
* Only supported for invoice_total_reached
|
|
199
|
-
* evaluate.
|
|
201
|
+
* Only supported for invoice_total_reached threshold notifications. A list of
|
|
202
|
+
* invoice types to evaluate.
|
|
200
203
|
*/
|
|
201
204
|
invoice_types_filter?: Array<string>;
|
|
202
205
|
|
|
203
206
|
/**
|
|
204
|
-
* If provided, will create this
|
|
205
|
-
* for all customers, do not specify a `plan_id`.
|
|
207
|
+
* If provided, will create this threshold notification for this specific plan. To
|
|
208
|
+
* create a notification for all customers, do not specify a `plan_id`.
|
|
206
209
|
*/
|
|
207
210
|
plan_id?: string;
|
|
208
211
|
|
|
@@ -232,12 +235,13 @@ export namespace AlertCreateParams {
|
|
|
232
235
|
|
|
233
236
|
export interface AlertArchiveParams {
|
|
234
237
|
/**
|
|
235
|
-
* The Metronome ID of the
|
|
238
|
+
* The Metronome ID of the threshold notification
|
|
236
239
|
*/
|
|
237
240
|
id: string;
|
|
238
241
|
|
|
239
242
|
/**
|
|
240
|
-
* If true, resets the uniqueness key on this
|
|
243
|
+
* If true, resets the uniqueness key on this threshold notification so it can be
|
|
244
|
+
* re-used
|
|
241
245
|
*/
|
|
242
246
|
release_uniqueness_key?: boolean;
|
|
243
247
|
}
|
|
@@ -574,11 +574,12 @@ export class Contracts extends APIResource {
|
|
|
574
574
|
}
|
|
575
575
|
|
|
576
576
|
/**
|
|
577
|
-
* Update or
|
|
577
|
+
* Update or add an end date to a contract. Ending a contract early will impact
|
|
578
578
|
* draft usage statements, truncate any terms, and remove upcoming scheduled
|
|
579
579
|
* invoices. Moving the date into the future will only extend the contract length.
|
|
580
|
-
* Terms and scheduled invoices are not extended.
|
|
581
|
-
* has changed or if a perpetual
|
|
580
|
+
* Terms and scheduled invoices are not extended. In-advance subscriptions will not
|
|
581
|
+
* be extended. Use this if a contract's end date has changed or if a perpetual
|
|
582
|
+
* contract ends.
|
|
582
583
|
*
|
|
583
584
|
* @example
|
|
584
585
|
* ```ts
|
|
@@ -1117,7 +1118,7 @@ export namespace ContractCreateParams {
|
|
|
1117
1118
|
* not wish Metronome to calculate tax on your behalf. Leaving this field blank
|
|
1118
1119
|
* will default to NONE.
|
|
1119
1120
|
*/
|
|
1120
|
-
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED';
|
|
1121
|
+
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'AVALARA' | 'PRECALCULATED';
|
|
1121
1122
|
}
|
|
1122
1123
|
|
|
1123
1124
|
export namespace PaymentGateConfig {
|
|
@@ -1387,7 +1388,22 @@ export namespace ContractCreateParams {
|
|
|
1387
1388
|
}
|
|
1388
1389
|
|
|
1389
1390
|
export interface HierarchyConfiguration {
|
|
1390
|
-
parent
|
|
1391
|
+
parent?: HierarchyConfiguration.Parent;
|
|
1392
|
+
|
|
1393
|
+
parent_behavior?: HierarchyConfiguration.ParentBehavior;
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* Indicates whether the parent should pay for the child's invoice charges
|
|
1397
|
+
*/
|
|
1398
|
+
payer?: 'SELF' | 'PARENT';
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Indicates the behavior of the child's invoice statements on the parent's
|
|
1402
|
+
* invoices **CONSOLIDATE**: Child's invoice statements will be added to parent's
|
|
1403
|
+
* consolidated invoices **SEPARATE**: Child's invoice statements will appear not
|
|
1404
|
+
* appear on parent's consolidated invoices
|
|
1405
|
+
*/
|
|
1406
|
+
usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE';
|
|
1391
1407
|
}
|
|
1392
1408
|
|
|
1393
1409
|
export namespace HierarchyConfiguration {
|
|
@@ -1396,6 +1412,16 @@ export namespace ContractCreateParams {
|
|
|
1396
1412
|
|
|
1397
1413
|
customer_id: string;
|
|
1398
1414
|
}
|
|
1415
|
+
|
|
1416
|
+
export interface ParentBehavior {
|
|
1417
|
+
/**
|
|
1418
|
+
* Indicates the desired behavior of consolidated invoices generated by the parent
|
|
1419
|
+
* in a customer hierarchy **CONCATENATE**: Statements on the invoices of child
|
|
1420
|
+
* customers will be appended to the consolidated invoice **NONE**: Do not generate
|
|
1421
|
+
* consolidated invoices
|
|
1422
|
+
*/
|
|
1423
|
+
invoice_consolidation_type?: 'CONCATENATE' | 'NONE';
|
|
1424
|
+
}
|
|
1399
1425
|
}
|
|
1400
1426
|
|
|
1401
1427
|
export interface Override {
|
|
@@ -2648,7 +2674,7 @@ export namespace ContractAmendParams {
|
|
|
2648
2674
|
* not wish Metronome to calculate tax on your behalf. Leaving this field blank
|
|
2649
2675
|
* will default to NONE.
|
|
2650
2676
|
*/
|
|
2651
|
-
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED';
|
|
2677
|
+
tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'AVALARA' | 'PRECALCULATED';
|
|
2652
2678
|
}
|
|
2653
2679
|
|
|
2654
2680
|
export namespace PaymentGateConfig {
|
|
@@ -13,17 +13,26 @@ import { RequestOptions } from '../../../internal/request-options';
|
|
|
13
13
|
|
|
14
14
|
export class Alerts extends APIResource {
|
|
15
15
|
/**
|
|
16
|
-
* Retrieve the real-time evaluation status for a specific
|
|
17
|
-
* This endpoint provides instant visibility into
|
|
18
|
-
*
|
|
19
|
-
* action based on current
|
|
16
|
+
* Retrieve the real-time evaluation status for a specific threshold
|
|
17
|
+
* notification-customer pair. This endpoint provides instant visibility into
|
|
18
|
+
* whether a customer has triggered a threshold notification condition, enabling
|
|
19
|
+
* you to monitor account health and take proactive action based on current
|
|
20
|
+
* threshold notification states.
|
|
20
21
|
*
|
|
21
22
|
* ### Use this endpoint to:
|
|
22
23
|
*
|
|
23
|
-
* - Check if a specific customer is currently violating an
|
|
24
|
+
* - Check if a specific customer is currently violating an threshold notification
|
|
24
25
|
* (`in_alarm` status)
|
|
25
|
-
* - Verify
|
|
26
|
-
*
|
|
26
|
+
* - Verify threshold notification configuration details and threshold values for a
|
|
27
|
+
* customer
|
|
28
|
+
* - Monitor the evaluation state of newly created or recently modified threshold
|
|
29
|
+
* notification
|
|
30
|
+
* - Build dashboards or automated workflows that respond to specific threshold
|
|
31
|
+
* notification conditions
|
|
32
|
+
* - Validate threshold notification behavior before deploying to production
|
|
33
|
+
* customers
|
|
34
|
+
* - Integrate threshold notification status checks into customer support tools or
|
|
35
|
+
* admin interfaces
|
|
27
36
|
*
|
|
28
37
|
* ### Key response fields:
|
|
29
38
|
*
|
|
@@ -32,29 +41,32 @@ export class Alerts extends APIResource {
|
|
|
32
41
|
* - `customer_status`: The current evaluation state
|
|
33
42
|
*
|
|
34
43
|
* - `ok` - Customer is within acceptable thresholds
|
|
35
|
-
* - `in_alarm
|
|
36
|
-
* - `evaluating` -
|
|
37
|
-
*
|
|
38
|
-
* - `null` -
|
|
39
|
-
* - `triggered_by`: Additional context about what caused the
|
|
40
|
-
* (when applicable)
|
|
41
|
-
* - alert: Complete
|
|
42
|
-
* -
|
|
44
|
+
* - `in_alarm` - Customer has breached the threshold for the notification
|
|
45
|
+
* - `evaluating` - Notification is currently being evaluated (typically during
|
|
46
|
+
* initial setup)
|
|
47
|
+
* - `null` - Notification has been archived
|
|
48
|
+
* - `triggered_by`: Additional context about what caused the notification to
|
|
49
|
+
* trigger (when applicable)
|
|
50
|
+
* - alert: Complete threshold notification configuration including:
|
|
51
|
+
* - Notification ID, name, and type
|
|
43
52
|
* - Current threshold values and credit type information
|
|
44
|
-
* -
|
|
53
|
+
* - Notification status (enabled, disabled, or archived)
|
|
45
54
|
* - Last update timestamp
|
|
46
55
|
* - Any applied filters (credit grant types, custom fields, group values)
|
|
47
56
|
*
|
|
48
57
|
* ### Usage guidelines:
|
|
49
58
|
*
|
|
50
59
|
* - Customer status: Returns the current evaluation state, not historical data.
|
|
51
|
-
* For
|
|
52
|
-
* -
|
|
53
|
-
*
|
|
54
|
-
* -
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
60
|
+
* For threshold notification history, use webhook notifications or event logs
|
|
61
|
+
* - Required parameters: Both customer_id and alert_id must be valid UUIDs that
|
|
62
|
+
* exist in your organization
|
|
63
|
+
* - Archived notifications: Returns null for customer_status if the notification
|
|
64
|
+
* has been archived, but still includes the notification configuration details
|
|
65
|
+
* - Performance considerations: This endpoint queries live evaluation state,
|
|
66
|
+
* making it ideal for real-time monitoring but not for bulk status checks
|
|
67
|
+
* - Integration patterns: Best used for on-demand status checks in response to
|
|
68
|
+
* user actions or as part of targeted monitoring workflows
|
|
69
|
+
* - Error handling: Returns 404 if either the customer or alert_id doesn't exist
|
|
58
70
|
* or isn't accessible to your organization
|
|
59
71
|
*
|
|
60
72
|
* @example
|
|
@@ -70,31 +82,37 @@ export class Alerts extends APIResource {
|
|
|
70
82
|
}
|
|
71
83
|
|
|
72
84
|
/**
|
|
73
|
-
* Retrieve all
|
|
74
|
-
* customer in a single API call. This endpoint provides a
|
|
75
|
-
* all
|
|
85
|
+
* Retrieve all threshold notification configurations and their current statuses
|
|
86
|
+
* for a specific customer in a single API call. This endpoint provides a
|
|
87
|
+
* comprehensive view of all threshold notification monitoring a customer account.
|
|
76
88
|
*
|
|
77
89
|
* ### Use this endpoint to:
|
|
78
90
|
*
|
|
79
|
-
* - Display all active
|
|
80
|
-
*
|
|
81
|
-
* -
|
|
82
|
-
*
|
|
91
|
+
* - Display all active threshold notifications for a customer in dashboards or
|
|
92
|
+
* admin panels
|
|
93
|
+
* - Quickly identify which threshold notifications a customer is currently
|
|
94
|
+
* triggering
|
|
95
|
+
* - Audit threshold notification coverage for specific accounts
|
|
96
|
+
* - Filter threshold notifications by status (enabled, disabled, or archived)
|
|
83
97
|
*
|
|
84
98
|
* ### Key response fields:
|
|
85
99
|
*
|
|
86
100
|
* - data: Array of CustomerAlert objects, each containing:
|
|
87
101
|
* - Current evaluation status (`ok`, `in_alarm`, `evaluating`, or `null`)
|
|
88
|
-
* - Complete
|
|
89
|
-
* -
|
|
90
|
-
* -
|
|
102
|
+
* - Complete threshold notification configuration and threshold details
|
|
103
|
+
* - Threshold notification metadata including type, name, and last update time
|
|
104
|
+
* - next_page: Pagination cursor for retrieving additional results
|
|
91
105
|
*
|
|
92
106
|
* ### Usage guidelines:
|
|
93
107
|
*
|
|
94
|
-
* - Default behavior: Returns only enabled
|
|
95
|
-
* specified
|
|
108
|
+
* - Default behavior: Returns only enabled threshold notifications unless
|
|
109
|
+
* `alert_statuses` filter is specified
|
|
96
110
|
* - Pagination: Use the `next_page` cursor to retrieve all results for customers
|
|
97
|
-
* with many
|
|
111
|
+
* with many notifications
|
|
112
|
+
* - Performance: Efficiently retrieves multiple threshold notification statuses in
|
|
113
|
+
* a single request instead of making individual calls
|
|
114
|
+
* - Filtering: Pass the `alert_statuses` array to include disabled or archived
|
|
115
|
+
* threshold notifications in results
|
|
98
116
|
*
|
|
99
117
|
* @example
|
|
100
118
|
* ```ts
|
|
@@ -120,23 +138,24 @@ export class Alerts extends APIResource {
|
|
|
120
138
|
}
|
|
121
139
|
|
|
122
140
|
/**
|
|
123
|
-
* Force an immediate re-evaluation of a specific
|
|
124
|
-
* any previous state and triggering a fresh assessment against
|
|
125
|
-
* This endpoint ensures
|
|
126
|
-
* corrections.
|
|
141
|
+
* Force an immediate re-evaluation of a specific threshold notification for a
|
|
142
|
+
* customer, clearing any previous state and triggering a fresh assessment against
|
|
143
|
+
* current thresholds. This endpoint ensures threshold notification accuracy after
|
|
144
|
+
* configuration changes or data corrections.
|
|
127
145
|
*
|
|
128
146
|
* ### Use this endpoint to:
|
|
129
147
|
*
|
|
130
|
-
* - Clear false positive
|
|
131
|
-
* - Re-evaluate
|
|
132
|
-
*
|
|
133
|
-
* -
|
|
148
|
+
* - Clear false positive threshold notifications after fixing data issues
|
|
149
|
+
* - Re-evaluate threshold notifications after adjusting customer balances or
|
|
150
|
+
* credits
|
|
151
|
+
* - Test threshold notification behavior during development and debugging
|
|
152
|
+
* - Resolve stuck threshold notification that may be in an incorrect state
|
|
134
153
|
* - Trigger immediate evaluation after threshold modifications
|
|
135
154
|
*
|
|
136
155
|
* ### Key response fields:
|
|
137
156
|
*
|
|
138
|
-
* - 200 Success: Confirmation that the
|
|
139
|
-
* initiated
|
|
157
|
+
* - 200 Success: Confirmation that the threshold notification has been reset and
|
|
158
|
+
* re-evaluation initiated
|
|
140
159
|
* - No response body is returned - the operation completes asynchronously
|
|
141
160
|
*
|
|
142
161
|
* ### Usage guidelines:
|
|
@@ -172,13 +191,13 @@ export interface CustomerAlert {
|
|
|
172
191
|
alert: CustomerAlert.Alert;
|
|
173
192
|
|
|
174
193
|
/**
|
|
175
|
-
* The status of the
|
|
176
|
-
* returned.
|
|
194
|
+
* The status of the threshold notification. If the notification is archived, null
|
|
195
|
+
* will be returned.
|
|
177
196
|
*/
|
|
178
197
|
customer_status: 'ok' | 'in_alarm' | 'evaluating' | null;
|
|
179
198
|
|
|
180
199
|
/**
|
|
181
|
-
* If present, indicates the reason the
|
|
200
|
+
* If present, indicates the reason the threshold notification was triggered.
|
|
182
201
|
*/
|
|
183
202
|
triggered_by?: string | null;
|
|
184
203
|
}
|
|
@@ -186,27 +205,27 @@ export interface CustomerAlert {
|
|
|
186
205
|
export namespace CustomerAlert {
|
|
187
206
|
export interface Alert {
|
|
188
207
|
/**
|
|
189
|
-
* the Metronome ID of the
|
|
208
|
+
* the Metronome ID of the threshold notification
|
|
190
209
|
*/
|
|
191
210
|
id: string;
|
|
192
211
|
|
|
193
212
|
/**
|
|
194
|
-
* Name of the
|
|
213
|
+
* Name of the threshold notification
|
|
195
214
|
*/
|
|
196
215
|
name: string;
|
|
197
216
|
|
|
198
217
|
/**
|
|
199
|
-
* Status of the
|
|
218
|
+
* Status of the threshold notification
|
|
200
219
|
*/
|
|
201
220
|
status: 'enabled' | 'archived' | 'disabled';
|
|
202
221
|
|
|
203
222
|
/**
|
|
204
|
-
* Threshold value of the
|
|
223
|
+
* Threshold value of the notification policy
|
|
205
224
|
*/
|
|
206
225
|
threshold: number;
|
|
207
226
|
|
|
208
227
|
/**
|
|
209
|
-
* Type of the
|
|
228
|
+
* Type of the threshold notification
|
|
210
229
|
*/
|
|
211
230
|
type:
|
|
212
231
|
| 'low_credit_balance_reached'
|
|
@@ -225,39 +244,41 @@ export namespace CustomerAlert {
|
|
|
225
244
|
| 'invoice_total_reached';
|
|
226
245
|
|
|
227
246
|
/**
|
|
228
|
-
* Timestamp for when the
|
|
247
|
+
* Timestamp for when the threshold notification was last updated
|
|
229
248
|
*/
|
|
230
249
|
updated_at: string;
|
|
231
250
|
|
|
232
251
|
/**
|
|
233
|
-
* An array of strings, representing a way to filter the credit grant this
|
|
234
|
-
* applies to, by looking at the credit_grant_type field on
|
|
235
|
-
* field is only defined for CreditPercentage and
|
|
252
|
+
* An array of strings, representing a way to filter the credit grant this
|
|
253
|
+
* threshold notification applies to, by looking at the credit_grant_type field on
|
|
254
|
+
* the credit grant. This field is only defined for CreditPercentage and
|
|
255
|
+
* CreditBalance notifications
|
|
236
256
|
*/
|
|
237
257
|
credit_grant_type_filters?: Array<string>;
|
|
238
258
|
|
|
239
259
|
credit_type?: Shared.CreditTypeData | null;
|
|
240
260
|
|
|
241
261
|
/**
|
|
242
|
-
* A list of custom field filters for
|
|
262
|
+
* A list of custom field filters for notification types that support advanced
|
|
263
|
+
* filtering
|
|
243
264
|
*/
|
|
244
265
|
custom_field_filters?: Array<Alert.CustomFieldFilter>;
|
|
245
266
|
|
|
246
267
|
/**
|
|
247
|
-
* Scopes
|
|
248
|
-
* items. Only present for spend
|
|
268
|
+
* Scopes threshold notification evaluation to a specific presentation group key on
|
|
269
|
+
* individual line items. Only present for spend notifications.
|
|
249
270
|
*/
|
|
250
271
|
group_key_filter?: Alert.GroupKeyFilter;
|
|
251
272
|
|
|
252
273
|
/**
|
|
253
|
-
* Only present for `spend_threshold_reached`
|
|
254
|
-
* group key on individual line items.
|
|
274
|
+
* Only present for `spend_threshold_reached` notifications. Scope notification to
|
|
275
|
+
* a specific group key on individual line items.
|
|
255
276
|
*/
|
|
256
277
|
group_values?: Array<Alert.GroupValue>;
|
|
257
278
|
|
|
258
279
|
/**
|
|
259
|
-
* Only supported for invoice_total_reached
|
|
260
|
-
* evaluate.
|
|
280
|
+
* Only supported for invoice_total_reached threshold notifications. A list of
|
|
281
|
+
* invoice types to evaluate.
|
|
261
282
|
*/
|
|
262
283
|
invoice_types_filter?: Array<string>;
|
|
263
284
|
|
|
@@ -279,8 +300,8 @@ export namespace CustomerAlert {
|
|
|
279
300
|
}
|
|
280
301
|
|
|
281
302
|
/**
|
|
282
|
-
* Scopes
|
|
283
|
-
* items. Only present for spend
|
|
303
|
+
* Scopes threshold notification evaluation to a specific presentation group key on
|
|
304
|
+
* individual line items. Only present for spend notifications.
|
|
284
305
|
*/
|
|
285
306
|
export interface GroupKeyFilter {
|
|
286
307
|
key: string;
|
|
@@ -302,7 +323,7 @@ export interface AlertRetrieveResponse {
|
|
|
302
323
|
|
|
303
324
|
export interface AlertRetrieveParams {
|
|
304
325
|
/**
|
|
305
|
-
* The Metronome ID of the
|
|
326
|
+
* The Metronome ID of the threshold notification
|
|
306
327
|
*/
|
|
307
328
|
alert_id: string;
|
|
308
329
|
|
|
@@ -312,22 +333,22 @@ export interface AlertRetrieveParams {
|
|
|
312
333
|
customer_id: string;
|
|
313
334
|
|
|
314
335
|
/**
|
|
315
|
-
* Only present for `spend_threshold_reached`
|
|
316
|
-
* specific group key-value pair.
|
|
336
|
+
* Only present for `spend_threshold_reached` notifications. Retrieve the
|
|
337
|
+
* notification for a specific group key-value pair.
|
|
317
338
|
*/
|
|
318
339
|
group_values?: Array<AlertRetrieveParams.GroupValue>;
|
|
319
340
|
|
|
320
341
|
/**
|
|
321
|
-
* When parallel
|
|
322
|
-
* fetch
|
|
342
|
+
* When parallel threshold notifications are enabled during migration, this flag
|
|
343
|
+
* denotes whether to fetch notifications for plans or contracts.
|
|
323
344
|
*/
|
|
324
345
|
plans_or_contracts?: 'PLANS' | 'CONTRACTS';
|
|
325
346
|
}
|
|
326
347
|
|
|
327
348
|
export namespace AlertRetrieveParams {
|
|
328
349
|
/**
|
|
329
|
-
* Scopes
|
|
330
|
-
* items. Only present for spend
|
|
350
|
+
* Scopes threshold notification evaluation to a specific presentation group key on
|
|
351
|
+
* individual line items. Only present for spend notifications.
|
|
331
352
|
*/
|
|
332
353
|
export interface GroupValue {
|
|
333
354
|
key: string;
|
|
@@ -343,15 +364,15 @@ export interface AlertListParams extends CursorPageWithoutLimitParams {
|
|
|
343
364
|
customer_id: string;
|
|
344
365
|
|
|
345
366
|
/**
|
|
346
|
-
* Body param: Optionally filter by
|
|
347
|
-
* will be returned.
|
|
367
|
+
* Body param: Optionally filter by threshold notification status. If absent, only
|
|
368
|
+
* enabled notifications will be returned.
|
|
348
369
|
*/
|
|
349
370
|
alert_statuses?: Array<'ENABLED' | 'DISABLED' | 'ARCHIVED'>;
|
|
350
371
|
}
|
|
351
372
|
|
|
352
373
|
export interface AlertResetParams {
|
|
353
374
|
/**
|
|
354
|
-
* The Metronome ID of the
|
|
375
|
+
* The Metronome ID of the threshold notification
|
|
355
376
|
*/
|
|
356
377
|
alert_id: string;
|
|
357
378
|
|