> ## Documentation Index
> Fetch the complete documentation index at: https://docs.member.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Record Activity

> Record a login or search activity event for the authenticated contact.

Emits the matching ``HubLoginRecorded`` / ``HubSearchRecorded`` domain
event on success.



## OpenAPI

````yaml /openapi/mio-openapi.json post /api/v1/hub/{hub_id}/activity
openapi: 3.1.0
info:
  description: >-
    Production API reference for Membership.io. Use the authored guides for
    workflows and the generated endpoint pages for exact parameters and schemas.
  title: Membership.io API
  version: 0.1.0
servers:
  - description: Production
    url: https://api.member.dev
security:
  - bearerAuth: []
paths:
  /api/v1/hub/{hub_id}/activity:
    post:
      tags:
        - activity-portal
      summary: Record Activity
      description: |-
        Record a login or search activity event for the authenticated contact.

        Emits the matching ``HubLoginRecorded`` / ``HubSearchRecorded`` domain
        event on success.
      operationId: activity_portal.post_activity_portal_post_hub_by_hub_id_activity
      parameters:
        - in: path
          name: hub_id
          required: true
          schema:
            title: Hub Id
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/ActivityEventEnvelope'
        required: true
      responses:
        '202':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/ContactHubStatsResponse'
          description: Successful Response
        '401':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/JsonApiErrorResponse'
          description: Not authenticated
        '403':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/JsonApiErrorResponse'
          description: Forbidden
        '404':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/JsonApiErrorResponse'
          description: Resource not found
        '422':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/JsonApiErrorResponse'
          description: Unprocessable entity
        '429':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/JsonApiErrorResponse'
          description: Too many requests
      security:
        - HTTPBearer: []
components:
  schemas:
    ActivityEventEnvelope:
      additionalProperties: false
      properties:
        data:
          $ref: '#/components/schemas/ActivityEventResource'
      required:
        - data
      title: ActivityEventEnvelope
      type: object
    ContactHubStatsResponse:
      additionalProperties: false
      properties:
        data:
          $ref: '#/components/schemas/ContactHubStatsResource'
      required:
        - data
      title: ContactHubStatsResponse
      type: object
    JsonApiErrorResponse:
      description: Error JSON:API response.
      properties:
        errors:
          items:
            $ref: '#/components/schemas/JsonApiError'
          title: Errors
          type: array
        meta:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Meta
      required:
        - errors
      title: JsonApiErrorResponse
      type: object
    ActivityEventResource:
      additionalProperties: false
      properties:
        attributes:
          $ref: '#/components/schemas/ActivityEventAttributes'
        type:
          const: activity_events
          title: Type
          type: string
      required:
        - type
        - attributes
      title: ActivityEventResource
      type: object
    ContactHubStatsResource:
      additionalProperties: false
      properties:
        attributes:
          $ref: '#/components/schemas/ContactHubStatsAttributes'
        id:
          title: Id
          type: string
        type:
          const: contact_hub_stats
          default: contact_hub_stats
          title: Type
          type: string
      required:
        - id
        - attributes
      title: ContactHubStatsResource
      type: object
    JsonApiError:
      properties:
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
        detail:
          anyOf:
            - type: string
            - type: 'null'
          title: Detail
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        meta:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Meta
        source:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Source
        status:
          title: Status
          type: string
        title:
          title: Title
          type: string
      required:
        - status
        - title
      title: JsonApiError
      type: object
    ActivityEventAttributes:
      additionalProperties: false
      properties:
        event_type:
          enum:
            - login
            - search
          title: Event Type
          type: string
        extras:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Extras
      required:
        - event_type
      title: ActivityEventAttributes
      type: object
    ContactHubStatsAttributes:
      additionalProperties: false
      properties:
        contact_id:
          title: Contact Id
          type: string
        created_at:
          format: date-time
          title: Created At
          type: string
        extras:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Extras
        hub_id:
          title: Hub Id
          type: string
        last_login_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Last Login At
        last_search_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Last Search At
        login_count:
          title: Login Count
          type: integer
        search_count:
          title: Search Count
          type: integer
        updated_at:
          format: date-time
          title: Updated At
          type: string
      required:
        - contact_id
        - hub_id
        - login_count
        - last_login_at
        - search_count
        - last_search_at
        - extras
        - created_at
        - updated_at
      title: ContactHubStatsAttributes
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT or mio_sk API key
      description: >-
        Send platform JWTs, contact JWTs, or team API keys as `Authorization:
        Bearer <token>`.
      scheme: bearer
      type: http
    HTTPBearer:
      scheme: bearer
      type: http

````