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

# Attach a failing test to a failure group

> Records that a run's failing test belongs to this group, refreshing the group's last-seen rollups, and returns the derived member entry. Idempotent: re-attaching an existing member refreshes its sighting (the entry's sighting_count and last_seen reflect it). An agent attach will not resurrect a membership a human detached.



## OpenAPI

````yaml /api-reference/openapi.generated.json post /api/failure-groups/{id}/members
openapi: 3.1.0
info:
  title: Empirical API
  version: 1.0.0
  description: Programmatic access to Empirical test runs, snoozes, and more.
  contact:
    name: Empirical
    url: https://empirical.run
servers:
  - url: https://api.empirical.run
security:
  - Bearer: []
tags:
  - name: Test Runs
    description: Trigger, list, and inspect end-to-end test runs.
  - name: Test Cases
    description: >-
      Browse the Playwright test cases synced from a project's repository and
      manage their tags.
  - name: Environments
    description: >-
      Named deployment targets (slug + Playwright project filters) a project's
      tests run against.
  - name: Snoozes
    description: Temporarily suppress known test failures for specific Playwright tests.
  - name: Analytics
    description: Aggregated test-run, test-count and test-case analytics for a project.
  - name: Resources
    description: >-
      Project file resources — uploads stored in R2 and external link-type files
      (e.g. Google Sheets).
  - name: Failure Groups
    description: >-
      Durable, cross-run identities for failure modes, carrying the latest
      triage diagnosis.
  - name: Badges
    description: Public README status badge images (SVG) for project environments.
paths:
  /api/failure-groups/{id}/members:
    post:
      tags:
        - Failure Groups
      summary: Attach a failing test to a failure group
      description: >-
        Records that a run's failing test belongs to this group, refreshing the
        group's last-seen rollups, and returns the derived member entry.
        Idempotent: re-attaching an existing member refreshes its sighting (the
        entry's sighting_count and last_seen reflect it). An agent attach will
        not resurrect a membership a human detached.
      operationId: attachFailureGroupMember
      parameters:
        - schema:
            type: string
            minLength: 1
            description: Failure group ID.
          required: true
          description: Failure group ID.
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AttachFailureGroupMemberRequest'
      responses:
        '200':
          description: The attached member, derived from the membership-event log.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FailureGroupMemberResponse'
        '404':
          description: Group or test run not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Membership was detached by a human; not re-attached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    AttachFailureGroupMemberRequest:
      type: object
      properties:
        test_run_id:
          type: integer
          minimum: 1
          description: The run in which this failure was observed.
        test_case_id:
          type: string
          minLength: 1
          description: >-
            Test case ID (normalized 41-character Playwright test id) of the
            failing test.
        pw_test_id:
          type: string
          minLength: 1
          description: Deprecated alias of `test_case_id`.
          deprecated: true
      required:
        - test_run_id
    FailureGroupMemberResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            member:
              $ref: '#/components/schemas/FailureGroupMemberEntry'
          required:
            - member
          description: Response payload.
      required:
        - data
    ErrorResponse:
      type: object
      properties:
        data:
          nullable: true
          description: Always null for error responses.
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message.
          required:
            - message
          description: Error details.
      required:
        - data
        - error
    FailureGroupMemberEntry:
      type: object
      properties:
        test_case_id:
          type: string
          description: Test case ID (normalized 41-character Playwright test id).
        state:
          type: string
          enum:
            - active
            - detached
        source:
          type: string
          enum:
            - machine
            - agent
            - human
            - system
        first_seen_at:
          type: string
        first_test_run_id:
          type: integer
          nullable: true
        last_seen_at:
          type: string
        last_test_run_id:
          type: integer
          nullable: true
        last_environment_id:
          type: integer
          nullable: true
        environments:
          type: array
          items:
            type: integer
        sighting_count:
          type: integer
        chat_session_id:
          type: integer
          nullable: true
        match_run_id:
          type: string
          nullable: true
        actor_id:
          type: string
          nullable: true
        detached_at:
          type: string
          nullable: true
        detached_by:
          type: string
          nullable: true
      required:
        - test_case_id
        - state
        - source
        - first_seen_at
        - first_test_run_id
        - last_seen_at
        - last_test_run_id
        - last_environment_id
        - environments
        - sighting_count
        - chat_session_id
        - match_run_id
        - actor_id
        - detached_at
        - detached_by
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````