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

# Delete User

> Deletes a user account, checks for suspension reports and OTP verification.

<Tip>To request OTP, keep the `code` empty.</Tip>
<Tip> To verify the OTP and proceed to deletion, pass the `code` in the body.</Tip>

## Delete User User Flow

<Steps>
  <Step title="OTP Request">
    The user requests OTP to delete account.
  </Step>

  <Step title="Report Suspension Checking">
    If the user has any of the following, this **process will fail** and **no OTP will be generated**:

    * A report marked with `reviewing`/`suspended` status;
    * The user `isSuspended` is true;
    * The user has a post with `isSuspended` is true.
  </Step>

  <Step title="OTP Creation">
    An OTP is sent to the user's email or phone. If the user has both an email and a phone number, the OTP will be sent to the email.
  </Step>

  <Step title="OTP Verification">
    The OTP is verified, and the account with all linked data are deleted.
  </Step>
</Steps>


## OpenAPI

````yaml DELETE /user
openapi: 3.0.1
info:
  title: User Authentication API
  version: 1.0.0
  description: API for user registration, OTP request, and OTP verification
servers:
  - url: https://our-secret-api-url.com
security: []
paths:
  /user:
    delete:
      summary: Delete a user account
      description: >-
        Deletes a user account, checks for suspension reports and OTP
        verification.
      parameters:
        - $ref: '#/components/parameters/X-API-KEY'
      requestBody:
        description: Optional OTP code for user account deletion.
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                code:
                  type: string
                  description: OTP code for verifying the deletion request.
                  example: '123456'
      responses:
        '200':
          description: User account deleted successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: boolean
                    description: Indicates whether the deletion was successful.
        '400':
          description: Bad Request - Invalid OTP or missing necessary user data.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Detailed error message.
        '401':
          description: >-
            Unauthorized - Account cannot be deleted due to ongoing report
            review or suspension.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Detailed error message.
        '404':
          description: Not Found - User not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Detailed error message.
        '500':
          description: Internal Server Error - General server error or deletion failure.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Detailed error message.
      security:
        - bearerAuth: []
components:
  parameters:
    X-API-KEY:
      name: X-API-KEY
      description: API key required for authentication
      in: header
      required: true
      schema:
        type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````