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

# Desadjuntar archivo

> Quita un archivo de un registro y, opcionalmente, lo elimina permanentemente.

Quita un archivo del valor de un campo `files`.

## Endpoint

```text theme={null}
DELETE /databases/{databaseId}/records/{recordId}/fields/{fieldKey}/files/{fileId}
```

## Parámetro de consulta

| Parámetro    | Tipo      | Default | Descripción                                                          |
| ------------ | --------- | ------- | -------------------------------------------------------------------- |
| `hardDelete` | `boolean` | `false` | Si es `true`, también elimina permanentemente el archivo almacenado. |

<Warning>
  Con `hardDelete=false`, el archivo deja de estar adjunto al registro, pero no se elimina permanentemente. Usa `hardDelete=true` cuando no necesites conservarlo.
</Warning>

## Ejemplo de solicitud

```bash theme={null}
curl -X DELETE "https://api.insuranceboosters.com/api/v1/databases/{databaseId}/records/{recordId}/fields/{fieldKey}/files/{fileId}?hardDelete=true" \
  -H "x-ib-api-key: TU_API_KEY"
```

## Respuesta exitosa (`200`)

```json theme={null}
{
  "record": {
    "id": "<record-id>",
    "values": {
      "documentos": []
    }
  },
  "detached": {
    "fileId": "<file-id>",
    "fieldKey": "documentos",
    "deleted": true
  }
}
```

`detached.deleted` indica si solicitaste la eliminación permanente.

## Errores frecuentes

Los errores de este endpoint usan `{ "error": "..." }`.

| HTTP  | Qué significa                                                         | Qué hacer                                 |
| ----- | --------------------------------------------------------------------- | ----------------------------------------- |
| `404` | El registro, campo o archivo no existe, o el archivo no está adjunto. | Confirma los identificadores.             |
| `422` | `fieldKey` no corresponde a un campo `files`.                         | Usa la clave de un campo compatible.      |
| `500` | No fue posible desadjuntar el archivo.                                | Reintenta; si continúa, contacta soporte. |


## OpenAPI

````yaml openapi/tableros-v1.yaml DELETE /databases/{databaseId}/records/{recordId}/fields/{fieldKey}/files/{fileId}
openapi: 3.1.0
info:
  title: Insurance Boosters API — Tableros
  version: 1.0.0
  description: API pública para administrar tableros, campos, registros y archivos.
  license:
    name: Propietaria
    url: https://insuranceboosters.com
servers:
  - url: https://api.insuranceboosters.com/api/v1
    description: Producción
security:
  - IbApiKey: []
tags:
  - name: Tableros
    description: Administración de tableros.
  - name: Campos
    description: Configuración del esquema de un tablero.
  - name: Registros
    description: Lectura y escritura de registros.
  - name: Archivos
    description: Archivos adjuntos a registros.
paths:
  /databases/{databaseId}/records/{recordId}/fields/{fieldKey}/files/{fileId}:
    parameters:
      - $ref: '#/components/parameters/DatabaseId'
      - $ref: '#/components/parameters/RecordId'
      - $ref: '#/components/parameters/FieldKey'
      - $ref: '#/components/parameters/FileId'
    delete:
      tags:
        - Archivos
      summary: Desadjuntar archivo
      operationId: detachDatabaseRecordFile
      parameters:
        - name: hardDelete
          in: query
          required: false
          description: También elimina el objeto almacenado cuando es `true`.
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Archivo desadjuntado.
          content:
            application/json:
              schema:
                type: object
                required:
                  - record
                  - detached
                properties:
                  record:
                    $ref: '#/components/schemas/Record'
                  detached:
                    type: object
                    required:
                      - fileId
                      - fieldKey
                      - deleted
                    properties:
                      fileId:
                        type: string
                      fieldKey:
                        type: string
                      deleted:
                        type: boolean
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          description: El campo indicado no admite archivos.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    DatabaseId:
      name: databaseId
      in: path
      required: true
      description: ID del tablero.
      schema:
        type: string
    RecordId:
      name: recordId
      in: path
      required: true
      description: ID del registro.
      schema:
        type: string
    FieldKey:
      name: fieldKey
      in: path
      required: true
      description: Clave estable del campo de archivos.
      schema:
        type: string
    FileId:
      name: fileId
      in: path
      required: true
      description: ID del archivo.
      schema:
        type: string
  schemas:
    Record:
      type: object
      required:
        - id
        - databaseId
        - values
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
        databaseId:
          type: string
        values:
          type: object
          additionalProperties: true
        createdAt:
          type: integer
        updatedAt:
          type: integer
        createdBy:
          type: string
        updatedBy:
          type: string
    Error:
      type: object
      properties:
        message:
          type: string
        error:
          type: string
      additionalProperties: false
  responses:
    Unauthorized:
      description: API key inválida o faltante.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Recurso no encontrado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Error del servicio.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    IbApiKey:
      type: apiKey
      in: header
      name: x-ib-api-key
      description: API key de Insurance Boosters.

````