Clear Recently Viewed
Authenticated. Hard-deletes every RecentlyViewed row for the calling user. Returns the count actually deleted. No undo.
DELETE /api/v1/discover/history โ ๐ Bearer ยท Kill-switched
Hard-deletes every RecentlyViewed row for the calling user via a single deleteMany. Returns the number of rows actually removed (zero is a normal result if the user has never viewed anyone).
Hard delete, no undo. Once gone, the rows are gone โ there's no recycle bin or "deleted" flag. The user's recommendations / "you visited" UI restarts from empty after this call.
Request
No body, no params. Identity comes from the bearer token.
| Header | Required | Notes |
|---|---|---|
Authorization: Bearer <accessToken> | โ | JWT from POST /auth/login |
Response
200 OK
{
"success": true,
"data": {
"deleted": 7
}
}The controller returns the service result { deleted: count } directly. The platform's response interceptor wraps it in { success: true, data: ... } per the standard envelope.
| Field | Type | Notes |
|---|---|---|
deleted | number | Count of RecentlyViewed rows actually removed. 0 is a normal result. |
Errors
| HTTP | code / i18nKey | Reason |
|---|---|---|
401 | (guard) | Missing / invalid bearer token |
503 | features.discover_disabled | Admin kill switch DISCOVER is active |
Side effects
prisma.recentlyViewed.deleteMany({ where: { userId } }).- Return
{ deleted: result.count }.
Code samples
curl -X DELETE https://api.bio.re/api/v1/discover/history \
-H "Authorization: Bearer $ACCESS_TOKEN"async function clearRecentlyViewed(accessToken: string): Promise<number> {
const res = await fetch('https://api.bio.re/api/v1/discover/history', {
method: 'DELETE',
headers: { Authorization: `Bearer ${accessToken}` },
});
const json = await res.json();
if (!res.ok || !json.success) {
throw Object.assign(new Error(json?.error?.message ?? 'Clear history failed'), {
code: json?.error?.code,
});
}
return json.data.deleted as number;
}import { useMutation, useQueryClient } from '@tanstack/react-query';
export function useClearRecentlyViewed() {
const qc = useQueryClient();
return useMutation({
mutationFn: async () => {
const res = await fetch('/api/v1/discover/history', { method: 'DELETE' });
const json = await res.json();
if (!res.ok || !json.success) {
throw Object.assign(new Error(json?.error?.message ?? 'Clear history failed'), {
code: json?.error?.code,
i18nKey: json?.error?.i18nKey,
});
}
return json.data.deleted as number;
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['discover', 'history'] });
},
});
}Try it
Authorization
bearer In: header
Response Body
application/json
application/json
curl -X DELETE "https://loading/api/v1/discover/history"{
"success": true
}{
"success": false,
"error": {
"code": "AUTH_UNAUTHORIZED",
"message": "Invalid credentials",
"i18nKey": "auth.login.invalid_credentials",
"i18nVars": {
"field": "email"
},
"details": [
{
"message": "email must be an email"
}
],
"correlationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
}Source
| Source | Path | Lines |
|---|---|---|
| Controller | apps/api-core/src/modules/discover/discover.controller.ts | 98โ105 (clearHistory) |
| Service | apps/api-core/src/modules/discover/discover.service.ts | 389โ392 (clearRecentlyViewed) |
| Prisma model | packages/prisma/prisma/schema.prisma | RecentlyViewed |
Get Recently Viewed
Authenticated. Returns the calling user's recently viewed creators ordered by viewedAt DESC. Active-creator filter โ inactive / suspended / vacationing creators are dropped from the read.
List Locales
Active language catalog plus a per-locale version map. Sanitized output โ only code, name, nativeName, isRtl, isDefault. Use the version map to decide when to refetch translation bundles.