Skip to content

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

feat(api): agent-friendly deprecation responses for legacy endpoints (LFE-10895) (#15168)

Niklas Semmler7955a3edb55c
diff --git a/fern/apis/server/definition/commons.yml b/fern/apis/server/definition/commons.yml
index 048eee4251..e5abdf04c3 100644
--- a/fern/apis/server/definition/commons.yml
+++ b/fern/apis/server/definition/commons.yml
@@ -1,4 +1,22 @@
types:
+ # Migration signal attached as the top-level `_deprecation` key on responses
+ # from deprecated (legacy, pre-v4-data-model) endpoints. See LFE-10895.
+ Deprecation:
+ docs: Migration signal returned by deprecated endpoints. Optional fields are omitted when they have no value.
+ properties:
+ message:
+ type: string
+ docs: Human- and agent-readable summary of the deprecation and its replacement.
+ replacement:
+ type: optional<string>
+ docs: The replacement endpoint, e.g. "GET /api/public/v2/observations". Omitted when the endpoint is being removed without a direct replacement.
+ docsUrl:
+ type: optional<string>
+ docs: Link to the migration documentation (markdown), when available.
+ sunsetAt:
+ type: optional<string>
+ docs: ISO date after which the endpoint may stop working, when a removal date is committed.
+
# Objects
# Source: web/src/features/public-api/types/traces.ts - APITrace, APIExtendedTrace, GetTraceV1Response
Trace:
@@ -78,6 +96,7 @@ types:
scores:
type: list<ScoreV1>
docs: List of scores
+ _deprecation: optional<Deprecation>
# Source: web/src/features/public-api/types/sessions.ts - APISession
Session:
properties:
@@ -91,6 +110,7 @@ types:
extends: Session
properties:
traces: list<Trace>
+ _deprecation: optional<Deprecation>
# Source: web/src/features/public-api/types/observations.ts - APIObservation
Observation:
properties:
@@ -195,6 +215,14 @@ types:
type: nullable<double>
docs: The time to the first token in seconds
+ # Single-observation response (GET /observations/{observationId}); carries the
+ # deprecation signal without adding it to the shared ObservationsView (used as
+ # a list element and nested in TraceWithFullDetails).
+ ObservationsViewSingle:
+ extends: ObservationsView
+ properties:
+ _deprecation: optional<Deprecation>
+
# Source: web/src/features/public-api/types/observations.ts - APIObservationV2
ObservationV2:
docs: |
@@ -556,6 +584,8 @@ types:
docs: The text content of the score (1-500 characters)
Score:
discriminant: "dataType"
+ base-properties:
+ _deprecation: optional<Deprecation>
union:
NUMERIC:
type: NumericScore
@@ -725,6 +755,7 @@ types:
extends: DatasetRun
properties:
datasetRunItems: list<DatasetRunItem>
+ _deprecation: optional<Deprecation>
# Source: web/src/features/public-api/types/models.ts - APIModelDefinition
Model:
docs: |
diff --git a/fern/apis/server/definition/dataset-run-items.yml b/fern/apis/server/definition/dataset-run-items.yml
index 64ddce622a..cc3045770f 100644
--- a/fern/apis/server/definition/dataset-run-items.yml
+++ b/fern/apis/server/definition/dataset-run-items.yml
@@ -7,12 +7,18 @@ service:
base-path: /api/public
endpoints:
create:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, create experiment data via the SDK experiment runner or the OpenTelemetry endpoint at POST /api/public/otel/v1/traces."
method: POST
docs: Create a dataset run item
path: /dataset-run-items
request: CreateDatasetRunItemRequest
response: commons.DatasetRunItem
list:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, dataset run items are replaced by experiment items; use GET /api/public/experiment-items?fromStartTime=<from>&toStartTime=<to> instead."
method: GET
docs: List dataset run items
path: /dataset-run-items
@@ -58,3 +64,4 @@ types:
properties:
data: list<commons.DatasetRunItem>
meta: pagination.MetaResponse
+ _deprecation: optional<commons.Deprecation>
diff --git a/fern/apis/server/definition/datasets.yml b/fern/apis/server/definition/datasets.yml
index f1fc001da7..31d4bf5081 100644
--- a/fern/apis/server/definition/datasets.yml
+++ b/fern/apis/server/definition/datasets.yml
@@ -34,6 +34,9 @@ service:
request: CreateDatasetRequest
response: commons.Dataset
getRun:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, dataset runs are replaced by experiments; use GET /api/public/experiments instead."
method: GET
docs: Get a dataset run and its items
path: /datasets/{datasetName}/runs/{runName}
@@ -42,6 +45,9 @@ service:
runName: string
response: commons.DatasetRunWithItems
deleteRun:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, dataset runs are replaced by experiments."
method: DELETE
docs: Delete a dataset run and all its run items. This action is irreversible.
path: /datasets/{datasetName}/runs/{runName}
@@ -50,6 +56,9 @@ service:
runName: string
response: DeleteDatasetRunResponse
getRuns:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, dataset runs are replaced by experiments; use GET /api/public/experiments instead."
method: GET
docs: Get dataset runs
path: /datasets/{datasetName}/runs
@@ -86,6 +95,7 @@ types:
properties:
data: list<commons.DatasetRun>
meta: pagination.MetaResponse
+ _deprecation: optional<commons.Deprecation>
DeleteDatasetRunResponse:
properties:
message: string
diff --git a/fern/apis/server/definition/ingestion.yml b/fern/apis/server/definition/ingestion.yml
index 2b033f6c10..5c194bcb90 100644
--- a/fern/apis/server/definition/ingestion.yml
+++ b/fern/apis/server/definition/ingestion.yml
@@ -9,7 +9,7 @@ service:
batch:
availability:
status: deprecated
- message: "Use the OpenTelemetry endpoint at /api/public/otel/v1/traces instead. Learn more: https://langfuse.com/integrations/native/opentelemetry"
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. Send data via the OpenTelemetry endpoint at POST /api/public/otel/v1/traces instead. Learn more: https://langfuse.com/integrations/native/opentelemetry"
docs: |
**Legacy endpoint for batch ingestion for Langfuse Observability.**
diff --git a/fern/apis/server/definition/legacy/metrics-v1.yml b/fern/apis/server/definition/legacy/metrics-v1.yml
index c5a6925fe9..e41a2e54b6 100644
--- a/fern/apis/server/definition/legacy/metrics-v1.yml
+++ b/fern/apis/server/definition/legacy/metrics-v1.yml
@@ -7,6 +7,9 @@ service:
base-path: /api/public
endpoints:
metrics:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. Use GET /api/public/v2/metrics?query=<urlencoded json query> instead."
docs: |
Get metrics from the Langfuse project using a query object.
@@ -72,3 +75,4 @@ types:
The metrics data. Each item in the list contains the metric values and dimensions requested in the query.
Format varies based on the query parameters.
Histograms will return an array with [lower, upper, height] tuples.
+ _deprecation: optional<commons.Deprecation>
diff --git a/fern/apis/server/definition/legacy/observations-v1.yml b/fern/apis/server/definition/legacy/observations-v1.yml
index b9f6bf05cc..0e63d68098 100644
--- a/fern/apis/server/definition/legacy/observations-v1.yml
+++ b/fern/apis/server/definition/legacy/observations-v1.yml
@@ -7,6 +7,9 @@ service:
base-path: /api/public
endpoints:
get:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. Use GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to> instead."
docs: Get a observation
method: GET
path: /observations/{observationId}
@@ -14,8 +17,11 @@ service:
observationId:
type: string
docs: The unique langfuse identifier of an observation, can be an event, span or generation
- response: commons.ObservationsView
+ response: commons.ObservationsViewSingle
getMany:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. Use GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to> instead."
docs: |
Get a list of observations.
@@ -160,3 +166,4 @@ types:
properties:
data: list<commons.ObservationsView>
meta: pagination.MetaResponse
+ _deprecation: optional<commons.Deprecation>
diff --git a/fern/apis/server/definition/scores.yml b/fern/apis/server/definition/scores.yml
index 4353fbd4ec..f70b12c2e0 100644
--- a/fern/apis/server/definition/scores.yml
+++ b/fern/apis/server/definition/scores.yml
@@ -7,6 +7,9 @@ service:
base-path: /api/public/v2
endpoints:
get-many:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. Use GET /api/public/v3/scores instead."
docs: |
**Deprecated.** Use `GET /api/public/v3/scores` instead. This endpoint
is no longer available on Langfuse v4 and later.
@@ -89,6 +92,9 @@ service:
Supported operators for stringObject: =, contains, does not contain, starts with, ends with.
response: GetScoresResponse
get-by-id:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. Use GET /api/public/v3/scores with the id filter instead."
docs: |
**Deprecated.** Use `GET /api/public/v3/scores` with the `id` filter
instead. This endpoint is no longer available on Langfuse v4 and later.
@@ -156,3 +162,4 @@ types:
properties:
data: list<GetScoresResponseData>
meta: pagination.MetaResponse
+ _deprecation: optional<commons.Deprecation>
diff --git a/fern/apis/server/definition/sessions.yml b/fern/apis/server/definition/sessions.yml
index 69b1cec86e..d42a0e9043 100644
--- a/fern/apis/server/definition/sessions.yml
+++ b/fern/apis/server/definition/sessions.yml
@@ -7,6 +7,9 @@ service:
base-path: /api/public
endpoints:
list:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, read session data via GET /api/public/v2/observations?filter=<urlencoded sessionId filter>&fromStartTime=<from>&toStartTime=<to>."
docs: |
Get sessions.
@@ -37,6 +40,9 @@ service:
docs: Optional filter for sessions where the environment is one of the provided values.
response: PaginatedSessions
get:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, read session data via GET /api/public/v2/observations?filter=<urlencoded sessionId filter>&fromStartTime=<from>&toStartTime=<to>."
docs: |
Get a session.
@@ -56,3 +62,4 @@ types:
properties:
data: list<commons.Session>
meta: pagination.MetaResponse
+ _deprecation: optional<commons.Deprecation>
diff --git a/fern/apis/server/definition/trace.yml b/fern/apis/server/definition/trace.yml
index e242945b89..8e61c28115 100644
--- a/fern/apis/server/definition/trace.yml
+++ b/fern/apis/server/definition/trace.yml
@@ -7,6 +7,9 @@ service:
base-path: /api/public
endpoints:
get:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, read span and trace data via GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to>."
docs: Get a specific trace
method: GET
path: /traces/{traceId}
@@ -31,6 +34,9 @@ service:
docs: The unique langfuse identifier of the trace to delete
response: DeleteTraceResponse
list:
+ availability:
+ status: deprecated
+ message: "Langfuse v3 is deprecated; this endpoint will be removed in a future release. In Langfuse v4, read span and trace data via GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to>."
docs: Get list of traces
method: GET
path: /traces
@@ -201,6 +207,7 @@ types:
properties:
data: list<commons.TraceWithDetails>
meta: pagination.MetaResponse
+ _deprecation: optional<commons.Deprecation>
DeleteTraceResponse:
properties:
message: string
diff --git a/packages/shared/src/utils/zod.ts b/packages/shared/src/utils/zod.ts
index aeb3bebae5..65f631308b 100644
--- a/packages/shared/src/utils/zod.ts
+++ b/packages/shared/src/utils/zod.ts
@@ -158,6 +158,19 @@ export const paginationMetaResponseZod = z.object({
totalPages: z.number().int().nonnegative(),
});
+/**
+ * Top-level `_deprecation` metadata returned by legacy public API endpoints.
+ * Optional fields are omitted when empty (never null). See LFE-10895.
+ */
+export const deprecationResponseZod = z.object({
+ message: z.string(),
+ replacement: z.string().optional(),
+ docsUrl: z.string().optional(),
+ sunsetAt: z.string().optional(),
+});
+
+export type ApiDeprecationInfo = z.infer<typeof deprecationResponseZod>;
+
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
new file mode 100644
index 0000000000..d757052e1d
--- /dev/null
+++ b/web/src/__tests__/server/deprecation-signal.servertest.ts
@@ -0,0 +1,218 @@
+import {
+ createObservation,
+ createObservationsCh,
+ createOrgProjectAndApiKey,
+} from "@langfuse/shared/src/server";
+import { prisma } from "@langfuse/shared/src/db";
+import {
+ makeAPICall,
+ makeZodVerifiedAPICall,
+} from "@/src/__tests__/test-utils";
+import {
+ GetObservationsV1Response,
+ GetObservationV1Response,
+} from "@/src/features/public-api/types/observations";
+import {
+ DATASET_RUN_ITEMS_DEPRECATION,
+ DATASET_RUNS_DEPRECATION,
+ OBSERVATIONS_V1_DEPRECATION,
+ SCORES_DEPRECATION,
+ SESSIONS_DEPRECATION,
+ TRACES_DEPRECATION,
+} from "@/src/features/public-api/server/deprecations";
+import { OBSERVATIONS_API_V2_DOCS_URL } from "@/src/features/public-api/server/rateLimitUpgradePaths";
+import { env } from "@/src/env.mjs";
+import { randomUUID } from "crypto";
+
+// `_deprecation` injection is gated on LANGFUSE_MIGRATION_V4_ALLOW_PREVIEW_OPT_IN,
+// which also enables the events read path (requires ClickHouse >= 25.12). The
+// -azure / -redis-cluster CI modes intentionally run older ClickHouse with the
+// flag off, so skip there — same pattern as the other events-read-path suites.
+const maybeDescribe =
+ env.LANGFUSE_MIGRATION_V4_ALLOW_PREVIEW_OPT_IN === "true"
+ ? describe
+ : describe.skip;
+
+// LFE-10895: legacy (v3-data-model) endpoints attach a top-level `_deprecation`
+// object so coding agents get a self-correcting migration signal.
+maybeDescribe("public API deprecation signal", () => {
+ let auth: string;
+ let projectId: string;
+
+ beforeAll(async () => {
+ const fixture = await createOrgProjectAndApiKey();
+ auth = fixture.auth;
+ projectId = fixture.projectId;
+ });
+
+ it("attaches `_deprecation` to the legacy GET /observations list response", async () => {
+ const response = await makeZodVerifiedAPICall(
+ GetObservationsV1Response,
+ "GET",
+ "/api/public/observations",
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ expect(response.body._deprecation).toEqual(OBSERVATIONS_V1_DEPRECATION);
+ expect(response.body._deprecation?.replacement).toBe(
+ "GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to>",
+ );
+ });
+
+ it("carries the docs URL", async () => {
+ const response = await makeZodVerifiedAPICall(
+ GetObservationsV1Response,
+ "GET",
+ "/api/public/observations",
+ undefined,
+ auth,
+ );
+
+ // docsUrl points at the migration guidance for the endpoint family.
+ expect(response.body._deprecation?.docsUrl).toBe(
+ OBSERVATIONS_API_V2_DOCS_URL,
+ );
+ });
+
+ // Single-item response: `_deprecation` is added via `.extend()` at the
+ // response level (not on the shared item schema). makeZodVerifiedAPICall
+ // validates the strict single-item schema accepts the injected field.
+ it("attaches `_deprecation` to the legacy single GET /observations/{id}", async () => {
+ const observationId = randomUUID();
+ await createObservationsCh([
+ createObservation({
+ id: observationId,
+ project_id: projectId,
+ trace_id: randomUUID(),
+ type: "GENERATION",
+ }),
+ ]);
+
+ const response = await makeZodVerifiedAPICall(
+ GetObservationV1Response,
+ "GET",
+ `/api/public/observations/${observationId}`,
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ expect(response.body._deprecation).toEqual(OBSERVATIONS_V1_DEPRECATION);
+ });
+
+ // Scores v2 uses a non-strict response schema, so this also proves the
+ // injection works without a schema edit on the response type.
+ it("attaches `_deprecation` to the legacy GET /v2/scores list response", async () => {
+ const response = await makeAPICall(
+ "GET",
+ "/api/public/v2/scores",
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ expect((response.body as Record<string, unknown>)._deprecation).toEqual(
+ SCORES_DEPRECATION,
+ );
+ });
+
+ // Traces is being removed; it points at observations v2 as a soft
+ // replacement for reading span/trace data in v4.
+ it("attaches `_deprecation` with the observations-v2 soft replacement to legacy GET /traces", async () => {
+ const response = await makeAPICall(
+ "GET",
+ "/api/public/traces",
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ const deprecation = (response.body as Record<string, unknown>)._deprecation;
+ // toEqual against the constant covers `replacement` (incl. query params).
+ expect(deprecation).toEqual(TRACES_DEPRECATION);
+ });
+
+ // Sessions is deprecated and not replaced, so `_deprecation` is message-only.
+ it("attaches a replacement-less `_deprecation` to legacy GET /sessions", async () => {
+ const response = await makeAPICall(
+ "GET",
+ "/api/public/sessions",
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ const deprecation = (response.body as Record<string, unknown>)._deprecation;
+ expect(deprecation).toEqual(SESSIONS_DEPRECATION);
+ expect((deprecation as Record<string, unknown>)?.replacement).toBe(
+ "GET /api/public/v2/observations?filter=<urlencoded sessionId filter>&fromStartTime=<from>&toStartTime=<to>",
+ );
+ });
+
+ // Dataset run items (Group C) → experiment items. Needs a real dataset + run
+ // (the endpoint 404s otherwise); an empty run returns an empty list + signal.
+ it("attaches `_deprecation` to the legacy GET /dataset-run-items list response", async () => {
+ const dataset = await prisma.dataset.create({
+ data: { name: `deprecation-test-${randomUUID()}`, projectId },
+ });
+ const run = await prisma.datasetRuns.create({
+ data: { name: `run-${randomUUID()}`, datasetId: dataset.id, projectId },
+ });
+
+ const response = await makeAPICall(
+ "GET",
+ `/api/public/dataset-run-items?datasetId=${dataset.id}&runName=${run.name}`,
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ expect((response.body as Record<string, unknown>)._deprecation).toEqual(
+ DATASET_RUN_ITEMS_DEPRECATION,
+ );
+ });
+
+ it("attaches `_deprecation` to the legacy GET /datasets/{name}/runs list response", async () => {
+ const dataset = await prisma.dataset.create({
+ data: { name: `deprecation-test-${randomUUID()}`, projectId },
+ });
+ await prisma.datasetRuns.create({
+ data: { name: `run-${randomUUID()}`, datasetId: dataset.id, projectId },
+ });
+
+ const response = await makeAPICall(
+ "GET",
+ `/api/public/datasets/${encodeURIComponent(dataset.name)}/runs`,
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ expect((response.body as Record<string, unknown>)._deprecation).toEqual(
+ DATASET_RUNS_DEPRECATION,
+ );
+ });
+
+ it("attaches `_deprecation` to the legacy single GET /datasets/{name}/runs/{runName}", async () => {
+ const dataset = await prisma.dataset.create({
+ data: { name: `deprecation-test-${randomUUID()}`, projectId },
+ });
+ const run = await prisma.datasetRuns.create({
+ data: { name: `run-${randomUUID()}`, datasetId: dataset.id, projectId },
+ });
+
+ const response = await makeAPICall(
+ "GET",
+ `/api/public/datasets/${encodeURIComponent(dataset.name)}/runs/${encodeURIComponent(run.name)}`,
+ undefined,
+ auth,
+ );
+
+ expect(response.status).toBe(200);
+ expect((response.body as Record<string, unknown>)._deprecation).toEqual(
+ DATASET_RUNS_DEPRECATION,
+ );
+ });
+});
diff --git a/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts b/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts
index 404c1c47f2..6b3a154060 100644
--- a/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts
+++ b/web/src/features/public-api/server/createAuthedProjectAPIRoute.ts
@@ -10,7 +10,11 @@ import {
traceException,
logger,
} from "@langfuse/shared/src/server";
-import { PayloadTooLargeError, type RateLimitResource } from "@langfuse/shared";
+import {
+ PayloadTooLargeError,
+ type RateLimitResource,
+ type ApiDeprecationInfo,
+} from "@langfuse/shared";
import { RateLimitService } from "@/src/features/public-api/server/RateLimitService";
import { type RateLimitUpgradePath } from "@/src/features/public-api/server/rateLimitUpgradePaths";
import { contextWithLangfuseProps } from "@langfuse/shared/src/server";
@@ -26,6 +30,7 @@ import {
type PublicApiErrorContract,
} from "@/src/features/public-api/server/unstable-public-api-error-contract";
import { clickHouseRouteForRequest } from "@/src/features/public-api/server/clickHouseRequestTags";
+import { attachDeprecation } from "@/src/features/public-api/server/deprecations";
/** Access levels that can be accepted by project-scoped API routes. */
type RouteAccessLevel = Exclude<ApiAccessLevel, "organization">;
@@ -81,6 +86,8 @@ export type AuthedProjectAPIRouteConfig<
* events_only mode and would silently return stale or empty data.
*/
rejectInEventsOnlyMode?: boolean;
+ /** Stamps a top-level `_deprecation` object onto responses (LFE-10895). */
+ deprecation?: ApiDeprecationInfo;
fn: (params: {
query: z.infer<TQuery>;
body: z.infer<TBody>;
@@ -305,6 +312,14 @@ export const createAuthedProjectAPIRoute = <
routeConfig: AuthedProjectAPIRouteConfig<TQuery, TBody, TResponse>,
): ((req: NextApiRequest, res: NextApiResponse) => Promise<void>) => {
return async (req: NextApiRequest, res: NextApiResponse) => {
+ // Only surface deprecation notices on deployments on (or opting into) v4.
+ // Self-hosted deployments still on v3 (opt-in unset/false) should not see
+ // them yet, so gate the injected `_deprecation` on the preview flag.
+ const deprecation =
+ env.LANGFUSE_MIGRATION_V4_ALLOW_PREVIEW_OPT_IN === "true"
+ ? routeConfig.deprecation
+ : undefined;
+
// Short-circuit routes that read from legacy traces/observations tables
// when the deployment is in events_only mode — those tables are no longer
// populated, so the response would be stale or empty. Returning 404 keeps
@@ -313,10 +328,15 @@ export const createAuthedProjectAPIRoute = <
routeConfig.rejectInEventsOnlyMode &&
env.LANGFUSE_MIGRATION_V4_WRITE_MODE === "events_only"
) {
- 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",
- });
+ 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,
+ ),
+ );
return;
}
@@ -466,7 +486,7 @@ export const createAuthedProjectAPIRoute = <
);
try {
- res.json(response || { message: "OK" });
+ res.json(attachDeprecation(response || { message: "OK" }, deprecation));
} catch (error) {
if (isJsonStringTooLargeError(error)) {
throw new PayloadTooLargeError();
diff --git a/web/src/features/public-api/server/deprecations.ts b/web/src/features/public-api/server/deprecations.ts
new file mode 100644
index 0000000000..ec7c8c759f
--- /dev/null
+++ b/web/src/features/public-api/server/deprecations.ts
@@ -0,0 +1,102 @@
+import { type ApiDeprecationInfo } from "@langfuse/shared";
+import { OBSERVATIONS_API_V2_DOCS_URL } from "./rateLimitUpgradePaths";
+
+// LFE-10895. 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.
+
+// Shared deprecation reason — references the deprecated Langfuse v3 system
+// version (not an API version). Customer-facing wording lives here — edit once.
+const V3_NOTICE = `Langfuse v3 is deprecated; this endpoint will be removed in a future release.`;
+
+// v4 replacement endpoints, referenced by both the message and `replacement`.
+// Placeholder style matches rateLimitUpgradePaths (<from>, <to>, filters).
+const REPLACEMENT = {
+ observationsV2:
+ "GET /api/public/v2/observations?fromStartTime=<from>&toStartTime=<to>",
+ observationsV2BySession:
+ "GET /api/public/v2/observations?filter=<urlencoded sessionId filter>&fromStartTime=<from>&toStartTime=<to>",
+ scoresV3: "GET /api/public/v3/scores",
+ metricsV2: "GET /api/public/v2/metrics?query=<urlencoded json query>",
+ otelTraces: "POST /api/public/otel/v1/traces",
+ experimentItems:
+ "GET /api/public/experiment-items?fromStartTime=<from>&toStartTime=<to>",
+ experiments: "GET /api/public/experiments",
+} as const;
+
+// 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,
+ scoresV3:
+ "https://langfuse.com/docs/api-and-data-platform/features/scores-api",
+ metricsV2: "https://langfuse.com/docs/metrics/features/metrics-api",
+ compatibility: "https://langfuse.com/docs/compatibility",
+ otel: "https://langfuse.com/integrations/native/opentelemetry",
+} as const;
+
+export const OBSERVATIONS_V1_DEPRECATION: ApiDeprecationInfo = {
+ message: `${V3_NOTICE} Use ${REPLACEMENT.observationsV2} instead.`,
+ replacement: REPLACEMENT.observationsV2,
+ docsUrl: DOCS.observationsV2,
+};
+
+// 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}.`,
+ replacement: REPLACEMENT.observationsV2,
+ docsUrl: DOCS.observationsV2,
+};
+
+// 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}.`,
+ replacement: REPLACEMENT.observationsV2BySession,
+ docsUrl: DOCS.observationsV2,
+};
+
+export const SCORES_DEPRECATION: ApiDeprecationInfo = {
+ message: `${V3_NOTICE} Use ${REPLACEMENT.scoresV3} instead.`,
+ replacement: REPLACEMENT.scoresV3,
+ docsUrl: DOCS.scoresV3,
+};
+
+export const METRICS_DEPRECATION: ApiDeprecationInfo = {
+ message: `${V3_NOTICE} Use ${REPLACEMENT.metricsV2} instead.`,
+ replacement: REPLACEMENT.metricsV2,
+ docsUrl: DOCS.metricsV2,
+};
+
+// 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.`,
+ replacement: REPLACEMENT.experimentItems,
+ docsUrl: DOCS.compatibility,
+};
+
+// 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.`,
+ replacement: REPLACEMENT.experiments,
+ docsUrl: DOCS.compatibility,
+};
+
+// 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.
+export function attachDeprecation(
+ body: unknown,
+ deprecation: ApiDeprecationInfo | undefined,
+): unknown {
+ if (
+ !deprecation ||
+ typeof body !== "object" ||
+ body === null ||
+ Array.isArray(body)
+ ) {
+ return body;
+ }
+ return { ...body, _deprecation: deprecation };
+}
diff --git a/web/src/features/public-api/types/datasets.ts b/web/src/features/public-api/types/datasets.ts
index dab9723a25..dfb1001aea 100644
--- a/web/src/features/public-api/types/datasets.ts
+++ b/web/src/features/public-api/types/datasets.ts
@@ -1,4 +1,5 @@
import {
+ deprecationResponseZod,
jsonSchema,
publicApiPaginationZod,
paginationZod,
@@ -178,6 +179,7 @@ export const GetDatasetRunsV1Response = z
.object({
data: z.array(APIDatasetRun),
meta: paginationMetaResponseZod,
+ _deprecation: deprecationResponseZod.optional(),
})
.strict();
@@ -188,6 +190,7 @@ export const GetDatasetRunV1Query = z.object({
});
export const GetDatasetRunV1Response = APIDatasetRun.extend({
datasetRunItems: z.array(APIDatasetRunItem),
+ _deprecation: deprecationResponseZod.optional(),
}).strict();
export const publicApiIdSchema = z
@@ -282,6 +285,7 @@ export const GetDatasetRunItemsV1Response = z
.object({
data: z.array(APIDatasetRunItem),
meta: paginationMetaResponseZod,
+ _deprecation: deprecationResponseZod.optional(),
})
.strict();
diff --git a/web/src/features/public-api/types/metrics.ts b/web/src/features/public-api/types/metrics.ts
index 620322341b..cf23d54088 100644
--- a/web/src/features/public-api/types/metrics.ts
+++ b/web/src/features/public-api/types/metrics.ts
@@ -1,4 +1,5 @@
import {
+ deprecationResponseZod,
InvalidRequestError,
paginationMetaResponseZod,
publicApiPaginationZod,
@@ -194,5 +195,6 @@ export const GetMetricsDailyV1Response = z
.strict(),
),
meta: paginationMetaResponseZod,
+ _deprecation: deprecationResponseZod.optional(),
})
.strict();
diff --git a/web/src/features/public-api/types/observations.ts b/web/src/features/public-api/types/observations.ts
index 72ace86fff..da899c7939 100644
--- a/web/src/features/public-api/types/observations.ts
+++ b/web/src/features/public-api/types/observations.ts
@@ -1,6 +1,7 @@
import {
type Observation,
commaSeparatedEnumArray,
+ deprecationResponseZod,
type EventsObservation,
OBSERVATION_FIELD_GROUPS_PUBLIC_API,
ObservationLevel,
@@ -234,6 +235,7 @@ export const GetObservationsV1Response = z
.object({
data: z.array(APIObservation),
meta: paginationMetaResponseZod,
+ _deprecation: deprecationResponseZod.optional(),
})
.strict();
@@ -242,8 +244,11 @@ export const GetObservationV1Query = z.object({
observationId: z.string(),
useEventsTable: useEventsTableSchema,
});
-/** @alias */
-export const GetObservationV1Response = APIObservation;
+// `_deprecation` at the response level, not on the shared `APIObservation`
+// (which is also the list element type).
+export const GetObservationV1Response = APIObservation.extend({
+ _deprecation: deprecationResponseZod.optional(),
+});
/**
* Cursor schema for v2 observations pagination
diff --git a/web/src/features/public-api/types/sessions.ts b/web/src/features/public-api/types/sessions.ts
index cb11fc38da..fa2fd0cf8c 100644
--- a/web/src/features/public-api/types/sessions.ts
+++ b/web/src/features/public-api/types/sessions.ts
@@ -1,5 +1,6 @@
import { APITrace } from "@/src/features/public-api/types/traces";
import {
+ deprecationResponseZod,
paginationMetaResponseZod,
publicApiPaginationZod,
} from "@langfuse/shared";
@@ -35,6 +36,7 @@ export const GetSessionsV1Response = z
.object({
data: z.array(APISession),
meta: paginationMetaResponseZod,
+ _deprecation: deprecationResponseZod.optional(),
})
.strict();
@@ -44,4 +46,5 @@ export const GetSessionV1Query = z.object({
});
export const GetSessionV1Response = APISession.extend({
traces: z.array(APITrace),
+ _deprecation: deprecationResponseZod.optional(),
}).strict();
diff --git a/web/src/features/public-api/types/traces.ts b/web/src/features/public-api/types/traces.ts
index 23e2fb3397..2b07748f94 100644
--- a/web/src/features/public-api/types/traces.ts
+++ b/web/src/features/public-api/types/traces.ts
@@ -2,6 +2,7 @@ import { APIObservation } from "@/src/features/public-api/types/observations";
import {
APIScoreSchemaV1,
commaSeparatedEnumArray,
+ deprecationResponseZod,
paginationMetaResponseZod,
orderBy,
optionalJsonParam,
@@ -90,6 +91,7 @@ export const GetTracesV1Response = z
.object({
data: z.array(APIExtendedTrace),
meta: paginationMetaResponseZod,
+ _deprecation: deprecationResponseZod.optional(),
})
.strict();
@@ -107,6 +109,7 @@ export const GetTraceV1Query = z.object({
export const GetTraceV1Response = APIExtendedTrace.extend({
scores: z.array(APIScoreSchemaV1),
observations: z.array(APIObservation),
+ _deprecation: deprecationResponseZod.optional(),
}).strict();
// DELETE /api/public/traces/{traceId}
diff --git a/web/src/pages/api/public/dataset-run-items.ts b/web/src/pages/api/public/dataset-run-items.ts
index ca1c2f8e09..3909f3a6e5 100644
--- a/web/src/pages/api/public/dataset-run-items.ts
+++ b/web/src/pages/api/public/dataset-run-items.ts
@@ -10,6 +10,7 @@ import {
createDatasetRunItemForApi,
listDatasetRunItemsForApi,
} from "@/src/features/datasets/server/publicDatasetService";
+import { DATASET_RUN_ITEMS_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
POST: createAuthedProjectAPIRoute({
@@ -29,6 +30,7 @@ export default withMiddlewares({
name: "Get Dataset Run Items",
querySchema: GetDatasetRunItemsV1Query,
responseSchema: GetDatasetRunItemsV1Response,
+ deprecation: DATASET_RUN_ITEMS_DEPRECATION,
rateLimitResource: "datasets",
// Reads from the legacy dataset_run_items ClickHouse table, which is no
// longer populated in events_only mode; GET /api/public/experiment-items
diff --git a/web/src/pages/api/public/datasets/[name]/runs/[runName].ts b/web/src/pages/api/public/datasets/[name]/runs/[runName].ts
index 8e0907eb24..66d2cd8142 100644
--- a/web/src/pages/api/public/datasets/[name]/runs/[runName].ts
+++ b/web/src/pages/api/public/datasets/[name]/runs/[runName].ts
@@ -10,12 +10,14 @@ import {
deleteDatasetRunForApi,
getDatasetRunForApi,
} from "@/src/features/datasets/server/publicDatasetService";
+import { DATASET_RUNS_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "get-dataset-run",
querySchema: GetDatasetRunV1Query,
responseSchema: GetDatasetRunV1Response,
+ deprecation: DATASET_RUNS_DEPRECATION,
rateLimitResource: "datasets",
// Embeds run items read from the legacy dataset_run_items ClickHouse
// table, which is no longer populated in events_only mode;
diff --git a/web/src/pages/api/public/datasets/[name]/runs/index.ts b/web/src/pages/api/public/datasets/[name]/runs/index.ts
index 4a4fe42f2a..34815963a5 100644
--- a/web/src/pages/api/public/datasets/[name]/runs/index.ts
+++ b/web/src/pages/api/public/datasets/[name]/runs/index.ts
@@ -5,12 +5,14 @@ import {
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
import { listDatasetRunsForApi } from "@/src/features/datasets/server/publicDatasetService";
+import { DATASET_RUNS_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "get-dataset-runs",
querySchema: GetDatasetRunsV1Query,
responseSchema: GetDatasetRunsV1Response,
+ deprecation: DATASET_RUNS_DEPRECATION,
rateLimitResource: "datasets",
// Lists legacy dataset runs whose items live in the dataset_run_items
// ClickHouse table, which is no longer populated in events_only mode;
diff --git a/web/src/pages/api/public/metrics/daily.ts b/web/src/pages/api/public/metrics/daily.ts
index 7278fef22e..5ef2f7097a 100644
--- a/web/src/pages/api/public/metrics/daily.ts
+++ b/web/src/pages/api/public/metrics/daily.ts
@@ -8,12 +8,14 @@ import {
generateDailyMetrics,
getDailyMetricsCount,
} from "@/src/features/public-api/server/dailyMetrics";
+import { METRICS_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "Get Daily Metrics",
querySchema: GetMetricsDailyV1Query,
responseSchema: GetMetricsDailyV1Response,
+ deprecation: METRICS_DEPRECATION,
rateLimitResource: "public-api-daily-metrics-legacy",
// Aggregates over the legacy traces and observations tables without an
// events_full fallback.
diff --git a/web/src/pages/api/public/metrics/index.ts b/web/src/pages/api/public/metrics/index.ts
index a5b5f41269..2a25428698 100644
--- a/web/src/pages/api/public/metrics/index.ts
+++ b/web/src/pages/api/public/metrics/index.ts
@@ -9,6 +9,7 @@ import {
GetMetricsV1Response,
} from "@/src/features/public-api/types/metrics";
import { executeQuery } from "@langfuse/shared/query/server";
+import { METRICS_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares(
{
GET: createAuthedProjectAPIRoute({
@@ -16,6 +17,7 @@ export default withMiddlewares(
rateLimitResource: "public-api-metrics",
querySchema: GetMetricsV1Query,
responseSchema: GetMetricsV1Response,
+ deprecation: METRICS_DEPRECATION,
// v1 metrics executes QueryBuilder against the legacy traces/observations
// tables; the v2 endpoint at /api/public/v2/metrics targets events_full.
rejectInEventsOnlyMode: true,
diff --git a/web/src/pages/api/public/observations/[observationId].ts b/web/src/pages/api/public/observations/[observationId].ts
index c02e658ecf..b191d821f9 100644
--- a/web/src/pages/api/public/observations/[observationId].ts
+++ b/web/src/pages/api/public/observations/[observationId].ts
@@ -16,6 +16,7 @@ import {
getObservationByIdFromEventsTable,
} from "@langfuse/shared/src/server";
import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";
+import { OBSERVATIONS_V1_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares(
{
@@ -27,6 +28,7 @@ export default withMiddlewares(
responseSchema: GetObservationV1Response,
rateLimitUpgradePath: legacyPublicApiRateLimitUpgradePaths.observationGet,
rejectInEventsOnlyMode: true,
+ deprecation: OBSERVATIONS_V1_DEPRECATION,
fn: async ({ query, auth }) => {
const clickhouseObservation = query.useEventsTable
? await getObservationByIdFromEventsTable({
diff --git a/web/src/pages/api/public/observations/index.ts b/web/src/pages/api/public/observations/index.ts
index 32ac031208..b5c808c09b 100644
--- a/web/src/pages/api/public/observations/index.ts
+++ b/web/src/pages/api/public/observations/index.ts
@@ -20,6 +20,7 @@ import {
getObservationsCountForPublicApi,
} from "@/src/features/public-api/server/observations";
import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";
+import { OBSERVATIONS_V1_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares(
{
@@ -32,6 +33,7 @@ export default withMiddlewares(
rateLimitUpgradePath:
legacyPublicApiRateLimitUpgradePaths.observationsList,
rejectInEventsOnlyMode: true,
+ deprecation: OBSERVATIONS_V1_DEPRECATION,
fn: async ({ query, auth }) => {
const filterProps = {
projectId: auth.scope.projectId,
diff --git a/web/src/pages/api/public/scores/[scoreId].ts b/web/src/pages/api/public/scores/[scoreId].ts
index 685a426d6d..84b26ad471 100644
--- a/web/src/pages/api/public/scores/[scoreId].ts
+++ b/web/src/pages/api/public/scores/[scoreId].ts
@@ -10,12 +10,14 @@ import {
} from "@langfuse/shared";
import { logger, traceException } from "@langfuse/shared/src/server";
import { ScoresApiService } from "@/src/features/public-api/server/scores-api-service";
+import { SCORES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "Get Score",
querySchema: GetScoreQueryV1,
responseSchema: GetScoreResponseV1,
+ deprecation: SCORES_DEPRECATION,
rejectInEventsOnlyMode: true,
fn: async ({ query, auth }) => {
const scoresApiService = new ScoresApiService("v1");
diff --git a/web/src/pages/api/public/scores/index.ts b/web/src/pages/api/public/scores/index.ts
index d326f5d8b8..27cc256b35 100644
--- a/web/src/pages/api/public/scores/index.ts
+++ b/web/src/pages/api/public/scores/index.ts
@@ -13,6 +13,7 @@ import {
} from "@langfuse/shared/src/server";
import { ForbiddenError } from "@langfuse/shared";
import { ScoresApiService } from "@/src/features/public-api/server/scores-api-service";
+import { SCORES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
import { randomUUID } from "crypto";
export default withMiddlewares({
@@ -63,6 +64,7 @@ export default withMiddlewares({
name: "/api/public/scores",
querySchema: GetScoresQueryV1,
responseSchema: GetScoresResponseV1,
+ deprecation: SCORES_DEPRECATION,
rejectInEventsOnlyMode: true,
fn: async ({ query, auth }) => {
const scoresApiService = new ScoresApiService("v1");
diff --git a/web/src/pages/api/public/sessions/[sessionId].ts b/web/src/pages/api/public/sessions/[sessionId].ts
index 31b873d73b..716bba36ba 100644
--- a/web/src/pages/api/public/sessions/[sessionId].ts
+++ b/web/src/pages/api/public/sessions/[sessionId].ts
@@ -8,10 +8,12 @@ import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/cr
import { LangfuseNotFoundError } from "@langfuse/shared";
import { getTracesBySessionId } from "@langfuse/shared/src/server";
import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";
+import { SESSIONS_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "Get Session",
+ deprecation: SESSIONS_DEPRECATION,
rateLimitResource: "public-api-legacy",
querySchema: GetSessionV1Query,
responseSchema: GetSessionV1Response,
diff --git a/web/src/pages/api/public/sessions/index.ts b/web/src/pages/api/public/sessions/index.ts
index 61c8194e54..e0124becd8 100644
--- a/web/src/pages/api/public/sessions/index.ts
+++ b/web/src/pages/api/public/sessions/index.ts
@@ -6,10 +6,12 @@ import {
import { withMiddlewares } from "@/src/features/public-api/server/withMiddlewares";
import { createAuthedProjectAPIRoute } from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";
+import { SESSIONS_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "Get Sessions",
+ deprecation: SESSIONS_DEPRECATION,
rateLimitResource: "public-api-legacy",
querySchema: GetSessionsV1Query,
responseSchema: GetSessionsV1Response,
diff --git a/web/src/pages/api/public/traces/[traceId].ts b/web/src/pages/api/public/traces/[traceId].ts
index 1210ca11df..a604336e1d 100644
--- a/web/src/pages/api/public/traces/[traceId].ts
+++ b/web/src/pages/api/public/traces/[traceId].ts
@@ -28,11 +28,13 @@ import {
import Decimal from "decimal.js";
import { auditLog } from "@/src/features/audit-logs/auditLog";
import { legacyPublicApiRateLimitUpgradePaths } from "@/src/features/public-api/server/rateLimitUpgradePaths";
+import { TRACES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares(
{
GET: createAuthedProjectAPIRoute({
name: "Get Single Trace",
+ deprecation: TRACES_DEPRECATION,
rateLimitResource: "public-api-legacy",
querySchema: GetTraceV1Query,
responseSchema: GetTraceV1Response,
diff --git a/web/src/pages/api/public/traces/index.ts b/web/src/pages/api/public/traces/index.ts
index 64e01c0f9d..907f2cdb62 100644
--- a/web/src/pages/api/public/traces/index.ts
+++ b/web/src/pages/api/public/traces/index.ts
@@ -32,6 +32,7 @@ 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";
export default withMiddlewares(
{
@@ -80,6 +81,7 @@ export default withMiddlewares(
rateLimitResource: "public-api-legacy",
querySchema: GetTracesV1Query,
responseSchema: GetTracesV1Response,
+ deprecation: TRACES_DEPRECATION,
rateLimitUpgradePath: legacyPublicApiRateLimitUpgradePaths.tracesList,
rejectInEventsOnlyMode: true,
fn: async ({ query, auth }) => {
diff --git a/web/src/pages/api/public/v2/scores/[scoreId].ts b/web/src/pages/api/public/v2/scores/[scoreId].ts
index 618c643563..435161a807 100644
--- a/web/src/pages/api/public/v2/scores/[scoreId].ts
+++ b/web/src/pages/api/public/v2/scores/[scoreId].ts
@@ -8,12 +8,14 @@ import {
LangfuseNotFoundError,
} from "@langfuse/shared";
import { logger, traceException } from "@langfuse/shared/src/server";
+import { SCORES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "Get Score",
querySchema: GetScoreQueryV2,
responseSchema: GetScoreResponseV2,
+ deprecation: SCORES_DEPRECATION,
rejectInEventsOnlyMode: true,
fn: async ({ query, auth }) => {
const scoresApiService = new ScoresApiService("v2");
diff --git a/web/src/pages/api/public/v2/scores/index.ts b/web/src/pages/api/public/v2/scores/index.ts
index 86bf9e5eff..d5f50c9744 100644
--- a/web/src/pages/api/public/v2/scores/index.ts
+++ b/web/src/pages/api/public/v2/scores/index.ts
@@ -7,12 +7,14 @@ import {
InvalidRequestError,
} from "@langfuse/shared";
import { ScoresApiService } from "@/src/features/public-api/server/scores-api-service";
+import { SCORES_DEPRECATION } from "@/src/features/public-api/server/deprecations";
export default withMiddlewares({
GET: createAuthedProjectAPIRoute({
name: "/api/public/scores",
querySchema: GetScoresQueryV2,
responseSchema: GetScoresResponseV2,
+ deprecation: SCORES_DEPRECATION,
rejectInEventsOnlyMode: true,
fn: async ({ query, auth }) => {
// Validate that trace filters are not used when trace field is excluded