> ## 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.

# Reordenar campos

> Define el orden de las columnas de un tablero.

Reordena los campos del tablero con una lista completa de sus IDs.

## Endpoint

```text theme={null}
PUT /databases/{databaseId}/fields/reorder
```

## Body

| Campo      | Tipo       | Requerido | Descripción                                                       |
| ---------- | ---------- | --------- | ----------------------------------------------------------------- |
| `fieldIds` | `string[]` | Sí        | Todos los IDs de campo, exactamente una vez, en el orden deseado. |

Obtén la lista vigente con [Consultar tablero](/tableros/consultar-tablero) antes de reordenar.

## Ejemplo de solicitud

```bash theme={null}
curl -X PUT "https://api.insuranceboosters.com/api/v1/databases/{databaseId}/fields/reorder" \
  -H "Content-Type: application/json" \
  -H "x-ib-api-key: TU_API_KEY" \
  -d '{
    "fieldIds": ["<field-id-estado>", "<field-id-poliza>", "<field-id-prima>"]
  }'
```

## Respuesta exitosa (`200`)

```json theme={null}
{
  "fields": [
    { "id": "<field-id-estado>", "key": "estado", "name": "Estado", "type": "enum" },
    { "id": "<field-id-poliza>", "key": "numeroPoliza", "name": "Número de póliza", "type": "string" },
    { "id": "<field-id-prima>", "key": "prima", "name": "Prima", "type": "number" }
  ]
}
```

## Errores frecuentes

| HTTP  | Qué significa                                 | Qué hacer                                                     |
| ----- | --------------------------------------------- | ------------------------------------------------------------- |
| `400` | `fieldIds` no es un arreglo.                  | Envía un arreglo de strings.                                  |
| `409` | Los campos cambiaron desde tu última lectura. | Consulta de nuevo el tablero y reintenta con la lista actual. |
| `403` | Tu integración no puede modificar el tablero. | Confirma el acceso al tablero.                                |
| `404` | El tablero o un campo no existe.              | Confirma los IDs.                                             |


## OpenAPI

````yaml openapi/tableros-v1.yaml PUT /databases/{databaseId}/fields/reorder
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}/fields/reorder:
    parameters:
      - $ref: '#/components/parameters/DatabaseId'
    put:
      tags:
        - Campos
      summary: Reordenar campos
      operationId: reorderDatabaseFields
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - fieldIds
              properties:
                fieldIds:
                  type: array
                  minItems: 1
                  description: IDs de todos los campos, en el orden deseado.
                  items:
                    type: string
            example:
              fieldIds:
                - <field-id-1>
                - <field-id-2>
      responses:
        '200':
          description: Campos reordenados.
          content:
            application/json:
              schema:
                type: object
                required:
                  - fields
                properties:
                  fields:
                    type: array
                    items:
                      $ref: '#/components/schemas/Field'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: El esquema cambió mientras se procesaba la solicitud.
          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
  schemas:
    Field:
      allOf:
        - $ref: '#/components/schemas/FieldInputProperties'
        - type: object
          required:
            - id
            - key
            - name
            - type
          properties:
            id:
              type: string
            inverseFieldId:
              type: string
            relationPairId:
              type: string
    Error:
      type: object
      properties:
        message:
          type: string
        error:
          type: string
      additionalProperties: false
    FieldInputProperties:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          description: Nombre visible del campo.
        key:
          type: string
          pattern: ^[a-z][a-zA-Z0-9]*(?:_[a-z0-9]+)*$
          description: Clave estable; se genera desde `name` si la omites.
        type:
          type: string
          enum:
            - string
            - number
            - boolean
            - date
            - enum
            - enum_multi
            - relation_single
            - relation_multi
            - contact_single
            - contact_multi
            - lookup
            - files
          description: Tipo inmutable después de crear el campo.
        required:
          type: boolean
          default: false
          description: >-
            Marca el campo como obligatorio en el esquema y en la captura del
            tablero.
        description:
          type: string
        defaultValue:
          description: Valor predeterminado para tipos compatibles.
        dateConfig:
          allOf:
            - $ref: '#/components/schemas/DateConfig'
          description: Configuración de presentación cuando `type` es `date`.
        options:
          type: array
          minItems: 1
          description: Requerido para `enum` y `enum_multi`.
          items:
            $ref: '#/components/schemas/EnumOptionInput'
        toDatabaseId:
          type: string
          description: Requerido para campos de relación.
        displayFieldId:
          type: string
          description: Campo mostrado en relaciones o contactos.
        bidirectional:
          type: boolean
          default: false
        inverseField:
          $ref: '#/components/schemas/InverseFieldInput'
        relationFieldId:
          type: string
          description: Requerido para `lookup`.
        targetFieldId:
          type: string
          description: Requerido para `lookup`.
        multipleValuesBehavior:
          type: string
          enum:
            - allValues
            - uniqueValues
            - firstValue
            - lastValue
          description: Requerido para `lookup`.
        maxFiles:
          type: integer
          minimum: 1
          description: Máximo de archivos cuando `type` es `files`.
        accept:
          type: array
          description: Tipos MIME aceptados cuando `type` es `files`.
          items:
            type: string
        numberFormat:
          $ref: '#/components/schemas/NumberFormat'
    DateConfig:
      type: object
      additionalProperties: false
      required:
        - includeTime
      properties:
        includeTime:
          type: boolean
          default: false
          description: >-
            Controla si el tablero captura y muestra hora. No cambia la
            validación del valor.
    EnumOptionInput:
      type: object
      additionalProperties: false
      required:
        - label
      properties:
        id:
          type: string
          description: ID estable; se genera automáticamente si lo omites.
        label:
          type: string
          minLength: 1
        color:
          type: string
        order:
          type: integer
          minimum: 0
    InverseFieldInput:
      type: object
      additionalProperties: false
      description: >-
        Vincula un campo existente con `id` o crea uno nuevo con `name` y
        `type`.
      properties:
        id:
          type: string
          description: ID de un campo de relación existente en el tablero destino.
        name:
          type: string
          minLength: 1
          description: Nombre de un campo inverso nuevo.
        key:
          type: string
          pattern: ^[a-z][a-zA-Z0-9]*(?:_[a-z0-9]+)*$
        type:
          type: string
          enum:
            - relation_single
            - relation_multi
        displayFieldId:
          type: string
    NumberFormat:
      type: object
      additionalProperties: false
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - none
            - currency
            - percent
          description: Formato visual del número.
        currencyCode:
          type: string
          enum:
            - USD
            - EUR
            - MXN
            - BRL
            - ARS
            - COP
            - CLP
            - PEN
            - UYU
            - GTQ
          description: Requerido cuando `type` es `currency`.
        decimalPlaces:
          type: integer
          minimum: 0
          maximum: 6
          default: 2
        thousandsSeparator:
          type: boolean
          default: true
  responses:
    BadRequest:
      description: Solicitud inválida.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: API key inválida o faltante.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: La integración no tiene acceso al recurso.
      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.

````