BIO.RE
Discover

Record Profile View

Authenticated. Upserts a RecentlyViewed row for the (user, creator) pair — refreshes viewedAt on subsequent visits. Returns whether the row was recorded.

POST /api/v1/discover/history/:creatorId — 🔑 Bearer · Kill-switched

Records that the calling user viewed a creator's profile. Upsert semantics: first view creates the row, subsequent visits update the viewedAt timestamp (move-to-front behavior in the recently-viewed list). The body is empty — userId comes from the bearer token, creatorId from the path.

Move-to-front, not append. A repeat view of the same creator doesn't insert a duplicate row — it bumps the existing row's viewedAt so it surfaces at the top of GET /discover/history. The compound unique key (userId, creatorId) makes this safe.

Validates the creator exists. The server checks creatorProfile.findUnique for the supplied creatorId before upserting; missing → 404 creator_not_found. There's no inactive-creator filter here — even suspended / vacationing creators can be recorded as viewed (the active-only filter applies on the read side, see GET /discover/history).

Request

Path parameters

ParamTypeNotes
creatorIdstringThe CreatorProfile.id being viewed (raw string, no UUID pipe)

No body.

HeaderRequiredNotes
Authorization: Bearer <accessToken>JWT from POST /auth/login

Response

200 OKApiResponseOf<RecordViewResultDto>

{
  "success": true,
  "data": {
    "recorded": true
  }
}
FieldTypeNotes
recordedbooleanAlways true on 200 — both create and update paths return this

Errors

HTTPcode / i18nKeyReason
401(guard)Missing / invalid bearer token
404discover.creator_not_foundNo CreatorProfile with this id
503features.discover_disabledAdmin kill switch DISCOVER is active

Side effects

  1. prisma.creatorProfile.findUnique({ where: { id: creatorId }, select: { id: true } }). Missing → throw creator_not_found.
  2. prisma.recentlyViewed.upsert({ where: { userId_creatorId }, update: { viewedAt: new Date() }, create: { id, userId, creatorId } }).
  3. Return { recorded: true }.

Code samples

curl -X POST https://api.bio.re/api/v1/discover/history/c1a2b3c4-d5e6-7890-abcd-ef1234567890 \
  -H "Authorization: Bearer $ACCESS_TOKEN"
async function recordCreatorView(accessToken: string, creatorId: string): Promise<void> {
  const res = await fetch(`https://api.bio.re/api/v1/discover/history/${creatorId}`, {
    method: 'POST',
    headers: { Authorization: `Bearer ${accessToken}` },
  });
  const json = await res.json();
  if (!res.ok || !json.success) {
    throw Object.assign(new Error(json?.error?.message ?? 'Record view failed'), {
      code: json?.error?.code,
    });
  }
}
import { useMutation, useQueryClient } from '@tanstack/react-query';

export function useRecordCreatorView() {
  const qc = useQueryClient();
  return useMutation({
    mutationFn: async (creatorId: string) => {
      const res = await fetch(`/api/v1/discover/history/${creatorId}`, { method: 'POST' });
      const json = await res.json();
      if (!res.ok || !json.success) {
        throw Object.assign(new Error(json?.error?.message ?? 'Record view failed'), {
          code: json?.error?.code,
          i18nKey: json?.error?.i18nKey,
        });
      }
    },
    onSuccess: () => {
      qc.invalidateQueries({ queryKey: ['discover', 'history'] });
    },
  });
}

Try it

POST
/api/v1/discover/history/{creatorId}
AuthorizationBearer <token>

In: header

Path Parameters

creatorId*string

Response Body

application/json

application/json

curl -X POST "https://loading/api/v1/discover/history/string"
{
  "success": true,
  "data": {
    "recorded": 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.ts80–88 (recordView)
DTO (response)apps/api-core/src/modules/discover/dto/discover-response.dto.ts60–63 (RecordViewResultDto)
Serviceapps/api-core/src/modules/discover/discover.service.ts364–373 (recordView)
Prisma modelspackages/prisma/prisma/schema.prismaRecentlyViewed (compound unique userId_creatorId), CreatorProfile (existence check)

On this page