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

# Fold one subject into another

> Fold this subject's record into the ``into`` subject under ``mode`` (an alias the reads
then resolve through). Refused on a self-fold, a cycle, or a merge that no longer validates.



## OpenAPI

````yaml /openapi.json post /api/states/{name}/records/{target_kind}/{target_name}/{kind}/{key}/fold
openapi: 3.1.0
info:
  description: The operator HTTP surface served under /api/*.
  title: tai42-skeleton API
  version: 14.0.2
servers: []
security: []
paths:
  /api/states/{name}/records/{target_kind}/{target_name}/{kind}/{key}/fold:
    post:
      tags:
        - states
      summary: Fold one subject into another
      description: >-
        Fold this subject's record into the ``into`` subject under ``mode`` (an
        alias the reads

        then resolve through). Refused on a self-fold, a cycle, or a merge that
        no longer validates.
      operationId: post_api_states_name_records_target_kind_target_name_kind_key_fold
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
        - in: path
          name: target_kind
          required: true
          schema:
            type: string
        - in: path
          name: target_name
          required: true
          schema:
            type: string
        - in: path
          name: kind
          required: true
          schema:
            type: string
        - in: path
          name: key
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/FoldReport'
                required:
                  - data
                type: object
          description: Success.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Missing or invalid api key.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Conflict with the current resource state.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Request failed validation.
        '501':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error.
      security:
        - ApiKeyAuth: []
components:
  schemas:
    FoldReport:
      description: >-
        The ``fold_state_record`` report: the fold ``mode``, the ``from`` and
        ``into``

        subjects, whether the fold was ``already`` in place (a quiet no-op), and
        the number

        of aliases ``flattened`` onto the survivor. ``merged_members`` — the
        survivor's

        newly-filled top-level members — rides ONLY a ``merge`` fold; a
        ``switch`` omits it.

        The Python attribute for the wire ``from`` key is suffixed (``from`` is
        a keyword);

        the wire key stays ``from`` via the alias.
      properties:
        already:
          title: Already
          type: boolean
        flattened:
          title: Flattened
          type: integer
        from:
          $ref: '#/components/schemas/FoldSubjectRef'
        into:
          $ref: '#/components/schemas/FoldSubjectRef'
        merged_members:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          default: null
          title: Merged Members
        mode:
          title: Mode
          type: string
      required:
        - mode
        - from
        - into
        - already
        - flattened
      title: FoldReport
      type: object
    Error:
      properties:
        code:
          description: >-
            Stable machine-readable reason a client keys a dedicated error state
            on, present on refusals that opt in (e.g. a 501 not-configured
            refusal). Optional: absent when the error carries only a
            human-readable message.
          type: string
        error:
          type: string
      required:
        - error
      type: object
    FoldSubjectRef:
      description: One end of a fold — the ``kind`` and ``key`` of a subject.
      properties:
        key:
          title: Key
          type: string
        kind:
          title: Kind
          type: string
      required:
        - kind
        - key
      title: FoldSubjectRef
      type: object
  securitySchemes:
    ApiKeyAuth:
      in: header
      name: x-api-key
      type: apiKey

````