{
    "name": "Marketing Email Campaigns Workflow",
    "nodes": [
        {
            "type": "n8n-nodes-base.httpRequest",
            "name": "Authenticate with Email Platform",
            "parameters": {
                "authentication": "OAuth2",
                "oauthTokenUrl": "${MAILCHIMP_TOKEN_URL}",
                "oauthClientId": "${MAILCHIMP_CLIENT_ID}",
                "oauthClientSecret": "${MAILCHIMP_CLIENT_SECRET}",
                "oauthScopes": ["campaigns_write", "campaigns_read"]
            }
        },
        {
            "type": "n8n-nodes-base.set",
            "name": "Prepare Campaign Parameters",
            "parameters": {
                "values": {
                    "campaign_name": "{{$json.campaign_name}}",
                    "campaign_subject": "{{$json.campaign_subject}}",
                    "list_id": "{{$json.list_id}}"
                }
            }
        },
        {
            "type": "n8n-nodes-base.httpRequest",
            "name": "Create Email Campaign",
            "parameters": {
                "method": "POST",
                "url": "${MAILCHIMP_API_BASE}/campaigns",
                "authentication": "predefinedCredentialType",
                "errorHandler": {
                    "mode": "exponentialBackoff",
                    "maxRetries": 2
                }
            }
        },
        {
            "type": "n8n-nodes-base.httpRequest",
            "name": "Send Test Email",
            "parameters": {
                "method": "POST",
                "url": "${MAILCHIMP_API_BASE}/campaigns/{{$json.campaign_id}}/actions/test",
                "authentication": "predefinedCredentialType"
            }
        },
        {
            "type": "n8n-nodes-base.httpRequest",
            "name": "Get Campaign Statistics",
            "parameters": {
                "method": "GET",
                "url": "${MAILCHIMP_API_BASE}/reports/{{$json.campaign_id}}",
                "authentication": "predefinedCredentialType"
            }
        },
        {
            "type": "n8n-nodes-base.switch",
            "name": "Campaign Status Check",
            "parameters": {
                "rules": [
                    {
                        "condition": "{{$json.status === 'completed'}}",
                        "output": "Success Path"
                    },
                    {
                        "condition": "{{$json.status === 'failed'}}",
                        "output": "Error Path"
                    }
                ]
            }
        }
    ],
    "connections": {
        "Authenticate with Email Platform": {
            "main": [["Prepare Campaign Parameters"]]
        },
        "Prepare Campaign Parameters": {
            "main": [["Create Email Campaign"]]
        }
    },
    "settings": {
        "errorWorkflow": true,
        "saveExecutionProgress": true
    }
}