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

# Erase all consents for a subject (DSAR right-to-erasure)

> Soft-deletes every consent row owned by the caller whose `subject_id` matches. History rows are preserved (regulators want proof we honoured the request). Optionally pass `?site_id=<uuid>` to restrict the erasure to a single site. Returns the count of rows touched. Counts against monthly API quota.




## OpenAPI

````yaml /openapi.yaml delete /consents/by-subject/{subjectId}
openapi: 3.0.0
info:
  title: ConsentFly
  version: 1.1.0
  description: >
    API REST do ConsentFly para gerenciar consentimentos e evidências de
    privacidade em escala. Autentique cada chamada com `Authorization: Bearer
    sk-...` (API Key). Cada requisição bem-sucedida consome **1 unidade** da
    cota mensal do plano. Gere sua API Key em `/dashboard/api-keys`.
  contact: {}
servers:
  - url: https://www.consentfly.com.br/api/v1
    description: Produção
security:
  - ApiKeyAuth: []
tags:
  - name: Consents
    description: Capturar, listar, atualizar e auditar registros de consentimento.
  - name: DSAR
    description: >-
      Direito ao esquecimento por titular e recibo canônico para evidência
      regulatória.
  - name: Exports
    description: >-
      Exportação CSV em streaming síncrono ou via job assíncrono para volumes
      grandes.
paths:
  /consents/by-subject/{subjectId}:
    delete:
      tags:
        - DSAR
      summary: Erase all consents for a subject (DSAR right-to-erasure)
      description: >
        Soft-deletes every consent row owned by the caller whose `subject_id`
        matches. History rows are preserved (regulators want proof we honoured
        the request). Optionally pass `?site_id=<uuid>` to restrict the erasure
        to a single site. Returns the count of rows touched. Counts against
        monthly API quota.
      parameters:
        - name: subjectId
          in: path
          required: true
          description: Subject identifier (e.g. hashed user id from the customer)
          schema:
            type: string
        - name: site_id
          in: query
          description: Restrict erasure to a single site UUID
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/consents.EraseBySubjectResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/QuotaExceeded'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    consents.EraseBySubjectResponse:
      type: object
      description: >-
        Resultado de uma exclusão DSAR (direito ao esquecimento) por
        `subject_id`.
      properties:
        subject_id:
          type: string
          description: Identificador opaco do titular afetado.
          example: user_sha256_a1b2c3d4e5f6
        erased:
          type: integer
          description: Quantidade de consentimentos marcados como excluídos.
          example: 7
    utils.APIErrorResponse:
      type: object
      description: Envelope JSON padrão de erro da API.
      properties:
        error:
          type: string
          description: >-
            Código legível por máquina (ex. `unauthorized`, `quota_exceeded`,
            `plan_required`).
          example: unauthorized
        message:
          type: string
          description: Mensagem legível por humano. Para 5xx é genérica.
          example: Invalid or missing API key
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/utils.APIErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/utils.APIErrorResponse'
    PaymentRequired:
      description: Plan inactive (payment required)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/utils.APIErrorResponse'
    Forbidden:
      description: Forbidden (feature gate or plan limit)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/utils.APIErrorResponse'
    QuotaExceeded:
      description: Monthly API quota exhausted
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/utils.APIErrorResponse'
    InternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/utils.APIErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        Autenticação por API Key no formato `Authorization: Bearer sk-...`
        (sempre inclua o prefixo `Bearer`).

        Gere sua chave em `/dashboard/api-keys` após criar a conta e
        verificar o e-mail. A chave é exibida **uma única vez** no momento
        da criação — armazene em variável de ambiente no seu backend.
        Nunca exponha em código client-side.

````