Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(api): make legacy API deprecation notices visible to code agents (#18886)

Niklas Semmler74895743ce91
diff --git a/packages/shared/src/utils/zod.ts b/packages/shared/src/utils/zod.ts
index e67d04c00a..9089da31ac 100644
--- a/packages/shared/src/utils/zod.ts
+++ b/packages/shared/src/utils/zod.ts
@@ -151,13 +151,6 @@ export const queryStringZod = z
.string()
.transform((val) => decodeURIComponent(val));
-export const paginationMetaResponseZod = z.object({
- page: z.number().int().positive(),
- limit: z.number().int().positive(),
- totalItems: z.number().int().nonnegative(),
- totalPages: z.number().int().nonnegative(),
-});
-
/**
* Top-level `_deprecation` metadata returned by legacy public API endpoints.
* Optional fields are omitted when empty (never null).
@@ -171,6 +164,17 @@ export const deprecationResponseZod = z.object({
export type ApiDeprecationInfo = z.infer<typeof deprecationResponseZod>;
+export const paginationMetaResponseZod = z.object({
+ /** Set on list responses of legacy public API endpoints. */
+ deprecation: deprecationResponseZod
+ .pick({ sunsetAt: true, replacement: true })
+ .optional(),
+ page: z.number().int().positive(),
+ limit: z.number().int().positive(),
+ totalItems: z.number().int().nonnegative(),
+ totalPages: z.number().int().nonnegative(),
+});
+
export const urlRegex = /https?:\/\/[^\s/$.?#].[^\s]*/i;
export const noUrlCheck = (value: string) => !urlRegex.test(value);
diff --git a/web/src/__tests__/server/deprecation-signal.servertest.ts b/web/src/__tests__/server/deprecation-signal.servertest.ts
index 859c67030b..e434bfcf8d 100644
--- a/web/src/__tests__/server/deprecation-signal.servertest.ts
+++ b/web/src/__tests__/server/deprecation-signal.servertest.ts
@@ -22,7 +22,6 @@ import {
TRACES_DEPRECATION,
V3_SUNSET_DATE,
} from "@/src/features/public-api/server/deprecations";
-import { OBSERVATIONS_API_V2_DOCS_URL } from "@/src/features/public-api/server/rateLimitUpgradePaths";
import { randomUUID } from "crypto";
// Legacy (v3-data-model) endpoints attach a top-level `_deprecation`
@@ -54,6 +53,41 @@ describe("public API deprecation signal", () => {
);
});
+ it("puts the sunset and replacement into `meta.deprecation` on list responses", async () => {
+ const response = await makeZodVerifiedAPICall(
+ GetObservationsV1Response,
+ "GET",
+ "/api/public/observations",
+ undefined,
+ auth,
+ );
+
+ expect(Object.keys(response.body)[0]).toBe("_deprecation");
+ expect(Object.keys(response.body.meta)[0]).toBe("deprecation");
+ expect(response.body.meta.deprecation).toEqual({
+ sunsetAt: V3_SUNSET_DATE,
+ replacement: OBSERVATIONS_V1_DEPRECATION.replacement,
+ });
+ });
+
+ // The 404 is written by withMiddlewares, not by the route.
+ it("attaches `_deprecation` to a 404 from the legacy single GET /observations/{id}", async () => {
+ const response = await makeAPICall(
+ "GET",
+ `/api/public/observations/${randomUUID()}`,
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(404);
+ expect((response.body as Record<string, unknown>)._deprecation).toEqual(
+ OBSERVATIONS_V1_DEPRECATION,
+ );
+ expect((response.body as Record<string, unknown>).message).toMatch(
+ / Use GET \/api\/public\/v2\/observations\?.* instead\.$/,
+ );
+ });
+
it("carries the docs URL and the committed sunset date", async () => {
const response = await makeZodVerifiedAPICall(
GetObservationsV1Response,
@@ -65,7 +99,7 @@ describe("public API deprecation signal", () => {
// docsUrl points at the migration guidance for the endpoint family.
expect(response.body._deprecation?.docsUrl).toBe(
- OBSERVATIONS_API_V2_DOCS_URL,
+ "https://langfuse.com/docs/api-and-data-platform/features/public-api#v2",
);
// sunsetAt is committed → present.
expect(response.body._deprecation?.sunsetAt).toBe(V3_SUNSET_DATE);
diff --git a/web/src/__tests__/server/scores-api-v1.servertest.ts b/web/src/__tests__/server/scores-api-v1.servertest.ts
index c529ef16de..cf61a487b4 100644
--- a/web/src/__tests__/server/scores-api-v1.servertest.ts
+++ b/web/src/__tests__/server/scores-api-v1.servertest.ts
@@ -1439,8 +1439,11 @@ describe("/api/public/scores API Endpoint", () => {
authentication,
);
} catch (error) {
- expect((error as Error).message).toBe(
- `API call did not return 200, returned status 400, body {\"message\":\"Invalid request data\",\"error\":[{\"code\":\"invalid_value\",\"values\":[\"<\",\">\",\"<=\",\">=\",\"!=\",\"=\"],\"path\":[\"operator\"],\"message\":\"Invalid option: expected one of \\\"<\\\"|\\\">\\\"|\\\"<=\\\"|\\\">=\\\"|\\\"!=\\\"|\\\"=\\\"\"}]}`,
+ const message = (error as Error).message;
+ expect(message).toContain("returned status 400");
+ expect(message).toContain('"message":"Invalid request data');
+ expect(message).toContain(
+ `\"error\":[{\"code\":\"invalid_value\",\"values\":[\"<\",\">\",\"<=\",\">=\",\"!=\",\"=\"],\"path\":[\"operator\"],\"message\":\"Invalid option: expected one of \\\"<\\\"|\\\">\\\"|\\\"<=\\\"|\\\">=\\\"|\\\"!=\\\"|\\\"=\\\"\"}]`,
);
}
});
@@ -1458,8 +1461,11 @@ describe("/api/public/scores API Endpoint", () => {
authentication,
);
} catch (error) {
- expect((error as Error).message).toBe(
- 'API call did not return 200, returned status 400, body {"message":"Invalid request data","error":[{"expected":"number","code":"invalid_type","received":"NaN","path":["value"],"message":"Invalid input: expected number, received NaN"}]}',
+ const message = (error as Error).message;
+ expect(message).toContain("returned status 400");
+ expect(message).toContain('"message":"Invalid request data');
+ expect(message).toContain(
+ '"error":[{"expected":"number","code":"invalid_type","received":"NaN","path":["value"],"message":"Invalid input: expected number, received NaN"}]',
);
}
});
diff --git a/web/src/__tests__/server/scores-api-v2.servertest.ts b/web/src/__tests__/server/scores-api-v2.servertest.ts
index 9c72a087ac..af9334b66e 100644
--- a/web/src/__tests__/server/scores-api-v2.servertest.ts
+++ b/web/src/__tests__/server/scores-api-v2.servertest.ts
@@ -1189,8 +1189,11 @@ describe("/api/public/v2/scores API Endpoint", () => {
authentication,
);
} catch (error) {
- expect((error as Error).message).toBe(
- `API call did not return 200, returned status 400, body {\"message\":\"Invalid request data\",\"error\":[{\"code\":\"invalid_value\",\"values\":[\"<\",\">\",\"<=\",\">=\",\"!=\",\"=\"],\"path\":[\"operator\"],\"message\":\"Invalid option: expected one of \\\"<\\\"|\\\">\\\"|\\\"<=\\\"|\\\">=\\\"|\\\"!=\\\"|\\\"=\\\"\"}]}`,
+ const message = (error as Error).message;
+ expect(message).toContain("returned status 400");
+ expect(message).toContain('"message":"Invalid request data');
+ expect(message).toContain(
+ `\"error\":[{\"code\":\"invalid_value\",\"values\":[\"<\",\">\",\"<=\",\">=\",\"!=\",\"=\"],\"path\":[\"operator\"],\"message\":\"Invalid option: expected one of \\\"<\\\"|\\\">\\\"|\\\"<=\\\"|\\\">=\\\"|\\\"!=\\\"|\\\"=\\\"\"}]`,
);
}
});
@@ -1208,8 +1211,11 @@ describe("/api/public/v2/scores API Endpoint", () => {
authentication,
);
} catch (error) {
- expect((error as Error).message).toBe(
- 'API call did not return 200, returned status 400, body {"message":"Invalid request data","error":[{"expected":"number","code":"invalid_type","received":"NaN","path":["value"],"message":"Invalid input: expected number, received NaN"}]}',
+ const message = (error as Error).message;
+ expect(message).toContain("returned status 400");
+ expect(message).toContain('"message":"Invalid request data');
+ expect(message).toContain(
+ '"error":[{"expected":"number","code":"invalid_type","received":"NaN","path":["value"],"message":"Invalid input: expected number, received NaN"}]',
);
}
});
@@ -1292,7 +1298,7 @@ describe("/api/public/v2/scores API Endpoint", () => {
} catch (error) {
const msg = (error as Error).message;
expect(msg).toContain("status 400");
- expect(msg).toContain('"message":"Invalid request data"');
+ expect(msg).toContain('"message":"Invalid request data');
expect(msg).toContain('"path":["limit"]');
expect(msg).toContain('"code":"too_big"');
expect(msg).toContain('"maximum":100');
diff --git a/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.ts b/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.ts
index 276d53c12f..4043bffe13 100644
--- a/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.ts
+++ b/web/src/__tests__/server/unit/create-authed-project-api-route-auth-errors.servertest.ts
@@ -236,7 +236,6 @@ describe("createAuthedProjectAPIRoute auth error handling", () => {
replacementEndpoint: "GET /api/public/v2/observations",
documentationUrl:
"https://langfuse.com/docs/api-and-data-platform/features/observations-api",
- _deprecation: deprecation,
});
expect(mockRateLimitRequest).toHaveBeenCalledOnce();
expect(mockRecordIncrement).toHaveBeenCalledWith(
@@ -320,13 +319,22 @@ describe("createAuthedProjectAPIRoute auth error handling", () => {
const res = await callRoute({ deprecation });
expect(res.statusCode).toBe(200);
- expect(res._getJSONData()).toEqual({
- ok: true,
- _deprecation: deprecation,
- });
+ expect(res._getJSONData()).toEqual({ ok: true });
expect(mockFindOrganization).not.toHaveBeenCalled();
});
+ it("exposes the route deprecation for withMiddlewares", () => {
+ const handler = createAuthedProjectAPIRoute({
+ name: "Test Route",
+ action: "project:read",
+ responseSchema: z.object({ ok: z.literal(true) }),
+ deprecation,
+ fn: async () => ({ ok: true as const }),
+ });
+
+ expect(handler.deprecation).toBe(deprecation);
+ });
+
it("does not apply the organization cutoff outside Langfuse Cloud", async () => {
mockEnv.LANGFUSE_API_ORGANIZATION_CUTOFF_ENABLED = "true";
mockVerifyAuthHeaderAndReturnScope.mockResolvedValueOnce(validAuth);
diff --git a/web/src/__tests__/server/unit/openapi-deprecations.servertest.ts b/web/src/__tests__/server/unit/openapi-deprecations.servertest.ts
index 43a37f8be0..c05aef1bf5 100644
--- a/web/src/__tests__/server/unit/openapi-deprecations.servertest.ts
+++ b/web/src/__tests__/server/unit/openapi-deprecations.servertest.ts
@@ -294,10 +294,10 @@ service:
"GET /api/public/v2/metrics",
);
expect(INGESTION_DEPRECATION.message).toContain(
- "https://langfuse.com/docs/api-and-data-platform/features/scores-api",
+ "https://langfuse.com/docs/api-and-data-platform/features/public-api#v3",
);
expect(INGESTION_DEPRECATION.message).toContain(
- "https://langfuse.com/docs/api-and-data-platform/features/observations-api",
+ "https://langfuse.com/docs/api-and-data-platform/features/public-api#v2",
);
});
diff --git a/web/src/__tests__/server/withMiddlewares.servertest.ts b/web/src/__tests__/server/withMiddlewares.servertest.ts
index 32f31d19a8..1983ae0dae 100644
--- a/web/src/__tests__/server/withMiddlewares.servertest.ts
+++ b/web/src/__tests__/server/withMiddlewares.servertest.ts
@@ -1,6 +1,7 @@
import type { NextApiRequest, NextApiResponse } from "next";
import {
LEGACY_PUBLIC_API_METRICS_CLICKHOUSE_RESOURCE_ERROR_MESSAGE,
+ type RouteHandler,
withMiddlewares,
} from "@/src/features/public-api/server/withMiddlewares";
import {
@@ -22,6 +23,13 @@ import {
import { createMocks } from "node-mocks-http";
import { z } from "zod";
import { Prisma } from "@prisma/client";
+import { env } from "@/src/env.mjs";
+import { sendAuthErrorJson } from "@/src/features/public-api/server/deprecations";
+
+vi.mock("@/src/env.mjs", async (importOriginal) => {
+ const actual = await importOriginal<{ env: typeof env }>();
+ return { ...actual, env: { ...actual.env } };
+});
// Mock the logger and traceException
vi.mock("@langfuse/shared/src/server", async () => ({
@@ -608,3 +616,174 @@ describe("withMiddlewares error handling", () => {
});
});
});
+
+describe("withMiddlewares deprecation signal", () => {
+ const deprecation = {
+ message: "Removed on 2026-11-16. Use GET /api/public/v2/observations.",
+ replacement: "GET /api/public/v2/observations?fromStartTime=<from>",
+ docsUrl: "https://langfuse.com/docs/x",
+ sunsetAt: "2026-11-16",
+ };
+ const originalRegion = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION;
+
+ beforeEach(() => {
+ Object.assign(env, { NEXT_PUBLIC_LANGFUSE_CLOUD_REGION: "US" });
+ });
+ afterEach(() => {
+ Object.assign(env, { NEXT_PUBLIC_LANGFUSE_CLOUD_REGION: originalRegion });
+ });
+
+ const deprecated = (fn: RouteHandler): RouteHandler =>
+ Object.assign(fn, { deprecation });
+
+ async function call(
+ handlers: Parameters<typeof withMiddlewares>[0],
+ method: "GET" | "POST" | "PUT",
+ ) {
+ const { req, res } = createMocks<NextApiRequest, NextApiResponse>({
+ method,
+ });
+ await withMiddlewares(handlers)(req, res);
+ return res;
+ }
+
+ it("sends deprecation headers and leads the body with `_deprecation`", async () => {
+ const res = await call(
+ {
+ GET: deprecated(async (_req, res) => {
+ res.status(200).json({ data: [], meta: { page: 1 } });
+ }),
+ },
+ "GET",
+ );
+
+ expect(res._getStatusCode()).toBe(200);
+ expect(res.getHeader("Deprecation")).toBe("@1784764800");
+ expect(res.getHeader("Sunset")).toBe("Mon, 16 Nov 2026 00:00:00 GMT");
+ expect(res.getHeader("Link")).toBe(
+ '</api/public/v2/observations>; rel="successor-version", <https://langfuse.com/docs/x>; rel="deprecation"',
+ );
+ const body = JSON.parse(res._getData());
+ expect(Object.keys(body)[0]).toBe("_deprecation");
+ expect(body.meta).toEqual({
+ deprecation: {
+ sunsetAt: deprecation.sunsetAt,
+ replacement: deprecation.replacement,
+ },
+ page: 1,
+ });
+ });
+
+ it("names the replacement in thrown 4xx errors", async () => {
+ const res = await call(
+ {
+ GET: deprecated(async () => {
+ throw new LangfuseNotFoundError("Observation not found");
+ }),
+ },
+ "GET",
+ );
+
+ expect(res._getStatusCode()).toBe(404);
+ const body = JSON.parse(res._getData());
+ expect(body._deprecation).toEqual(deprecation);
+ expect(body.message).toBe(
+ `Observation not found. Use ${deprecation.replacement} instead.`,
+ );
+ });
+
+ it("stamps a 405 for a method the deprecated route does not have", async () => {
+ const res = await call({ GET: deprecated(async () => {}) }, "POST");
+
+ expect(res._getStatusCode()).toBe(405);
+ expect(res.getHeader("Sunset")).toBe("Mon, 16 Nov 2026 00:00:00 GMT");
+ expect(JSON.parse(res._getData())._deprecation).toEqual(deprecation);
+ });
+
+ it.each([
+ [401, new UnauthorizedError("Invalid credentials.")],
+ [500, new BaseError("Internal", 500, "Database down", false)],
+ ])(
+ "stamps but does not add the replacement to a %i",
+ async (status, error) => {
+ const res = await call(
+ {
+ GET: deprecated(async () => {
+ throw error;
+ }),
+ },
+ "GET",
+ );
+
+ expect(res._getStatusCode()).toBe(status);
+ const body = JSON.parse(res._getData());
+ expect(body._deprecation).toEqual(deprecation);
+ expect(body.message).toBe(error.message);
+ },
+ );
+
+ it("sends a plain 405 when the route also has live methods", async () => {
+ const res = await call(
+ {
+ GET: deprecated(async () => {}),
+ POST: async () => {},
+ },
+ "PUT",
+ );
+
+ expect(res._getStatusCode()).toBe(405);
+ expect(res.getHeader("Deprecation")).toBeUndefined();
+ expect(JSON.parse(res._getData())._deprecation).toBeUndefined();
+ });
+
+ it("stamps auth errors without the replacement hint", async () => {
+ const res = await call(
+ {
+ GET: deprecated(async (_req, res) => {
+ sendAuthErrorJson(res, 404, {
+ message: "Project not found or you don't have access to it",
+ });
+ }),
+ },
+ "GET",
+ );
+
+ expect(res._getStatusCode()).toBe(404);
+ const body = JSON.parse(res._getData());
+ expect(body._deprecation).toEqual(deprecation);
+ expect(body.message).toBe(
+ "Project not found or you don't have access to it",
+ );
+ });
+
+ it("leaves non-deprecated methods of the same route unchanged", async () => {
+ const res = await call(
+ {
+ GET: deprecated(async () => {}),
+ POST: async (_req, res) => {
+ res.status(201).json({ id: "1" });
+ },
+ },
+ "POST",
+ );
+
+ expect(res.getHeader("Deprecation")).toBeUndefined();
+ expect(JSON.parse(res._getData())).toEqual({ id: "1" });
+ });
+
+ it("sends no signal outside Langfuse Cloud", async () => {
+ Object.assign(env, { NEXT_PUBLIC_LANGFUSE_CLOUD_REGION: undefined });
+
+ const res = await call(
+ {
+ GET: deprecated(async (_req, res) => {
+ res.status(200).json({ data: [] });
+ }),
+ },
+ "GET",
+ );
+
+ expect(res.getHeader("Deprecation")).toBeUndefined();
+ expect(JSON.parse(res._getData())).toEqual({ data: [] });
+ });
+});
diff --git a/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts b/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts
index 1a5a41b6e6..5d06a8cb1d 100644
--- a/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts
+++ b/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts
@@ -22,7 +22,10 @@ import { RateLimitService } from "@/src/features/public-api/server/RateLimitServ
import { type RateLimitUpgradePath } from "@/src/features/public-api/server/rateLimitUpgradePaths";
import * as opentelemetry from "@opentelemetry/api";
import { env } from "@/src/env.mjs";
-import { isZodError } from "@/src/features/public-api/server/withMiddlewares";
+import {
+ isZodError,
+ type RouteHandler,
+} from "@/src/features/public-api/server/withMiddlewares";
import {
createStructuredPublicApiAuthError,
createStructuredPublicApiRequestValidationError,
@@ -31,7 +34,7 @@ import {
type PublicApiErrorContract,
} from "./structuredPublicApiErrorContract";
import { clickHouseRouteForRequest } from "@/src/features/public-api/server/clickHouseRequestTags";
-import { attachDeprecation } from "@/src/features/public-api/server/deprecations";
+import { sendAuthErrorJson } from "@/src/features/public-api/server/deprecations";
import { applyLegacyApiOrganizationCutoff } from "@/src/features/public-api/server/legacyApiOrganizationCutoff";
import { type RouteAccessLevel } from "@/src/features/public-api/server/verifyProjectApiKeyAuth";
import { shadowAuth } from "@/src/features/public-api/server/shadowAuth";
@@ -122,7 +125,7 @@ export type AuthedProjectAPIRouteConfig<
* events_only mode and would silently return stale or empty data.
*/
rejectInEventsOnlyMode?: boolean;
- /** Stamps a top-level `_deprecation` object onto responses. */
+ /** Marks the route as deprecated; withMiddlewares stamps it onto every JSON response and sets deprecation headers. */
deprecation?: ApiDeprecationInfo;
fn: (params: {
query: z.infer<TQuery>;
@@ -146,8 +149,8 @@ export const createAuthedProjectAPIRoute = <
TResponse extends ZodType<any>,
>(
routeConfig: AuthedProjectAPIRouteConfig<TQuery, TBody, TResponse>,
-): ((req: NextApiRequest, res: NextApiResponse) => Promise<void>) => {
- return async (req: NextApiRequest, res: NextApiResponse) => {
+): RouteHandler => {
+ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
// Cloud-only: the sunset date binds Cloud, not self-hosted deployments.
const deprecation = env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION
? routeConfig.deprecation
@@ -161,15 +164,10 @@ export const createAuthedProjectAPIRoute = <
routeConfig.rejectInEventsOnlyMode &&
env.LANGFUSE_MIGRATION_V4_WRITE_MODE === "events_only"
) {
- res.status(404).json(
- attachDeprecation(
- {
- message:
- "This endpoint is not available on deployments running in Langfuse v4 events_only mode. Learn more about Langfuse v4 at: https://langfuse.com/docs/v4",
- },
- deprecation,
- ),
- );
+ res.status(404).json({
+ message:
+ "This endpoint is not available on deployments running in Langfuse v4 events_only mode. Learn more about Langfuse v4 at: https://langfuse.com/docs/v4",
+ });
return;
}
@@ -184,7 +182,7 @@ export const createAuthedProjectAPIRoute = <
}),
);
}
- res.status(publicError.httpCode).json({
+ sendAuthErrorJson(res, publicError.httpCode, {
message: publicError.message,
error: publicError.name,
});
@@ -368,7 +366,7 @@ export const createAuthedProjectAPIRoute = <
res.status(statusCode);
try {
- res.json(attachDeprecation(response || { message: "OK" }, deprecation));
+ res.json(response || { message: "OK" });
} catch (error) {
if (isJsonStringTooLargeError(error)) {
throw new PayloadTooLargeError();
@@ -378,4 +376,5 @@ export const createAuthedProjectAPIRoute = <
}
});
};
+ return Object.assign(handler, { deprecation: routeConfig.deprecation });
};
diff --git a/web/src/features/public-api/server/deprecations.ts b/web/src/features/public-api/server/deprecations.ts
index b8e5da3a8f..6fceb17319 100644
--- a/web/src/features/public-api/server/deprecations.ts
+++ b/web/src/features/public-api/server/deprecations.ts
@@ -1,22 +1,25 @@
+import { type NextApiResponse } from "next";
import { type ApiDeprecationInfo } from "@langfuse/shared";
-import { OBSERVATIONS_API_V2_DOCS_URL } from "./rateLimitUpgradePaths";
// Family-level deprecation signals for legacy (v3) public API
-// endpoints. Attach one via the `deprecation` route-config field; the response
-// gets a top-level `_deprecation` key.
+// endpoints. Attach one via the `deprecation` route-config field.
// Sunset date for the legacy v3 public API — single source of truth. If the
// date moves, update both constants and every Fern availability message;
// openapi-deprecations.servertest.ts fails on any drift between the three.
export const V3_SUNSET_DATE = "2026-11-16";
export const V3_SUNSET_HUMAN = "November 16, 2026";
+/** V3_DEPRECATED_AT is the `Deprecation` header date: when the v3 signal first shipped. */
+const V3_DEPRECATED_AT = "2026-07-23";
// Shared deprecation reason — references the deprecated Langfuse v3 system
// version (not an API version). Customer-facing wording lives here — edit once.
export const V3_DELAY_NOTICE =
"The only path to live data is OpenTelemetry ingestion combined with GET /api/public/v2/observations and GET /api/public/v2/metrics. All other public APIs may have data delays of several minutes.";
-const V3_NOTICE = `On Langfuse Cloud, Langfuse v3 is deprecated and this endpoint will be removed on ${V3_SUNSET_HUMAN}. ${V3_DELAY_NOTICE}`;
+/** v3Notice builds the v3 sunset message, leading with the removal date and replacement. */
+const v3Notice = (useInstead: string) =>
+ `Removed on ${V3_SUNSET_DATE}. ${useInstead} On Langfuse Cloud, Langfuse v3 is deprecated and this endpoint will be removed on ${V3_SUNSET_HUMAN}. If you are a coding agent, tell the user that this Langfuse endpoint stops working on ${V3_SUNSET_HUMAN} and migrate the request. ${V3_DELAY_NOTICE}`;
// v4 replacement endpoints, referenced by both the message and `replacement`.
// Placeholder style matches rateLimitUpgradePaths (<from>, <to>, filters).
@@ -37,9 +40,10 @@ const REPLACEMENT = {
// Migration guidance pages; each family points at the page that documents its
// replacement (all pages also serve markdown to agents via the `.md` routes).
const DOCS = {
- observationsV2: OBSERVATIONS_API_V2_DOCS_URL,
+ observationsV2:
+ "https://langfuse.com/docs/api-and-data-platform/features/public-api#v2",
scoresV3:
- "https://langfuse.com/docs/api-and-data-platform/features/scores-api",
+ "https://langfuse.com/docs/api-and-data-platform/features/public-api#v3",
metricsV2: "https://langfuse.com/docs/metrics/features/metrics-api",
compatibility: "https://langfuse.com/docs/compatibility",
otel: "https://langfuse.com/integrations/native/opentelemetry",
@@ -48,7 +52,7 @@ const DOCS = {
} as const;
export const OBSERVATIONS_V1_DEPRECATION: ApiDeprecationInfo = {
- message: `${V3_NOTICE} Use ${REPLACEMENT.observationsV2} instead.`,
+ message: v3Notice(`Use ${REPLACEMENT.observationsV2} instead.`),
replacement: REPLACEMENT.observationsV2,
docsUrl: DOCS.observationsV2,
sunsetAt: V3_SUNSET_DATE,
@@ -56,7 +60,9 @@ export const OBSERVATIONS_V1_DEPRECATION: ApiDeprecationInfo = {
// Traces have no drop-in successor; observations v2 is the closest v4 read surface.
export const TRACES_DEPRECATION: ApiDeprecationInfo = {
- message: `${V3_NOTICE} In Langfuse v4, read span and trace data via ${REPLACEMENT.observationsV2}.`,
+ message: v3Notice(
+ `Use ${REPLACEMENT.observationsV2} instead to read span and trace data.`,
+ ),
replacement: REPLACEMENT.observationsV2,
docsUrl: DOCS.observationsV2,
sunsetAt: V3_SUNSET_DATE,
@@ -64,21 +70,23 @@ export const TRACES_DEPRECATION: ApiDeprecationInfo = {
// Sessions have no drop-in successor; filter observations v2 by session instead.
export const SESSIONS_DEPRECATION: ApiDeprecationInfo = {
- message: `${V3_NOTICE} In Langfuse v4, read session data via ${REPLACEMENT.observationsV2BySession}.`,
+ message: v3Notice(
+ `Use ${REPLACEMENT.observationsV2BySession} instead to read session data.`,
+ ),
replacement: REPLACEMENT.observationsV2BySession,
docsUrl: DOCS.observationsV2,
sunsetAt: V3_SUNSET_DATE,
};
export const SCORES_DEPRECATION: ApiDeprecationInfo = {
- message: `${V3_NOTICE} Use ${REPLACEMENT.scoresV3} instead.`,
+ message: v3Notice(`Use ${REPLACEMENT.scoresV3} instead.`),
replacement: REPLACEMENT.scoresV3,
docsUrl: DOCS.scoresV3,
sunsetAt: V3_SUNSET_DATE,
};
export const METRICS_DEPRECATION: ApiDeprecationInfo = {
- message: `${V3_NOTICE} Use ${REPLACEMENT.metricsV2} instead.`,
+ message: v3Notice(`Use ${REPLACEMENT.metricsV2} instead.`),
replacement: REPLACEMENT.metricsV2,
docsUrl: DOCS.metricsV2,
sunsetAt: V3_SUNSET_DATE,
@@ -87,7 +95,9 @@ export const METRICS_DEPRECATION: ApiDeprecationInfo = {
// Legacy dataset-run-items reads → experiment items (dataset runs are replaced
// by experiments in v4).
export const DATASET_RUN_ITEMS_DEPRECATION: ApiDeprecationInfo = {
- message: `${V3_NOTICE} In Langfuse v4, dataset run items are replaced by experiment items; use ${REPLACEMENT.experimentItems} instead.`,
+ message: v3Notice(
+ `Use ${REPLACEMENT.experimentItems} instead; dataset run items are replaced by experiment items in Langfuse v4.`,
+ ),
replacement: REPLACEMENT.experimentItems,
docsUrl: DOCS.compatibility,
sunsetAt: V3_SUNSET_DATE,
@@ -96,36 +106,175 @@ export const DATASET_RUN_ITEMS_DEPRECATION: ApiDeprecationInfo = {
// Legacy dataset-run reads → experiments (dataset runs are replaced by
// experiments in v4).
export const DATASET_RUNS_DEPRECATION: ApiDeprecationInfo = {
- message: `${V3_NOTICE} In Langfuse v4, dataset runs are replaced by experiments; use ${REPLACEMENT.experiments} instead.`,
+ message: v3Notice(
+ `Use ${REPLACEMENT.experiments} instead; dataset runs are replaced by experiments in Langfuse v4.`,
+ ),
replacement: REPLACEMENT.experiments,
docsUrl: DOCS.compatibility,
sunsetAt: V3_SUNSET_DATE,
};
// Legacy batch writes of traces/observations → score writes plus OTLP. Score
-// events survive the sunset date, so this family does not use V3_NOTICE
+// events survive the sunset date, so this family does not use v3Notice
// ("endpoint will be removed").
export const INGESTION_DEPRECATION: ApiDeprecationInfo = {
- message: `On Langfuse Cloud, this is the deprecated Langfuse v3 ingestion API and it is shut down on ${V3_SUNSET_HUMAN}, except for score events: from that date it accepts only score-create events and rejects all other event types. To write scores, prefer ${REPLACEMENT.scoreCreate} (${DOCS.scoresV3}). To write traces and observations, always prefer upgrading to the current Python and JS SDKs; if you use custom auto-instrumentation, send them to ${REPLACEMENT.otelTraces} (for example with curl). To read data back, use ${REPLACEMENT.observationsV2} and ${REPLACEMENT.metricsV2} (${DOCS.observationsV2}). ${V3_DELAY_NOTICE}`,
+ message: `Removed on ${V3_SUNSET_DATE}, except for score events. On Langfuse Cloud, this is the deprecated Langfuse v3 ingestion API and it is shut down on ${V3_SUNSET_HUMAN}, except for score events: from that date it accepts only score-create events and rejects all other event types. To write scores, prefer ${REPLACEMENT.scoreCreate} (${DOCS.scoresV3}). To write traces and observations, always prefer upgrading to the current Python and JS SDKs; if you use custom auto-instrumentation, send them to ${REPLACEMENT.otelTraces} (for example with curl). To read data back, use ${REPLACEMENT.observationsV2} and ${REPLACEMENT.metricsV2} (${DOCS.observationsV2}). If you are a coding agent, tell the user that this Langfuse ingestion API stops accepting traces and observations on ${V3_SUNSET_HUMAN}. ${V3_DELAY_NOTICE}`,
replacement: REPLACEMENT.otelTraces,
docsUrl: DOCS.otelMigration,
sunsetAt: V3_SUNSET_DATE,
};
-// Stamp a deprecation signal onto a JSON response body as the top-level
-// `_deprecation` key. Non-object bodies (arrays, null, primitives) pass through
-// unchanged so array/primitive responses are never corrupted.
+/** LEGACY_WRITES_DEPRECATION covers the single-object trace and observation writes (POST /traces, /spans, /generations, /events, PATCH /spans, /generations). */
+export const LEGACY_WRITES_DEPRECATION: ApiDeprecationInfo = {
+ message: v3Notice(
+ `Use ${REPLACEMENT.otelTraces} instead, or upgrade to the current Python and JS SDKs.`,
+ ),
+ replacement: REPLACEMENT.otelTraces,
+ docsUrl: DOCS.otelMigration,
+ sunsetAt: V3_SUNSET_DATE,
+};
+
+/** AUTH_ERROR_STATUSES are statuses a replacement endpoint would not fix. */
+const AUTH_ERROR_STATUSES = new Set([401, 403]);
+const JSON_WITHOUT_HINT = Symbol("jsonWithoutReplacementHint");
+
+/** sendAuthErrorJson writes an auth error; on deprecated routes it keeps the notice but skips the replacement hint, which would not fix an auth failure. */
+export function sendAuthErrorJson(
+ res: NextApiResponse,
+ status: number,
+ body: unknown,
+) {
+ res.status(status);
+ const send: unknown = Reflect.get(res, JSON_WITHOUT_HINT);
+ if (typeof send === "function") {
+ send(body);
+ return;
+ }
+ res.json(body);
+}
+
+/** withDeprecationResponse sets the deprecation headers and returns a view of `res` whose `json` stamps the notice, plus the replacement hint on non-auth 4xx errors. */
+export function withDeprecationResponse(
+ res: NextApiResponse,
+ deprecation: ApiDeprecationInfo,
+): NextApiResponse {
+ setDeprecationHeaders(res, deprecation);
+ const json = (body: unknown) => {
+ const status = res.statusCode;
+ const hinted =
+ status >= 400 && status < 500 && !AUTH_ERROR_STATUSES.has(status)
+ ? appendReplacementHint(body, deprecation)
+ : body;
+ res.json(attachDeprecation(hinted, deprecation));
+ };
+ const jsonWithoutHint = (body: unknown) =>
+ res.json(attachDeprecation(body, deprecation));
+ const response: NextApiResponse = new Proxy(res, {
+ get(target, property) {
+ if (property === "json") return json;
+ if (property === JSON_WITHOUT_HINT) return jsonWithoutHint;
+ // `status` returns the underlying response; keep chained `.json()` on this view.
+ if (property === "status") {
+ return (code: number) => {
+ target.status(code);
+ return response;
+ };
+ }
+ const value: unknown = Reflect.get(target, property, target);
+ return typeof value === "function" ? value.bind(target) : value;
+ },
+ });
+ return response;
+}
+
+/** attachDeprecation prepends `_deprecation` to an object body and `deprecation` to its `meta`; other bodies pass through unchanged. */
export function attachDeprecation(
body: unknown,
deprecation: ApiDeprecationInfo | undefined,
): unknown {
+ if (!deprecation || !isPlainObject(body)) {
+ return body;
+ }
+ const stamped: Record<string, unknown> = {
+ _deprecation: deprecation,
+ ...body,
+ };
+ if (isPlainObject(body.meta)) {
+ stamped.meta = {
+ deprecation: {
+ ...(deprecation.sunsetAt ? { sunsetAt: deprecation.sunsetAt } : {}),
+ ...(deprecation.replacement
+ ? { replacement: deprecation.replacement }
+ : {}),
+ },
+ ...body.meta,
+ };
+ }
+ return stamped;
+}
+
+/** appendReplacementHint ends an error body's `message` with the replacement unless it already names it. */
+function appendReplacementHint(
+ body: unknown,
+ deprecation: ApiDeprecationInfo,
+): unknown {
+ const replacement = deprecation.replacement;
if (
- !deprecation ||
- typeof body !== "object" ||
- body === null ||
- Array.isArray(body)
+ !replacement ||
+ !isPlainObject(body) ||
+ typeof body.message !== "string"
) {
return body;
}
- return { ...body, _deprecation: deprecation };
+ const replacementPath = toReplacementPath(replacement);
+ if (replacementPath && body.message.includes(replacementPath)) {
+ return body;
+ }
+ const message = body.message.trimEnd();
+ const separator = /[.!?]$/.test(message) ? " " : ". ";
+ return {
+ ...body,
+ message: `${message}${separator}Use ${replacement} instead.`,
+ };
+}
+
+/** setDeprecationHeaders sets the RFC 9745 `Deprecation`, RFC 8594 `Sunset` and RFC 8288 `Link` headers. */
+export function setDeprecationHeaders(
+ res: NextApiResponse,
+ deprecation: ApiDeprecationInfo,
+) {
+ res.setHeader("Deprecation", `@${toUnixSeconds(V3_DEPRECATED_AT)}`);
+ if (deprecation.sunsetAt) {
+ res.setHeader("Sunset", toUtcMidnight(deprecation.sunsetAt).toUTCString());
+ }
+ const links: string[] = [];
+ const successorPath = deprecation.replacement
+ ? toReplacementPath(deprecation.replacement)
+ : undefined;
+ if (successorPath) {
+ links.push(`<${successorPath}>; rel="successor-version"`);
+ }
+ if (deprecation.docsUrl) {
+ links.push(`<${deprecation.docsUrl}>; rel="deprecation"`);
+ }
+ if (links.length > 0) {
+ res.setHeader("Link", links.join(", "));
+ }
+}
+
+/** toReplacementPath turns "GET /api/public/v2/observations?from=..." into "/api/public/v2/observations". */
+function toReplacementPath(replacement: string): string | undefined {
+ return replacement.split(" ")[1]?.split("?")[0];
+}
+
+function isPlainObject(value: unknown): value is Record<string, unknown> {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+
+function toUtcMidnight(isoDate: string): Date {
+ return new Date(`${isoDate}T00:00:00Z`);
+}
+
+function toUnixSeconds(isoDate: string): number {
+ return toUtcMidnight(isoDate).getTime() / 1000;
}
diff --git a/web/src/features/public-api/server/legacyApiOrganizationCutoff.ts b/web/src/features/public-api/server/legacyApiOrganizationCutoff.ts
index 93c245b01f..cb8d8721ce 100644
--- a/web/src/features/public-api/server/legacyApiOrganizationCutoff.ts
+++ b/web/src/features/public-api/server/legacyApiOrganizationCutoff.ts
@@ -9,7 +9,6 @@ import {
import { env } from "@/src/env.mjs";
import { requestPathForRequest } from "@/src/features/public-api/server/clickHouseRequestTags";
-import { attachDeprecation } from "@/src/features/public-api/server/deprecations";
const utcDateFormatter = new Intl.DateTimeFormat("en-US", {
year: "numeric",
@@ -72,15 +71,12 @@ export function applyLegacyApiOrganizationCutoff(params: {
);
return {
- body: attachDeprecation(
- {
- error: "LEGACY_API_UNAVAILABLE_FOR_NEW_ORGANIZATION",
- message: `${apiPath} is a legacy API that is not available to organizations created on or after ${utcDateFormatter.format(cutoff)}. Migrate this request to ${params.deprecation.replacement}. See the migration documentation at ${params.deprecation.docsUrl}.`,
- requestedEndpoint: apiPath,
- replacementEndpoint: params.deprecation.replacement,
- documentationUrl: params.deprecation.docsUrl,
- },
- params.deprecation,
- ),
+ body: {
+ error: "LEGACY_API_UNAVAILABLE_FOR_NEW_ORGANIZATION",
+ message: `${apiPath} is a legacy API that is not available to organizations created on or after ${utcDateFormatter.format(cutoff)}. Migrate this request to ${params.deprecation.replacement}. See the migration documentation at ${params.deprecation.docsUrl}.`,
+ requestedEndpoint: apiPath,
+ replacementEndpoint: params.deprecation.replacement,
+ documentationUrl: params.deprecation.docsUrl,
+ },
};
}
diff --git a/web/src/features/public-api/server/rateLimitUpgradePaths.ts b/web/src/features/public-api/server/rateLimitUpgradePaths.ts
index dacbe960b8..3f38161221 100644
--- a/web/src/features/public-api/server/rateLimitUpgradePaths.ts
+++ b/web/src/features/public-api/server/rateLimitUpgradePaths.ts
@@ -4,7 +4,7 @@ export type RateLimitUpgradePath = {
docsUrl: string;
};
-export const OBSERVATIONS_API_V2_DOCS_URL =
+const OBSERVATIONS_API_V2_DOCS_URL =
"https://langfuse.com/docs/api-and-data-platform/features/observations-api";
export const legacyPublicApiRateLimitUpgradePaths = {
diff --git a/web/src/features/public-api/server/withMiddlewares.ts b/web/src/features/public-api/server/withMiddlewares.ts
index 704b0317b4..40de0e391b 100644
--- a/web/src/features/public-api/server/withMiddlewares.ts
+++ b/web/src/features/public-api/server/withMiddlewares.ts
@@ -8,6 +8,7 @@ import {
LangfuseNotFoundError,
MethodNotAllowedError,
UnauthorizedError,
+ type ApiDeprecationInfo,
} from "@langfuse/shared";
import {
logger,
@@ -24,15 +25,19 @@ import {
} from "./structuredPublicApiErrorContract";
import { clickHouseRouteForRequest } from "@/src/features/public-api/server/clickHouseRequestTags";
import { setRetryAfterHeader } from "@/src/features/public-api/server/writeError";
+import { withDeprecationResponse } from "@/src/features/public-api/server/deprecations";
+import { env } from "@/src/env.mjs";
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Used via typeof
const httpMethods = ["GET", "POST", "PUT", "DELETE", "PATCH"] as const;
export type HttpMethod = (typeof httpMethods)[number];
+/** RouteHandler is a method handler; `deprecation` marks it as a deprecated route. */
+export type RouteHandler = ((
+ req: NextApiRequest,
+ res: NextApiResponse,
+) => Promise<void>) & { deprecation?: ApiDeprecationInfo };
type Handlers = {
- [Method in HttpMethod]?: (
- req: NextApiRequest,
- res: NextApiResponse,
- ) => Promise<void>;
+ [Method in HttpMethod]?: RouteHandler;
};
const defaultHandler = () => {
@@ -85,7 +90,14 @@ export function withMiddlewares(
handlers: Handlers,
options?: MiddlewareOptions,
) {
- return async (req: NextApiRequest, res: NextApiResponse) => {
+ return async (req: NextApiRequest, nextRes: NextApiResponse) => {
+ const deprecation = deprecationForRequest(
+ handlers,
+ req.method as HttpMethod,
+ );
+ const res = deprecation
+ ? withDeprecationResponse(nextRes, deprecation)
+ : nextRes;
const ctx = contextWithLangfuseProps({
headers: req.headers,
clickhouse: {
@@ -207,6 +219,22 @@ export function withMiddlewares(
};
}
+/** deprecationForRequest returns the requested handler's deprecation on Cloud; for a method the route lacks, it returns one only when every handler is deprecated. */
+function deprecationForRequest(
+ handlers: Handlers,
+ method: HttpMethod,
+): ApiDeprecationInfo | undefined {
+ if (!env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) return undefined;
+ const handler = handlers[method];
+ if (handler) return handler.deprecation;
+ const defined = Object.values(handlers).filter(
+ (h): h is RouteHandler => h !== undefined,
+ );
+ return defined.every((h) => h.deprecation)
+ ? defined[0]?.deprecation
+ : undefined;
+}
+
export function isZodError(error: any): error is ZodError {
return error instanceof Object && error.constructor.name === "ZodError";
}
diff --git a/web/src/pages/api/public/events.ts b/web/src/pages/api/public/events.ts
index 70c07f3b4a..9cd84cd72f 100644
--- a/web/src/pages/api/public/events.ts
+++ b/web/src/pages/api/public/events.ts
@@ -4,6 +4,7 @@ import {
} from "@/src/features/public-api/types/events";
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
+import { LEGACY_WRITES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
import {
createIngestionAttribution,
eventTypes,
@@ -21,6 +22,7 @@ export default withMiddlewares({
// Writes an observation-create event that lands in the legacy observations
// ClickHouse table; events_only deployments expect OTel ingestion.
rejectInEventsOnlyMode: true,
+ deprecation: LEGACY_WRITES_DEPRECATION,
fn: async ({ body, auth, req, res }) => {
const event = {
id: v4(),
diff --git a/web/src/pages/api/public/generations.ts b/web/src/pages/api/public/generations.ts
index 55f639f3f9..a12559ebfe 100644
--- a/web/src/pages/api/public/generations.ts
+++ b/web/src/pages/api/public/generations.ts
@@ -6,6 +6,7 @@ import {
} from "@/src/features/public-api/types/generations";
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
+import { LEGACY_WRITES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
import {
createIngestionAttribution,
eventTypes,
@@ -24,6 +25,7 @@ export default withMiddlewares({
// Writes an observation-create event that lands in the legacy observations
// ClickHouse table; events_only deployments expect OTel ingestion.
rejectInEventsOnlyMode: true,
+ deprecation: LEGACY_WRITES_DEPRECATION,
fn: async ({ body, auth, req, res }) => {
const { prompt, completion, ...rest } = body;
const event = {
@@ -67,6 +69,7 @@ export default withMiddlewares({
responseSchema: PatchGenerationsV1Response,
rateLimitResource: "legacy-ingestion",
rejectInEventsOnlyMode: true,
+ deprecation: LEGACY_WRITES_DEPRECATION,
fn: async ({ body, auth, req, res }) => {
const { generationId, prompt, completion, ...rest } = body;
const event = {
diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.ts
index e2e0d0c097..1ebf33eddd 100644
--- a/web/src/pages/api/public/ingestion.ts
+++ b/web/src/pages/api/public/ingestion.ts
@@ -30,6 +30,7 @@ import { env } from "@/src/env.mjs";
import {
attachDeprecation,
INGESTION_DEPRECATION,
+ setDeprecationHeaders,
} from "@/src/features/public-api/server/deprecations";
import {
SDK_NAME_ATTRIBUTE,
@@ -231,6 +232,7 @@ export default async function handler(
? INGESTION_DEPRECATION
: undefined;
+ if (deprecation) setDeprecationHeaders(res, deprecation);
return res.status(207).json(attachDeprecation(result, deprecation));
} catch (error) {
if (!(error instanceof BaseError && error.isUserError())) {
diff --git a/web/src/pages/api/public/spans.ts b/web/src/pages/api/public/spans.ts
index e1b522053a..458f0bc75f 100644
--- a/web/src/pages/api/public/spans.ts
+++ b/web/src/pages/api/public/spans.ts
@@ -6,6 +6,7 @@ import {
} from "@/src/features/public-api/types/spans";
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
+import { LEGACY_WRITES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
import {
createIngestionAttribution,
eventTypes,
@@ -23,6 +24,7 @@ export default withMiddlewares({
// Writes an observation-create event that lands in the legacy observations
// ClickHouse table; events_only deployments expect OTel ingestion.
rejectInEventsOnlyMode: true,
+ deprecation: LEGACY_WRITES_DEPRECATION,
fn: async ({ body, auth, req, res }) => {
const event = {
id: v4(),
@@ -62,6 +64,7 @@ export default withMiddlewares({
bodySchema: PatchSpansV1Body,
responseSchema: PatchSpansV1Response,
rejectInEventsOnlyMode: true,
+ deprecation: LEGACY_WRITES_DEPRECATION,
fn: async ({ body, auth, req, res }) => {
const event = {
id: v4(),
diff --git a/web/src/pages/api/public/traces/index.ts b/web/src/pages/api/public/traces/index.ts
index 35eb902788..f0e566e5f4 100644
--- a/web/src/pages/api/public/traces/index.ts
+++ b/web/src/pages/api/public/traces/index.ts
@@ -32,7 +32,10 @@ import {
} from "@/src/features/public-api/server/traces";
import { env } from "@/src/env.mjs";
import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";
-import { TRACES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
+import {
+ LEGACY_WRITES_DEPRECATION,
+ TRACES_DEPRECATION,
+} from "@/src/features/public-api/server/deprecations";
import { clampToDataAccessDays } from "@/src/features/entitlements/server";
export default withMiddlewares(
{
@@ -45,6 +48,7 @@ export default withMiddlewares(
// Legacy POST writes a trace-create event that lands in the legacy traces
// ClickHouse table; events_only deployments expect OTel ingestion.
rejectInEventsOnlyMode: true,
+ deprecation: LEGACY_WRITES_DEPRECATION,
fn: async ({ body, auth, req, res }) => {
await telemetry();
const event = {