{
  "id": "0LwqeMMNkwmniCvR",
  "name": "Template-Jsoncut-watermark",
  "tags": [],
  "nodes": [
    {
      "id": "0de163b2-1be3-4ef2-879d-4ce701de702b",
      "name": "Form Trigger",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -304,
        80
      ],
      "parameters": {
        "path": "b355dccf-d9fa-46e0-9c3c-8d3c743aa037",
        "options": {},
        "formTitle": "Image Watermark Generator",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Main Image",
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "Watermark Image",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Upload your main image and watermark to create a watermarked image"
      },
      "typeVersion": 2
    },
    {
      "id": "fca14091-7089-48b5-bc5f-3c5261f093c9",
      "name": "Upload Main Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -80,
        -32
      ],
      "parameters": {
        "url": "https://api.jsoncut.com/api/v1/files/upload",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "Main_Image"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "a3e639ed-f4e2-437e-b4b0-72ae227a1a1a",
      "name": "Upload Watermark",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -80,
        176
      ],
      "parameters": {
        "url": "https://api.jsoncut.com/api/v1/files/upload",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "Watermark_Image"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "e397f050-48ba-4573-9ac2-54a07239d6ff",
      "name": "Merge Uploads",
      "type": "n8n-nodes-base.merge",
      "position": [
        144,
        80
      ],
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "7452ecb9-0de4-439c-adc6-3fb93eb33ae6",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        768,
        80
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 3
      },
      "typeVersion": 1
    },
    {
      "id": "c7e3fb3a-c2c3-4ead-8586-51686f114023",
      "name": "If Success",
      "type": "n8n-nodes-base.if",
      "position": [
        1184,
        80
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.data.status }}",
              "value2": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0c3f84ed-cbed-4d86-a019-85f0542e5cc5",
      "name": "If Error",
      "type": "n8n-nodes-base.if",
      "position": [
        1328,
        336
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.data.status }}",
              "value2": "FAILED"
            },
            {
              "value1": "={{ $json.data.status }}",
              "value2": "CANCELLED"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dcd47447-ba95-4ee7-a695-a95033ab251d",
      "name": "Download Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1504,
        64
      ],
      "parameters": {
        "url": "=https://api.jsoncut.com/api/v1/files/{{ $json.data.outputFileId }}/download",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        },
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/octet-stream"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "387771b8-e659-4f2d-86ce-4c7dbab16cb7",
      "name": "Error Stop",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        1536,
        336
      ],
      "parameters": {
        "errorMessage": "Failed to generate image"
      },
      "typeVersion": 1
    },
    {
      "id": "c698754d-f788-4d06-b09e-c86f531f8986",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        288,
        80
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "data.storageUrl"
            },
            {}
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "bb3fed4e-dc72-4af3-97b5-0d5e491da0bd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -80
      ],
      "parameters": {
        "width": 272,
        "height": 432,
        "content": "### Upload Files to JsonCut API"
      },
      "typeVersion": 1
    },
    {
      "id": "43b6603f-eaa1-47d0-90eb-22985a41e92f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 1248,
        "height": 320,
        "content": "### Create Job with Jsoncut API and wait for the result"
      },
      "typeVersion": 1
    },
    {
      "id": "c7dec839-3324-4c26-afe3-c0cce706359f",
      "name": "Create JsonCut Job",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        544,
        80
      ],
      "parameters": {
        "url": "https://api.jsoncut.com/api/v1/jobs",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n   \"type\":\"image\",\n   \"config\":{\n      \"width\":800,\n      \"height\":600,\n      \"layers\":[\n         {\n            \"type\":\"image\",\n            \"path\":\"{{ $json.storageUrl[0] }}\",\n            \"x\":0,\n            \"y\":0,\n            \"width\":800,\n            \"height\":600,\n            \"fit\":\"cover\"\n         },\n         {\n            \"type\":\"image\",\n            \"path\":\"{{ $json.storageUrl[1] }}\",\n            \"width\":90,\n            \"height\":90,\n            \"position\":{\n               \"x\":0.95,\n               \"y\":1,\n               \"originX\":\"right\",\n               \"originY\":\"bottom\"\n            },\n            \"fit\":\"contain\",\n            \"opacity\":0.5\n         }\n      ]\n   }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "10029720-1b82-4b47-9caf-4f8d15d20e71",
      "name": "Check JsonCut job Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        992,
        80
      ],
      "parameters": {
        "url": "=https://api.jsoncut.com/api/v1/jobs/{{ $json.data.jobId }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5d01db84-ed88-4692-8fdd-956e1badccac",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Check JsonCut job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Error": {
      "main": [
        [
          {
            "node": "Error Stop",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Create JsonCut Job",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Success": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form Trigger": {
      "main": [
        [
          {
            "node": "Upload Main Image",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload Watermark",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Uploads": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        []
      ]
    },
    "Upload Watermark": {
      "main": [
        [
          {
            "node": "Merge Uploads",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Upload Main Image": {
      "main": [
        [
          {
            "node": "Merge Uploads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create JsonCut Job": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check JsonCut job Status": {
      "main": [
        [
          {
            "node": "If Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}