Skip to content

Commit ac21fbf

Browse files
authored
feat(api): add invoice V3 GET endpoint (#4541)
1 parent c16cbe1 commit ac21fbf

36 files changed

Lines changed: 7428 additions & 2746 deletions

File tree

.agents/skills/api/rules/aip-126-enums.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
Reference: https://kong-aip.netlify.app/aip/126/
44

55
- All enum wire values must be `snake_case` (enforced as an error by the `casing-aip-errors` linter rule).
6-
- Every enum must define an `unknown` member as the zero/default value.
6+
- Prefer defining an `unknown` member as the zero/default value. This is a recommendation, not a requirement — most domains (charges, subscriptions, currencies) omit it, so do not flag its absence as a violation.
77
- Prefer enums over booleans for two-state fields — this allows a third state to be added later without a breaking change.

api/spec/packages/aip-client-javascript/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ TypeSpec definitions and ships fully-typed request and response models.
2424
- [Subscriptions](#subscriptions)
2525
- [Apps](#apps)
2626
- [Billing](#billing)
27+
- [Invoices](#invoices)
2728
- [Tax](#tax)
2829
- [Currencies](#currencies)
2930
- [Features](#features)
@@ -190,6 +191,12 @@ The full call path, HTTP route, and a short description are listed below.
190191
| `client.billing.updateProfile` | `PUT /openmeter/profiles/{id}` | Update a billing profile. |
191192
| `client.billing.deleteProfile` | `DELETE /openmeter/profiles/{id}` | Delete a billing profile. Only such billing profiles can be deleted that are: - not the default profile - not pinned to any customer using customer overrides - only have finalized invoices |
192193

194+
### Invoices
195+
196+
| Method | HTTP | Description |
197+
| --------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
198+
| `client.invoices.get` | `GET /openmeter/billing/invoices/{invoiceId}` | Get a billing invoice by ID. Returns the full invoice resource including line items, status details, totals, and workflow configuration snapshot. |
199+
193200
### Tax
194201

195202
| Method | HTTP | Description |

api/spec/packages/aip-client-javascript/src/funcs/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export * from './entitlements.js'
55
export * from './subscriptions.js'
66
export * from './apps.js'
77
export * from './billing.js'
8+
export * from './invoices.js'
89
export * from './tax.js'
910
export * from './currencies.js'
1011
export * from './features.js'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { type Client, http } from '../core.js'
2+
import { type Result, type RequestOptions } from '../lib/types.js'
3+
import { request } from '../lib/request.js'
4+
import { encodePath, toURLSearchParams, encodeSort } from '../lib/encodings.js'
5+
import type {
6+
GetInvoiceRequest,
7+
GetInvoiceResponse,
8+
} from '../models/operations/invoices.js'
9+
10+
export function getInvoice(
11+
client: Client,
12+
req: GetInvoiceRequest,
13+
options?: RequestOptions,
14+
): Promise<Result<GetInvoiceResponse>> {
15+
const path = encodePath('openmeter/billing/invoices/{invoiceId}', {
16+
invoiceId: req.invoiceId,
17+
})
18+
return request(() =>
19+
http(client).get(path, options).json<GetInvoiceResponse>(),
20+
)
21+
}

api/spec/packages/aip-client-javascript/src/index.ts

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export { Entitlements } from './sdk/entitlements.js'
66
export { Subscriptions } from './sdk/subscriptions.js'
77
export { Apps } from './sdk/apps.js'
88
export { Billing } from './sdk/billing.js'
9+
export { Invoices } from './sdk/invoices.js'
910
export { Tax } from './sdk/tax.js'
1011
export { Currencies } from './sdk/currencies.js'
1112
export { Features } from './sdk/features.js'
@@ -38,6 +39,7 @@ export type * from './models/operations/entitlements.js'
3839
export type * from './models/operations/subscriptions.js'
3940
export type * from './models/operations/apps.js'
4041
export type * from './models/operations/billing.js'
42+
export type * from './models/operations/invoices.js'
4143
export type * from './models/operations/tax.js'
4244
export type * from './models/operations/currencies.js'
4345
export type * from './models/operations/features.js'
@@ -62,11 +64,15 @@ export type {
6264
CreateLabels,
6365
TaxConfigStripe,
6466
TaxConfigExternalInvoicing,
65-
FlatFeeDiscounts,
67+
ChargeFlatFeeDiscounts,
6668
PriceFree,
6769
WorkflowCollectionAlignmentSubscription,
6870
WorkflowPaymentChargeAutomaticallySettings,
6971
WorkflowPaymentSendInvoiceSettings,
72+
InvoiceExternalReferences,
73+
InvoiceAvailableActionDetails,
74+
InvoiceWorkflowInvoicingSettings,
75+
InvoiceLineExternalReferences,
7076
LlmCostProvider,
7177
LlmCostModel,
7278
RateCardStaticEntitlement,
@@ -91,6 +97,7 @@ export type {
9197
PriceUnit,
9298
RateCardDiscounts,
9399
Totals,
100+
InvoiceLineCreditsApplied,
94101
FeatureManualUnitCost,
95102
FeatureLlmUnitCostPricing,
96103
LlmCostModelPricing,
@@ -109,6 +116,7 @@ export type {
109116
SubscriptionReference,
110117
AddonReference,
111118
AppReference,
119+
ChargeReference,
112120
CurrencyFiat,
113121
FeatureReference,
114122
Event,
@@ -149,7 +157,6 @@ export type {
149157
QueryFilterStringMapItem,
150158
CustomerKeyReference,
151159
CustomerUsageAttribution,
152-
BillingAddress,
153160
Address,
154161
AppStripeCreateCheckoutSessionCustomerUpdate,
155162
AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement,
@@ -173,6 +180,11 @@ export type {
173180
TaxCodeAppMapping,
174181
PartyTaxIdentity,
175182
WorkflowInvoicingSettings,
183+
InvoiceValidationIssue,
184+
InvoiceAvailableActions,
185+
InvoiceLineAmountDiscount,
186+
InvoiceLineUsageDiscount,
187+
InvoiceLineBaseDiscount,
176188
ListCurrenciesParamsFilter,
177189
CurrencyCustom,
178190
CreateCurrencyCustomRequest,
@@ -206,6 +218,7 @@ export type {
206218
PlanAddon,
207219
CreatePlanAddonRequest,
208220
ProfileAppReferences,
221+
InvoiceWorkflowAppsReferences,
209222
ListEventsParamsFilter,
210223
ResourceFilters,
211224
FieldFilters,
@@ -220,6 +233,7 @@ export type {
220233
Customer,
221234
UpsertCustomerRequest,
222235
PartyAddresses,
236+
InvoiceCustomer,
223237
AppStripeCreateCheckoutSessionConsentCollection,
224238
ListCustomerEntitlementAccessResponseData,
225239
WorkflowCollectionAlignmentAnchored,
@@ -233,6 +247,9 @@ export type {
233247
CreateTaxCodeRequest,
234248
TaxCode,
235249
UpsertTaxCodeRequest,
250+
InvoiceWorkflow,
251+
InvoiceStatusDetails,
252+
InvoiceLineDiscounts,
236253
InvoiceUsageQuantityDetail,
237254
GovernanceFeatureAccess,
238255
CustomerData,
@@ -244,7 +261,7 @@ export type {
244261
PricePagePaginatedResponse,
245262
CreateCreditGrantRequest,
246263
CreditGrant,
247-
CreateFlatFeeChargeRequest,
264+
CreateChargeFlatFeeRequest,
248265
WorkflowTaxSettings,
249266
SubscriptionAddonPagePaginatedResponse,
250267
PlanAddonPagePaginatedResponse,
@@ -253,26 +270,32 @@ export type {
253270
MeterQueryRequest,
254271
CustomerPagePaginatedResponse,
255272
Party,
273+
Supplier,
256274
AppStripeCreateCheckoutSessionRequestOptions,
257275
TaxCodePagePaginatedResponse,
276+
InvoiceWorkflowSettings,
277+
InvoiceDetailedLine,
258278
CurrencyPagePaginatedResponse,
259279
GovernanceQueryResult,
260280
Feature,
261281
CreateFeatureRequest,
262282
UpdateFeatureRequest,
263283
CreditGrantPagePaginatedResponse,
264284
BadRequest,
285+
InvoiceBase,
265286
CustomerStripeCreateCheckoutSessionRequest,
266287
WorkflowCollectionSettings,
267288
AppPagePaginatedResponse,
268289
ProfileApps,
269290
GovernanceQueryResponse,
270-
FlatFeeCharge,
271-
UsageBasedCharge,
272-
CreateUsageBasedChargeRequest,
291+
ChargeFlatFee,
292+
ChargeUsageBased,
293+
CreateChargeUsageBasedRequest,
294+
InvoiceLineRateCard,
273295
RateCard,
274296
FeaturePagePaginatedResponse,
275297
Workflow,
298+
InvoiceStandardLine,
276299
PlanPhase,
277300
Addon,
278301
CreateAddonRequest,
@@ -286,10 +309,12 @@ export type {
286309
UpsertPlanRequest,
287310
AddonPagePaginatedResponse,
288311
ProfilePagePaginatedResponse,
312+
InvoiceStandard,
289313
PlanPagePaginatedResponse,
290314
SortQueryInput,
291315
BaseErrorInput,
292316
WorkflowPaymentSendInvoiceSettingsInput,
317+
InvoiceWorkflowInvoicingSettingsInput,
293318
EventInput,
294319
UnauthorizedInput,
295320
ForbiddenInput,
@@ -313,19 +338,23 @@ export type {
313338
GovernanceQueryRequestInput,
314339
IngestedEventInput,
315340
SubscriptionCancelInput,
341+
InvoiceWorkflowInput,
316342
InvoiceUsageQuantityDetailInput,
317343
CreateCreditGrantRequestInput,
318344
CreditGrantInput,
319345
WorkflowTaxSettingsInput,
320346
IngestedEventPaginatedResponseInput,
321347
MeterQueryRequestInput,
322348
AppStripeCreateCheckoutSessionRequestOptionsInput,
349+
InvoiceWorkflowSettingsInput,
350+
InvoiceDetailedLineInput,
323351
CreditGrantPagePaginatedResponseInput,
324352
BadRequestInput,
325353
CustomerStripeCreateCheckoutSessionRequestInput,
326354
WorkflowCollectionSettingsInput,
327355
RateCardInput,
328356
WorkflowInput,
357+
InvoiceStandardLineInput,
329358
PlanPhaseInput,
330359
AddonInput,
331360
CreateAddonRequestInput,
@@ -338,5 +367,6 @@ export type {
338367
UpsertPlanRequestInput,
339368
AddonPagePaginatedResponseInput,
340369
ProfilePagePaginatedResponseInput,
370+
InvoiceStandardInput,
341371
PlanPagePaginatedResponseInput,
342372
} from './models/types.js'

api/spec/packages/aip-client-javascript/src/models/operations/customers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import type {
55
AppStripeCreateCheckoutSessionResult,
66
AppStripeCreateCustomerPortalSessionResult,
77
ChargePagePaginatedResponse,
8+
CreateChargeFlatFeeRequest,
9+
CreateChargeUsageBasedRequest,
810
CreateCreditAdjustmentRequest as CreateCreditAdjustmentRequestBody,
911
CreateCreditGrantRequestInput,
1012
CreateCustomerRequest as CreateCustomerRequestBody,
11-
CreateFlatFeeChargeRequest,
12-
CreateUsageBasedChargeRequest,
1313
CreditAdjustment,
1414
CreditBalances,
1515
CreditGrant,
@@ -172,7 +172,7 @@ export type ListCustomerChargesResponse = ChargePagePaginatedResponse
172172

173173
export type CreateCustomerChargesRequest = {
174174
customerId: string
175-
body: CreateFlatFeeChargeRequest | CreateUsageBasedChargeRequest
175+
body: CreateChargeFlatFeeRequest | CreateChargeUsageBasedRequest
176176
}
177177
export type CreateCustomerChargesResponse = z.output<
178178
typeof schemas.createCustomerChargesResponse
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { z } from 'zod'
2+
import * as schemas from '../schemas.js'
3+
4+
export type GetInvoiceRequest = {
5+
invoiceId: string
6+
}
7+
export type GetInvoiceResponse = z.output<typeof schemas.getInvoiceResponse>

0 commit comments

Comments
 (0)