BIO.RE
Discover

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.

HeaderRequiredNotes
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.

FieldTypeNotes
deletednumberCount of RecentlyViewed rows actually removed. 0 is a normal result.

Errors

HTTPcode / i18nKeyReason
401(guard)Missing / invalid bearer token
503features.discover_disabledAdmin kill switch DISCOVER is active

Side effects

  1. prisma.recentlyViewed.deleteMany({ where: { userId } }).
  2. 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

DELETE
/api/v1/discover/history
AuthorizationBearer <token>

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

SourcePathLines
Controllerapps/api-core/src/modules/discover/discover.controller.ts98โ€“105 (clearHistory)
Serviceapps/api-core/src/modules/discover/discover.service.ts389โ€“392 (clearRecentlyViewed)
Prisma modelpackages/prisma/prisma/schema.prismaRecentlyViewed

On this page