diff --git a/apps/docs/api-reference-generator/core/batchTrack.mdx b/apps/docs/api-reference-generator/core/batchTrack.mdx index 7407f69ed..627300b33 100644 --- a/apps/docs/api-reference-generator/core/batchTrack.mdx +++ b/apps/docs/api-reference-generator/core/batchTrack.mdx @@ -1,6 +1,6 @@ --- title: "Batch Track Usage" -openapi: "openapi POST /v1/balances.batchTrack" +openapi: "openapi POST /v1/balances.batch_track" --- import { DynamicParamField } from "/snippets/dynamic-param-field.jsx"; diff --git a/apps/docs/mintlify/api-reference/core/batchTrack.mdx b/apps/docs/mintlify/api-reference/core/batchTrack.mdx index 7407f69ed..627300b33 100644 --- a/apps/docs/mintlify/api-reference/core/batchTrack.mdx +++ b/apps/docs/mintlify/api-reference/core/batchTrack.mdx @@ -1,6 +1,6 @@ --- title: "Batch Track Usage" -openapi: "openapi POST /v1/balances.batchTrack" +openapi: "openapi POST /v1/balances.batch_track" --- import { DynamicParamField } from "/snippets/dynamic-param-field.jsx"; diff --git a/apps/docs/mintlify/api/openapi.yml b/apps/docs/mintlify/api/openapi.yml index 2c5ae25de..47cdf1f67 100644 --- a/apps/docs/mintlify/api/openapi.yml +++ b/apps/docs/mintlify/api/openapi.yml @@ -16399,7 +16399,7 @@ paths: feature_id="messages", value=1, ) - /v1/balances.batchTrack: + /v1/balances.batch_track: post: operationId: batchTrack description: >- @@ -16492,7 +16492,7 @@ paths: ]); - lang: curl source: |- - curl -X POST https://api.useautumn.com/v1/balances.batchTrack \ + curl -X POST https://api.useautumn.com/v1/balances.batch_track \ -H 'Authorization: Bearer ' \ -H 'Content-Type: application/json' \ -d '[ diff --git a/apps/docs/mintlify/changelog/changelog.mdx b/apps/docs/mintlify/changelog/changelog.mdx index 007dbc999..302d6381d 100644 --- a/apps/docs/mintlify/changelog/changelog.mdx +++ b/apps/docs/mintlify/changelog/changelog.mdx @@ -9,7 +9,7 @@ description: "Some new things we've shipped at Autumn HQ" Two new ways to record usage when you don't need an immediate balance read: - - [`POST /v1/balances.batchTrack`](/api-reference/core/batchTrack) — enqueue up to **1000 usage events** in one request. Returns 202 immediately; balances are deducted by background workers. + - [`POST /v1/balances.batch_track`](/api-reference/core/batchTrack) — enqueue up to **1000 usage events** in one request. Returns 202 immediately; balances are deducted by background workers. - **`async: true`** on the existing [`POST /v1/balances.track`](/api-reference/core/track) — same fire-and-forget shape for single-event callers that want the speed without switching to the batch endpoint. Both paths are intended for high-volume metering (event logging, per-action usage counters) where you'd previously be limited by the synchronous deduction's HTTP round-trip. Partial enqueue failures are logged server-side and do NOT surface as errors to the client — see the [batch track reference](/api-reference/core/batchTrack#partial-failure-semantics) for the trade-off. diff --git a/packages/openapi/v2.3/contracts/balancesContract.ts b/packages/openapi/v2.3/contracts/balancesContract.ts index c6daf799b..4aa8b0f35 100644 --- a/packages/openapi/v2.3/contracts/balancesContract.ts +++ b/packages/openapi/v2.3/contracts/balancesContract.ts @@ -160,7 +160,7 @@ export const balancesTrackContract = oc export const balancesBatchTrackContract = oc .route({ method: "POST", - path: "/v1/balances.batchTrack", + path: "/v1/balances.batch_track", operationId: "batchTrack", description: "Track multiple usage events asynchronously.", spec: (spec) => diff --git a/server/src/internal/balances/balancesRouter.ts b/server/src/internal/balances/balancesRouter.ts index 474837903..26e949eec 100644 --- a/server/src/internal/balances/balancesRouter.ts +++ b/server/src/internal/balances/balancesRouter.ts @@ -34,6 +34,6 @@ balancesRpcRouter.post("/balances.update", ...handleUpdateBalance); balancesRpcRouter.post("/balances.delete", ...handleDeleteBalance); balancesRpcRouter.post("/balances.track", ...handleTrack); -balancesRpcRouter.post("/balances.batchTrack", ...handleBatchTrack); +balancesRpcRouter.post("/balances.batch_track", ...handleBatchTrack); balancesRpcRouter.post("/balances.check", ...handleCheck); balancesRpcRouter.post("/balances.finalize", ...handleFinalizeLock); diff --git a/server/src/internal/misc/rateLimiter/rateLimitConfigs.ts b/server/src/internal/misc/rateLimiter/rateLimitConfigs.ts index 5ee9c86fb..77b636943 100644 --- a/server/src/internal/misc/rateLimiter/rateLimitConfigs.ts +++ b/server/src/internal/misc/rateLimiter/rateLimitConfigs.ts @@ -88,7 +88,7 @@ const RATE_LIMIT_ROUTE_GROUPS: RateLimitRouteGroup[] = [ }, { type: RateLimitType.BatchTrack, - patterns: [route({ method: "POST", url: "/v1/balances.batchTrack" })], + patterns: [route({ method: "POST", url: "/v1/balances.batch_track" })], }, { type: RateLimitType.Check, diff --git a/server/tests/integration/balances/batch-track/batch-track-contract.test.ts b/server/tests/integration/balances/batch-track/batch-track-contract.test.ts index 5af622398..1cadeb5e4 100644 --- a/server/tests/integration/balances/batch-track/batch-track-contract.test.ts +++ b/server/tests/integration/balances/batch-track/batch-track-contract.test.ts @@ -1,5 +1,5 @@ /** - * Retrospective contract coverage for POST /v1/balances.batchTrack. + * Retrospective contract coverage for POST /v1/balances.batch_track. * * This file is the HTTP-layer contract of record for the batch async-track * endpoint. It exercises everything the customer can observe by talking to @@ -8,7 +8,7 @@ * Contract (full surface, verbatim from the spec): * * New endpoint: - * - POST /v1/balances.batchTrack + * - POST /v1/balances.batch_track * request body: BatchTrackParams = TrackParams[] where 1 <= len <= 1000 * response: 202, body { success: true } * auth: requires Scopes.Balances.Write @@ -139,7 +139,7 @@ const postBatchTrack = async ({ headers.Authorization = authorization; } - const response = await fetch(`${autumn.baseUrl}/balances.batchTrack`, { + const response = await fetch(`${autumn.baseUrl}/balances.batch_track`, { method: "POST", headers, body: JSON.stringify(body), diff --git a/server/tests/unit/balances/track/batch-track-retry-dedup.test.ts b/server/tests/unit/balances/track/batch-track-retry-dedup.test.ts index 4c4cca3b3..2cff98abe 100644 --- a/server/tests/unit/balances/track/batch-track-retry-dedup.test.ts +++ b/server/tests/unit/balances/track/batch-track-retry-dedup.test.ts @@ -37,7 +37,7 @@ * * If this test starts failing: * DO NOT "fix" it by undoing the pin. The fix is to add idempotency - * keys to the /v1/balances.batchTrack API contract — at which point + * keys to the /v1/balances.batch_track API contract — at which point * this file should be rotated to assert the NEW dedup contract * (client-supplied keys produce stable MessageDeduplicationId across * client-driven retries). Until then, this behavior is intentional.