{
    "name": "DeCA gratis: avisos y crear DeCA",
    "nodes": [
        {
            "parameters": {
                "content": "DeCA gratis · plantilla\n\n1) Pon tu clave (dg_live_…) en el nodo «Crear DeCA» (cabecera Authorization).\n2) Activa el flujo y copia la URL de producción del nodo «Aviso de DeCA gratis».\n3) Créala como webhook en https://deca.transportistastop10.com/integraciones\n\nComprobar la firma: https://deca.transportistastop10.com/api/docs#webhooks",
                "height": 300,
                "width": 380
            },
            "id": "a1b2c3d4-0000-4000-8000-000000000001",
            "name": "Léeme",
            "type": "n8n-nodes-base.stickyNote",
            "typeVersion": 1,
            "position": [
                -420,
                0
            ]
        },
        {
            "parameters": {
                "httpMethod": "POST",
                "path": "deca-gratis",
                "options": {}
            },
            "id": "a1b2c3d4-0000-4000-8000-000000000002",
            "name": "Aviso de DeCA gratis",
            "type": "n8n-nodes-base.webhook",
            "typeVersion": 2,
            "position": [
                0,
                0
            ],
            "webhookId": "b7f0f0c2-5d1e-4c55-9d7a-4c1f0e2d9a10"
        },
        {
            "parameters": {
                "conditions": {
                    "string": [
                        {
                            "value1": "={{ $json.body.evento }}",
                            "value2": "deca.descargado"
                        }
                    ]
                }
            },
            "id": "a1b2c3d4-0000-4000-8000-000000000003",
            "name": "¿Posible inspección?",
            "type": "n8n-nodes-base.if",
            "typeVersion": 1,
            "position": [
                240,
                0
            ]
        },
        {
            "parameters": {},
            "id": "a1b2c3d4-0000-4000-8000-000000000004",
            "name": "Avisar a tráfico (pon aquí tu aviso)",
            "type": "n8n-nodes-base.noOp",
            "typeVersion": 1,
            "position": [
                480,
                -100
            ]
        },
        {
            "parameters": {},
            "id": "a1b2c3d4-0000-4000-8000-000000000005",
            "name": "Otros eventos (guárdalos en tu sistema)",
            "type": "n8n-nodes-base.noOp",
            "typeVersion": 1,
            "position": [
                480,
                100
            ]
        },
        {
            "parameters": {},
            "id": "a1b2c3d4-0000-4000-8000-000000000006",
            "name": "Probar",
            "type": "n8n-nodes-base.manualTrigger",
            "typeVersion": 1,
            "position": [
                0,
                320
            ]
        },
        {
            "parameters": {
                "jsCode": "// Cambia esto por los datos de tu pedido o expedición\nconst manana = new Date(Date.now() + 864e5).toISOString().slice(0, 10);\nreturn [{ json: {\n  ref_externa: 'N8N-' + Date.now(),\n  fecha_transporte: manana,\n  cargador_nombre: 'Frutas Huerta S.L.', cargador_nif: 'B12345674', cargador_domicilio: 'Calle Mayor 1, 03001 Alicante',\n  matricula: '1234BCD',\n  envios: [{ origen: 'Alicante', destino: 'Valencia', naturaleza: 'Fruta en cajas', peso: 12000, unidad: 'kg' }]\n} }];"
            },
            "id": "a1b2c3d4-0000-4000-8000-000000000007",
            "name": "Datos del DeCA",
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                240,
                320
            ]
        },
        {
            "parameters": {
                "method": "POST",
                "url": "https://deca.transportistastop10.com/api/v1/decas",
                "sendHeaders": true,
                "headerParameters": {
                    "parameters": [
                        {
                            "name": "Authorization",
                            "value": "Bearer dg_live_PON_AQUI_TU_CLAVE"
                        }
                    ]
                },
                "sendBody": true,
                "specifyBody": "json",
                "jsonBody": "={{ JSON.stringify($json) }}",
                "options": {}
            },
            "id": "a1b2c3d4-0000-4000-8000-000000000008",
            "name": "Crear DeCA",
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 4.2,
            "position": [
                480,
                320
            ]
        }
    ],
    "connections": {
        "Aviso de DeCA gratis": {
            "main": [
                [
                    {
                        "node": "¿Posible inspección?",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "¿Posible inspección?": {
            "main": [
                [
                    {
                        "node": "Avisar a tráfico (pon aquí tu aviso)",
                        "type": "main",
                        "index": 0
                    }
                ],
                [
                    {
                        "node": "Otros eventos (guárdalos en tu sistema)",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Probar": {
            "main": [
                [
                    {
                        "node": "Datos del DeCA",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Datos del DeCA": {
            "main": [
                [
                    {
                        "node": "Crear DeCA",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        }
    },
    "settings": {
        "executionOrder": "v1"
    },
    "pinData": {}
}