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

# Delete a document

> Un-tags a document from the case (metadata only); the stored blob is left for history. Scoped to the case so a widget can only remove its own files.

While an information request is open this accepts ONLY a file the applicant uploaded during the round, into a document group that request asked to be re-uploaded. Any other group, every owner government ID, and the files the group already held when the request was sent are a 409 `not_requested`: those are what the checks ran on, and removing one would answer the request by emptying the group. So an upload can always be taken back here, and the document being replaced cannot be.

The upload endpoint (POST /api/v4/upload/kyb/{publicId}/documents, served by docver-upload) applies the group half of the rule with the same code, but NOT the per-file half: a single-file group replaces rather than accumulates, so uploading into one supersedes whatever it held, the requested document included. A superseded file is not deletable here either: it stays on the case as history (`superseded_at` in the widget state) and this endpoint only ever matches a live file, so it answers 404.

An answer to a CUSTOM ask is taken back here too, judged by its ask instead of by the group rules above: it fills no document slot, so there is no group to have been reopened and no snapshot to protect. It is removable while the round holding its ask is live, and it is un-tagged from that ask alone, leaving the other answers to the same ask in place. An answer to an ask the round no longer holds open is a 409 `not_requested`. A sample the officer attached to an ask is not the applicant's to remove: that, and any ask file once the round is over, is an opaque 404.



## OpenAPI

````yaml https://api.dataspike.io/openapi/kyb/public.json delete /api/v4/kyb/widget/{publicId}/documents/{documentId}
openapi: 3.1.0
info:
  description: Know Your Business (KYB) — case creation and the embedded onboarding widget.
  title: Dataspike KYB API
  version: '1.0'
servers: []
security: []
paths:
  /api/v4/kyb/widget/{publicId}/documents/{documentId}:
    delete:
      tags:
        - KYB Widget
      summary: Delete a document
      description: >-
        Un-tags a document from the case (metadata only); the stored blob is
        left for history. Scoped to the case so a widget can only remove its own
        files.


        While an information request is open this accepts ONLY a file the
        applicant uploaded during the round, into a document group that request
        asked to be re-uploaded. Any other group, every owner government ID, and
        the files the group already held when the request was sent are a 409
        `not_requested`: those are what the checks ran on, and removing one
        would answer the request by emptying the group. So an upload can always
        be taken back here, and the document being replaced cannot be.


        The upload endpoint (POST /api/v4/upload/kyb/{publicId}/documents,
        served by docver-upload) applies the group half of the rule with the
        same code, but NOT the per-file half: a single-file group replaces
        rather than accumulates, so uploading into one supersedes whatever it
        held, the requested document included. A superseded file is not
        deletable here either: it stays on the case as history (`superseded_at`
        in the widget state) and this endpoint only ever matches a live file, so
        it answers 404.


        An answer to a CUSTOM ask is taken back here too, judged by its ask
        instead of by the group rules above: it fills no document slot, so there
        is no group to have been reopened and no snapshot to protect. It is
        removable while the round holding its ask is live, and it is un-tagged
        from that ask alone, leaving the other answers to the same ask in place.
        An answer to an ask the round no longer holds open is a 409
        `not_requested`. A sample the officer attached to an ask is not the
        applicant's to remove: that, and any ask file once the round is over, is
        an opaque 404.
      operationId: DELETE_/api/v4/kyb/widget/:publicId/documents/:documentId
      parameters:
        - description: KYB case public id.
          in: path
          name: publicId
          required: true
          schema:
            type: string
        - description: Document id.
          in: path
          name: documentId
          required: true
          schema:
            type: string
      responses:
        '204':
          description: No Content
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrCaseNotFound'
            application/xml:
              schema:
                $ref: '#/components/schemas/ErrCaseNotFound'
          description: Case or document not found.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrNotRequested'
            application/xml:
              schema:
                $ref: '#/components/schemas/ErrNotRequested'
          description: >-
            `not_requested` while an information request is open, or
            `case_locked` when the case does not accept writes at all.
components:
  schemas:
    ErrCaseNotFound:
      description: ErrCaseNotFound schema
      example:
        code: case_not_found
        message: Case not found
      properties:
        code:
          example: email_otp_expired
          type: string
        message:
          example: OTP has expired
          type: string
        param:
          nullable: true
          type: string
      type: object
    ErrNotRequested:
      description: ErrNotRequested schema
      example:
        code: not_requested
        message: >-
          Only the requested items can be changed while an information request
          is open
      properties:
        code:
          example: email_otp_expired
          type: string
        message:
          example: OTP has expired
          type: string
        param:
          nullable: true
          type: string
      type: object

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.