Crear Tratamiento

Crear Tratamiento

POST /cl/consent_manager/create_processing

Crea un tratamiento (DataProcessing). Un solo endpoint para REDEC y LPDP: el marco legal (legal_framework) y la base legal (legal_basis) se infieren de la Activity publicada resuelta por activity_code. Según la base legal, el motor registra:

  • CONSENTCONSENT_GRANTED (admite medium, evidence, expires_at y, sólo en Activities REDEC, el bloque redec).

  • CONTRACT | LEGITIMATE_INTEREST | LEGAL_OBLIGATIONPROCESSING_DECLARED (rechaza expires_at y redec).

  • URL de producción: https://api.floid.app/cl/consent_manager/create_processing

  • URL de sandbox: https://sandbox.floid.app/cl/consent_manager/create_processing


Headers requeridos

Authorization: Bearer {{TOKEN}}
Content-Type: application/json

El client_id se deriva del Bearer token. La versión de Activity, el marco y la base legal se infieren; no los envíes.


Parámetros del body

CampoTipoRequeridoDescripción
activity_codestringCódigo de la Activity publicada. Determina marco y base legal.
occurred_atstring (ISO 8601)Momento real del hecho. Debe estar dentro de la vigencia de la versión resuelta (tolerancia futura de 5 min).
subject_external_idstringIdentificador del titular en tu sistema (se indexa como blind index).
subject_snapshotobjectSnapshot del titular. Sólo subject_identification es obligatorio (ver tabla).
operational_codestringCódigo operacional del responsable.
mediumstringMedio de captura: ELECTRONIC, VERBAL, PHYSICAL.
evidencearrayCondicionalPiezas de evidencia. No siempre es obligatoria: depende de la base legal y de la política de evidencia de la Activity (ver nota).
expires_atstring (ISO 8601)NoSólo CONSENT. Acorta la vigencia máxima (nunca la extiende); posterior a occurred_at.
redecobjectCondicionalSólo CONSENT + marco REDEC. Ver tabla redec.
business_referencestringNoReferencia de negocio libre (trazabilidad).
metadataobjectNoMetadatos libres.
duplicate_protection_keystringNoClave de idempotencia por tenant. Un reintento idéntico devuelve replayed: true.

subject_snapshot

CampoTipoRequeridoDescripción
subject_typestringNATURAL o JURIDICAL.
subject_identificationobject{ type, value }. En REDEC debe ser CL_RUT válido.
name / email / phonestringNoDatos de contacto (opcionales).
company / attorneysobject/arrayNoSólo para titulares jurídicos.

redec

CampoTipoRequeridoDescripción
consent_idstringIdentificador del consentimiento en la institución. Único por compañía + REDEC.
purposenumberFinalidad: 1 o 2.
objectivestringObjetivo: 01..07.
executive_rutstringNoRUT del ejecutivo (validado si se envía).

evidence[]

CampoTipoRequeridoDescripción
formatstringFormato permitido por la Activity (PDF_A, MP3, JSON).
urlstringCondicionalURL válida cuando la custodia es EXTERNAL_URL_ONLY.
hashstringCondicionalHash declarado (obligatorio en REDEC).
custodystringNoFLOID_STORAGE o EXTERNAL_URL_ONLY (se valida contra la Activity).

¿Cuándo es obligatoria la evidencia? Depende de la política de evidencia (evidence_requirement) de la Activity: si es REQUIRED_IMMEDIATE, se exige al menos una pieza al crear; si es diferida, se agrega después con register_evidence.


Ejemplo (REDEC · consentimiento)

curl --location 'https://api.floid.app/cl/consent_manager/create_processing' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer {{TOKEN}}' \
  --data '{
    "activity_code": "marketing-redec",
    "occurred_at": "2026-09-10T13:00:00.000Z",
    "subject_external_id": "customer-8293",
    "subject_snapshot": {
      "subject_type": "NATURAL",
      "subject_identification": { "type": "CL_RUT", "value": "12.345.678-5" },
      "email": "[email protected]"
    },
    "medium": "ELECTRONIC",
    "operational_code": "crm-op-8891",
    "redec": {
      "consent_id": "institution-consent-001",
      "purpose": 2,
      "objective": "02",
      "executive_rut": "98765432-1"
    },
    "evidence": [
      { "format": "JSON", "url": "https://institution.example/evidence/redec-001.json", "hash": "hash-declarado" }
    ]
  }'

Respuesta exitosa (200)

{
  "code": 200,
  "message": "DataProcessing created",
  "caseid": "b3f1c2a4-9e77-4c31-8a10-2f6d5e7a1b90",
  "data": {
    "data_processing_id": "550e8400-e29b-41d4-a716-446655440000",
    "data_processing_event_id": "9d2b7f10-3c44-4a51-8b22-77aa11bb22cc",
    "event_type": "CONSENT_GRANTED",
    "occurred_at": "2026-09-10T13:00:00.000Z",
    "received_at": "2026-09-10T13:00:05.000Z",
    "status": "ACTIVE",
    "legal_basis": "CONSENT",
    "legal_framework": "REDEC",
    "subject_external_id": "customer-8293",
    "subject_snapshot": {
      "subject_type": "NATURAL",
      "subject_identification": { "type": "CL_RUT", "value": "12.345.678-5" },
      "email": "[email protected]"
    },
    "activity": { "code": "marketing-redec", "version_number": 3 },
    "terms_and_conditions": {
      "version": 2,
      "title": "Términos de marketing",
      "status": "PUBLISHED",
      "snapshot_url": "https://cdn.floid.app/tc/marketing-v2.pdf",
      "hash": "9f2b...e7"
    },
    "validity": {
      "ends_at": "2026-09-25T13:00:00.000Z",
      "end_mode": "FIXED_DURATION_FROM_FACT",
      "ended_at": null
    },
    "evidence_status": "RECEIVED",
    "evidence_due_at": null,
    "evidence": [
      {
        "evidence_id": "ev_7c2a1b0d",
        "source_event_id": "9d2b7f10-3c44-4a51-8b22-77aa11bb22cc",
        "source_event_type": "CONSENT_GRANTED",
        "received_at": "2026-09-10T13:00:05.000Z",
        "format": "JSON",
        "custody": "EXTERNAL_URL_ONLY",
        "hash": "hash-declarado",
        "ref": "https://institution.example/evidence/redec-001.json"
      }
    ],
    "operational_code": "crm-op-8891",
    "business_reference": null,
    "metadata": null,
    "redec": {
      "consent_id": "institution-consent-001",
      "institution_code": "1234",
      "purpose": "2",
      "objective": "02",
      "executive_rut": "98765432-1"
    },
    "replayed": false
  }
}

Estructura de data

CampoTipoDescripción
data_processing_idstringUUID del tratamiento creado.
data_processing_event_idstringUUID del evento de inicio registrado.
event_typestringCONSENT_GRANTED o PROCESSING_DECLARED (según base legal).
occurred_atstring (ISO 8601)Momento del hecho.
received_atstring (ISO 8601)Momento en que Floid recibió el evento.
statusstringEstado inicial: normalmente ACTIVE.
legal_basisstringBase legal inferida.
legal_frameworkstringMarco inferido (REDEC | LPDP).
subject_external_idstringIdentificador del titular (eco en claro).
subject_snapshotobjectSnapshot del titular tal como se persistió.
activityobject{ code, version_number } de la Activity aplicada.
terms_and_conditionsobjectT&C aplicados (version, title, status, snapshot_url, hash) o null.
validityobject{ ends_at, end_mode, ended_at }.
evidence_statusstringNOT_REQUIRED, PENDING, RECEIVED, OVERDUE.
evidence_due_atstring (ISO 8601)Vencimiento de evidencia diferida (null si no aplica).
evidencearrayPiezas de evidencia activas (evidence_id, source_event_id, source_event_type, received_at, format, custody, hash, ref).
operational_codestringEco del código operacional.
business_referencestringEco de la referencia de negocio (null si no se envió).
metadataobjectEco de metadatos (null si no se envió).
redecobjectBloque REDEC (null para LPDP).
replayedbooleantrue si el request fue una reproducción idempotente.

Errores

HTTPerror_codeCuándo
400ACTIVITY_CODE_REQUIREDFalta activity_code.
400VALIDATION_ERRORFalta operational_code u otro campo obligatorio.
400OCCURRED_AT_REQUIRED / OCCURRED_AT_INVALIDoccurred_at ausente o inválido.
400SUBJECT_EXTERNAL_ID_REQUIREDFalta subject_external_id.
400IDENTIFICATION_REQUIREDFalta subject_snapshot.subject_identification.
400MEDIUM_REQUIRED / MEDIUM_INVALIDmedium ausente o fuera de catálogo.
400EVIDENCE_REQUIRED / EVIDENCE_INVALIDFalta evidencia exigida o formato/custodia inválidos.
400REDEC_CONSENT_ID_REQUIRED / REDEC_PURPOSE_INVALID / REDEC_OBJECTIVE_INVALIDDatos REDEC ausentes o inválidos.
400INVALID_FIELD_FOR_PROCESSING_DECLAREDSe envió expires_at o redec en un tratamiento no-consentimiento.
409INSTITUTION_NOT_CONFIGUREDLa Activity es REDEC pero el tenant no tiene institution_code configurado.
404ACTIVITY_NOT_FOUND / ACTIVITY_NOT_PUBLISHEDNo hay Activity publicada aplicable en occurred_at.
409REDEC_CONSENT_ID_DUPLICATEredec.consent_id ya existe (con contenido distinto).
500INTERNAL_ERRORError inesperado del servidor.