Skip navigation

I was recently asked if you could build an Eloqua Campaign including the steps using the REST API. The Developer Help Center includes details and an example on creating an Eloqua Campaign using this REST 2.0 API endpoint - POST /assets/campaign; however, there are not details for creating the steps, which can be done using the elements array, within the Request parameters tab or within the Example. We are in the process of updating our documentation to indicate all the Request parameters and include a more extensive Example.

 

While our official documentation is being updated, I wanted to provide an example to demonstrate creating an Eloqua Campaign including the steps using the REST 2.0 API endpoint - POST /assets/campaign. Here is a screenshot of the resulting Eloqua Campaign created using the REST API Request below:

create_campaign_example.png

 

Request

POST /API/REST/2.0/assets/campaign

 

Request - Body

{

  "name": "API Example Campaign",

  "elements": [

    {

      "type": "CampaignSegment",

      "id": "-1",

      "name": "Segment members",

      "segmentId": "2",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "connectedId": "-2",

          "connectedType": "CampaignWaitAction",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "39"

      },

      "isFinished": "false",

      "isRecurring": "false"

    },

    {

      "type": "CampaignWaitAction",

      "id": "-2",

      "name": "Wait",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "connectedId": "-3",

          "connectedType": "CampaignEmail",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "131"

      },

      "waitFor": "3600"

    },

    {

      "type": "CampaignEmail",

      "emailId": "98",

      "id": "-3",

      "name": "Email 1",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "connectedId": "-4",

          "connectedType": "CampaignWaitAction",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "222"

      },

      "includeListUnsubscribeHeader": "false",

      "isAllowingResend": "false",

      "isAllowingSentToMasterExclude": "false",

      "isAllowingSentToUnsubscribe": "false",

      "sendTimePeriod": "sendAllEmailAtOnce"

    },

    {

      "type": "CampaignWaitAction",

      "id": "-4",

      "name": "Wait",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "connectedId": "-5",

          "connectedType": "CampaignEmail",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "316"

      },

      "waitFor": "259200"

    },

    {

      "type": "CampaignEmail",

      "emailId": "99",

      "id": "-5",

      "name": "Email 2",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "connectedId": "-6",

          "connectedType": "CampaignMoveToContactListAction",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "409"

      },

      "includeListUnsubscribeHeader": "true",

      "isAllowingResend": "false",

      "isAllowingSentToMasterExclude": "false",

      "isAllowingSentToUnsubscribe": "false",

      "sendTimePeriod": "sendAllEmailAtOnce"

    },

    {

      "type": "CampaignEmailClickthroughRule",

      "emailId": "99",

      "id": "-6",

      "name": "Clicked Email?",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "id": "-7",

          "connectedId": "-9",

          "connectedType": "CampaignMoveToContactListAction",

          "terminalType": "no"

        },

        {

          "type": "CampaignOutputTerminal",

          "id": "-8",

          "connectedId": "-10",

          "connectedType": "CampaignMoveToContactListAction",

          "terminalType": "yes"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "497"

      },

      "evaluateNoAfter": "604800",

      "numberOfClicks": "1",

      "withinLast": "604800"

    },

    {

      "type": "CampaignMoveToContactListAction",

      "listId": "64",

      "id": "-9",

      "name": "Move to Shared List 1",

      "position": {

        "type": "Position",

        "x": "233",

        "y": "614"

      }

    },

    {

      "type": "CampaignMoveToContactListAction",

      "listId": "65",

      "id": "-10",

      "name": "Move to Shared List 2",

      "position": {

        "type": "Position",

        "x": "503",

        "y": "614"

      }

    }

  ]

}

 

Response

{

  "type": "Campaign",

  "currentStatus": "Draft",

  "id": "22",

  "createdAt": "1463284937",

  "createdBy": "11",

  "depth": "complete",

  "folderId": "308",

  "name": "API Example Campaign",

  "permissions": [

    "Retrieve",

    "SetSecurity",

    "Delete",

    "Update",

    "Activate"

  ],

  "updatedAt": "1463284937",

  "updatedBy": "11",

  "elements": [

    {

      "type": "CampaignSegment",

      "id": "337",

      "initialId": "-1",

      "name": "Segment members",

      "memberCount": "0",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "id": "320",

          "connectedId": "338",

          "connectedType": "CampaignWaitAction",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "39"

      },

      "isFinished": "false",

      "isRecurring": "false",

      "segmentId": "2"

    },

    {

      "type": "CampaignWaitAction",

      "id": "338",

      "initialId": "-2",

      "name": "Wait",

      "memberCount": "0",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "id": "321",

          "connectedId": "339",

          "connectedType": "CampaignEmail",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "131"

      },

      "waitFor": "3600"

    },

    {

      "type": "CampaignEmail",

      "id": "339",

      "initialId": "-3",

      "name": "Email 1",

      "memberCount": "0",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "id": "322",

          "connectedId": "340",

          "connectedType": "CampaignWaitAction",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "222"

      },

      "emailId": "98",

      "includeListUnsubscribeHeader": "false",

      "isAllowingResend": "false",

      "isAllowingSentToMasterExclude": "false",

      "isAllowingSentToUnsubscribe": "false",

      "sendTimePeriod": "sendAllEmailAtOnce"

    },

    {

      "type": "CampaignWaitAction",

      "id": "340",

      "initialId": "-4",

      "name": "Wait",

      "memberCount": "0",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "id": "323",

          "connectedId": "341",

          "connectedType": "CampaignEmail",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "316"

      },

      "waitFor": "259200"

    },

    {

      "type": "CampaignEmail",

      "id": "341",

      "initialId": "-5",

      "name": "Email 2",

      "memberCount": "0",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "id": "324",

          "connectedId": "342",

          "connectedType": "CampaignEmailClickthroughRule",

          "terminalType": "out"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "409"

      },

      "emailId": "99",

      "includeListUnsubscribeHeader": "true",

      "isAllowingResend": "false",

      "isAllowingSentToMasterExclude": "false",

      "isAllowingSentToUnsubscribe": "false",

      "sendTimePeriod": "sendAllEmailAtOnce"

    },

    {

      "type": "CampaignEmailClickthroughRule",

      "id": "342",

      "initialId": "-6",

      "name": "Clicked Email?",

      "memberCount": "0",

      "outputTerminals": [

        {

          "type": "CampaignOutputTerminal",

          "id": "325",

          "initialId": "-7",

          "connectedId": "343",

          "connectedType": "CampaignMoveToContactListAction",

          "terminalType": "no"

        },

        {

          "type": "CampaignOutputTerminal",

          "id": "326",

          "initialId": "-8",

          "connectedId": "344",

          "connectedType": "CampaignMoveToContactListAction",

          "terminalType": "yes"

        }

      ],

      "position": {

        "type": "Position",

        "x": "365",

        "y": "497"

      },

      "emailId": "99",

      "evaluateNoAfter": "604800",

      "numberOfClicks": "1",

      "withinLast": "604800"

    },

    {

      "type": "CampaignMoveToContactListAction",

      "id": "343",

      "initialId": "-9",

      "name": "Move to Shared List 1",

      "memberCount": "0",

      "position": {

        "type": "Position",

        "x": "233",

        "y": "614"

      },

      "listId": "64"

    },

    {

      "type": "CampaignMoveToContactListAction",

      "id": "344",

      "initialId": "-10",

      "name": "Move to Shared List 2",

      "memberCount": "0",

      "position": {

        "type": "Position",

        "x": "503",

        "y": "614"

      },

      "listId": "65"

    }

  ],

  "isReadOnly": "false",

  "actualCost": "0",

  "budgetedCost": "0",

  "campaignCategory": "contact",

  "campaignType": "",

  "fieldValues": [

    {

      "type": "FieldValue",

      "id": "4",

      "value": ""

    },

    {

      "type": "FieldValue",

      "id": "5",

      "value": ""

    },

    {

      "type": "FieldValue",

      "id": "6",

      "value": ""

    },

    {

      "type": "FieldValue",

      "id": "7",

      "value": ""

    }

  ],

  "isEmailMarketingCampaign": "false",

  "isIncludedInROI": "false",

  "isMemberAllowedReEntry": "false",

  "isSyncedWithCRM": "false",

  "product": "",

  "region": ""

}

 

If you've made it this far, I bet you are wondering about the negative numbers used in the Request - Body. These are reference ids and they must be unique negative numbers. Eloqua will set these ids when the Campaign is created; therefore, you cannot know what they are prior. The negative id is a placeholder that allows you to connect the steps within the output terminals. For the output terminals, the unique negative number reference id is only needed for the output terminal itself if there is more than one output terminal, i.e. a yes / no decision step.

 

This is a simple example, but should help as a starting point for creating more complex flows. To see how you'd build more complex flows using a REST API call, and how other steps look within the elements array, retrieve an existing Campaign you already created using this REST 2.0 API endpoint - GET /assets/campaign/{id}?depth=complete (do not forget the "?depth=complete"!).

 

Happy coding with the Eloqua APIs and see you around Code It!

Filter Blog

By date: By tag: