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

# Archivar paciente

> Archiva un paciente: deja de aparecer en listas y búsquedas, pero se conserva su historial. Se puede deshacer en la web.

**Cuándo usarla:** Cuando la clínica pida retirar un paciente. Lee antes el paciente con patients.get y envía su versión como expectedVersion; si cambió, recibes un 409.



## OpenAPI

````yaml /api-reference/openapi.es.json post /patients/{id}/archive
openapi: 3.1.0
info:
  title: API de Brelio
  version: '1'
  description: >-
    Todo lo que una persona hace en Brelio lo puede hacer un programa, con los
    mismos permisos, auditoría y límites. Cada endpoint se deriva del catálogo
    de operaciones.
servers:
  - url: https://api.brelio.app/v1
security: []
paths:
  /patients/{id}/archive:
    post:
      tags:
        - patients
      summary: Archivar paciente
      description: >-
        Archiva un paciente: deja de aparecer en listas y búsquedas, pero se
        conserva su historial. Se puede deshacer en la web.


        **Cuándo usarla:** Cuando la clínica pida retirar un paciente. Lee antes
        el paciente con patients.get y envía su versión como expectedVersion; si
        cambió, recibes un 409.
      operationId: patients.archive
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
            description: El id del paciente.
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 8
            maxLength: 255
          description: >-
            Único por comando; reutilízala solo para reintentar la misma
            llamada.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                expectedVersion:
                  type: string
                  pattern: >-
                    ^\d{4}-\d{2}-\d{2}[
                    T]\d{2}:\d{2}:\d{2}(\.\d{1,6})?([+-]\d{2}(:?\d{2})?|Z)$
                  description: >-
                    La `version` del paciente tal como la leíste. No la
                    construyas tú.
              required:
                - expectedVersion
            examples:
              example1:
                summary: Archive a patient
                value:
                  id: 0f6c2a8e-4b1d-4c3a-9e57-2d8b1f0a6c41
                  expectedVersion: '2026-01-15 10:00:00+00'
      responses:
        '200':
          description: Correcto
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    pattern: >-
                      ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  code:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Código legible, como PAC-0042.
                  firstName:
                    type: string
                  lastName:
                    anyOf:
                      - type: string
                      - type: 'null'
                  birthDate:
                    anyOf:
                      - type: string
                        format: date
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$
                      - type: 'null'
                  sex:
                    anyOf:
                      - type: string
                        enum:
                          - male
                          - female
                          - other
                      - type: 'null'
                  email:
                    anyOf:
                      - type: string
                      - type: 'null'
                  phone:
                    anyOf:
                      - type: string
                      - type: 'null'
                  status:
                    type: string
                    enum:
                      - active
                      - inactive
                      - discharged
                  identificationNumber:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Número del documento de identidad (DNI, NIE, pasaporte).
                  identificationType:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: Tipo de documento de identidad, como dni.
                  internalCode:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: >-
                      El código propio de la clínica para el paciente, si lo
                      tiene.
                  responsibleId:
                    anyOf:
                      - type: string
                        format: uuid
                        pattern: >-
                          ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                      - type: 'null'
                    description: El profesional responsable del paciente.
                  admittedAt:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                        description: ISO 8601, en UTC.
                      - type: 'null'
                  lastSessionAt:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                        description: ISO 8601, en UTC.
                      - type: 'null'
                  nextSessionAt:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                        description: ISO 8601, en UTC.
                      - type: 'null'
                  archivedAt:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                        description: ISO 8601, en UTC.
                      - type: 'null'
                    description: Cuándo se archivó el paciente; null mientras está activo.
                  version:
                    type: string
                    description: >-
                      Token de versión opaco. Devuélvelo como expectedVersion
                      para cambiar este paciente; no lo interpretes.
                  createdAt:
                    type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                    description: ISO 8601, en UTC.
                  updatedAt:
                    type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
                    description: ISO 8601, en UTC.
                required:
                  - id
                  - code
                  - firstName
                  - lastName
                  - birthDate
                  - sex
                  - email
                  - phone
                  - status
                  - identificationNumber
                  - identificationType
                  - internalCode
                  - responsibleId
                  - admittedAt
                  - lastSessionAt
                  - nextSessionAt
                  - archivedAt
                  - version
                  - createdAt
                  - updatedAt
                additionalProperties: false
        '401':
          description: Problem Details (RFC 9457) con un `code` estable
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '402':
          description: Problem Details (RFC 9457) con un `code` estable
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '403':
          description: Problem Details (RFC 9457) con un `code` estable
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '422':
          description: Problem Details (RFC 9457) con un `code` estable
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '429':
          description: Problem Details (RFC 9457) con un `code` estable
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
        '503':
          description: Problem Details (RFC 9457) con un `code` estable
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
      security:
        - bearer: []
components:
  schemas:
    Problem:
      type: object
      required:
        - type
        - title
        - status
        - code
        - detail
        - request_id
        - params
      properties:
        type:
          type: string
        title:
          type: string
        status:
          type: integer
        code:
          type: string
        detail:
          type: string
        request_id:
          type: string
        hint:
          type: string
        retryAfterSeconds:
          type: integer
        params:
          type: object
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: >-
        Clave de API de Brelio (de organización o personal) o un token de acceso
        de WorkOS.

````

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