---
title: Create a webhook
slug: campaign/api/create-a-webhook
docTags: 
createdAt: 2026-09-02T15:04:15.718Z
---

{
  "id": "GOmyq-dUawQj9oEZsKDpv",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.campaign.episerver.net/rest/{clientId}/webhooks",
    "servers": [
      {
        "url": "https://api.campaign.episerver.net/rest/{clientId}/webhooks"
      }
    ],
    "name": "Create a webhook",
    "description": "",
    "contentType": "application/x-www-form-urlencoded",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "clientId",
          "type": "integer<int64>",
          "description": "Client ID",
          "format": "int64"
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json",
            "application/vnd.optivo.broadmail.v1+json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [
        {
          "name": "basicAuthUsername",
          "kind": "optional",
          "type": "string",
          "description": "<p>User name for Basic HTTP Authentication. This parameter is deprecated and might be removed in the near future. Please use &#x3C;authentication> instead.</p>"
        },
        {
          "name": "basicAuthPassword",
          "kind": "optional",
          "type": "string",
          "description": "<p>Password for Basic HTTP Authentication. This parameter is deprecated and might be removed in the near future. Please use &#x3C;authentication> instead.</p>"
        },
        {
          "name": "type",
          "kind": "required",
          "type": "string<open | click | sent | bounce | unsubscribe | spamcomplaint | singleoptin | confirmedoptin | doubleoptin | blocklist | archive | filteredbyblocklist>",
          "description": "Event data type",
          "enum": [
            "open",
            "click",
            "sent",
            "bounce",
            "unsubscribe",
            "spamcomplaint",
            "singleoptin",
            "confirmedoptin",
            "doubleoptin",
            "blocklist",
            "archive",
            "filteredbyblocklist"
          ]
        },
        {
          "name": "format",
          "kind": "required",
          "type": "string<json>",
          "description": "Data format in which the event data is to be sent",
          "enum": [
            "json"
          ]
        },
        {
          "name": "authentication",
          "kind": "optional",
          "type": "string",
          "description": "<p>Authentication method and attributes as json.\n\nCurrent types are:</p>\n<p>or</p>\n<p>or</p>"
        },
        {
          "name": "targetUrl",
          "kind": "required",
          "type": "string",
          "description": "<p>Target URL to which the event data is to be sentNote: The URL must be accessible and able to receive data via HTTP POST requests from the IP address 193.169.180.1 at any time. Use the current HTTPS version and standard port 443 for HTTPS connections.</p>"
        }
      ],
      "oAuthParameters": [
        {
          "id": "Authorization",
          "name": "Authorization",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "The webhook was created successfully.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "RestWebhook",
            "schema": [
              {
                "name": "id",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Webhook ID",
                "format": "int64"
              },
              {
                "name": "type",
                "kind": "optional",
                "type": "string<open | click | sent | bounce | unsubscribe | spamcomplaint | webhooknode | singleoptin | confirmedoptin | doubleoptin | blocklist | archived | filteredbyblocklist>",
                "description": "Type of the event data",
                "enum": [
                  "open",
                  "click",
                  "sent",
                  "bounce",
                  "unsubscribe",
                  "spamcomplaint",
                  "webhooknode",
                  "singleoptin",
                  "confirmedoptin",
                  "doubleoptin",
                  "blocklist",
                  "archived",
                  "filteredbyblocklist"
                ]
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "string<created | activated | deactivated | deleted | suspended>",
                "description": "Webhook status",
                "enum": [
                  "created",
                  "activated",
                  "deactivated",
                  "deleted",
                  "suspended"
                ]
              },
              {
                "name": "format",
                "kind": "optional",
                "type": "string<json>",
                "description": "Data format of the event data",
                "enum": [
                  "json"
                ]
              },
              {
                "name": "targetUrl",
                "kind": "optional",
                "type": "string",
                "description": "Target URL"
              },
              {
                "name": "authentication",
                "kind": "optional",
                "type": "object",
                "discriminator": {
                  "propertyName": "type"
                },
                "description": "Authentication method and attributes",
                "modelRef": "#/components/schemas/WebhookAuthentication",
                "customType": "WebhookAuthentication",
                "schema": [
                  {
                    "name": "type",
                    "kind": "required",
                    "type": "string",
                    "description": ""
                  }
                ]
              },
              {
                "name": "created",
                "kind": "optional",
                "type": "string<date-time>",
                "description": "Creation date",
                "format": "date-time"
              },
              {
                "name": "modified",
                "kind": "optional",
                "type": "string<date-time>",
                "description": "Modification date",
                "format": "date-time"
              }
            ],
            "modelRef": "#/components/schemas/RestWebhook",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "<p>The webhook could not be created (either url, type or format was wrong).</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "RestWebhook",
            "schema": [
              {
                "name": "id",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Webhook ID",
                "format": "int64"
              },
              {
                "name": "type",
                "kind": "optional",
                "type": "string<open | click | sent | bounce | unsubscribe | spamcomplaint | webhooknode | singleoptin | confirmedoptin | doubleoptin | blocklist | archived | filteredbyblocklist>",
                "description": "Type of the event data",
                "enum": [
                  "open",
                  "click",
                  "sent",
                  "bounce",
                  "unsubscribe",
                  "spamcomplaint",
                  "webhooknode",
                  "singleoptin",
                  "confirmedoptin",
                  "doubleoptin",
                  "blocklist",
                  "archived",
                  "filteredbyblocklist"
                ]
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "string<created | activated | deactivated | deleted | suspended>",
                "description": "Webhook status",
                "enum": [
                  "created",
                  "activated",
                  "deactivated",
                  "deleted",
                  "suspended"
                ]
              },
              {
                "name": "format",
                "kind": "optional",
                "type": "string<json>",
                "description": "Data format of the event data",
                "enum": [
                  "json"
                ]
              },
              {
                "name": "targetUrl",
                "kind": "optional",
                "type": "string",
                "description": "Target URL"
              },
              {
                "name": "authentication",
                "kind": "optional",
                "type": "object",
                "discriminator": {
                  "propertyName": "type"
                },
                "description": "Authentication method and attributes",
                "modelRef": "#/components/schemas/WebhookAuthentication",
                "customType": "WebhookAuthentication",
                "schema": [
                  {
                    "name": "type",
                    "kind": "required",
                    "type": "string",
                    "description": ""
                  }
                ]
              },
              {
                "name": "created",
                "kind": "optional",
                "type": "string<date-time>",
                "description": "Creation date",
                "format": "date-time"
              },
              {
                "name": "modified",
                "kind": "optional",
                "type": "string<date-time>",
                "description": "Modification date",
                "format": "date-time"
              }
            ],
            "modelRef": "#/components/schemas/RestWebhook",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "g8J440I3W5eDwrDJLCiX2",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.campaign.episerver.net/rest/{clientId}/webhooks \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/x-www-form-urlencoded' \\\n     --data 'type=open' \\\n     --data 'format=json' \\\n     --data 'targetUrl=string'"
        },
        {
          "id": "DeDrV6UluTHANYu4Q4mkC",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/x-www-form-urlencoded\");\n\nvar urlencoded = new URLSearchParams();\nurlencoded.append(\"type\", \"open\");\nurlencoded.append(\"format\", \"json\");\nurlencoded.append(\"targetUrl\", \"string\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: urlencoded,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.campaign.episerver.net/rest/{clientId}/webhooks\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "gTu4BpRA_gHATBGd1d1D5",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.campaign.episerver.net/rest/{clientId}/webhooks\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/x-www-form-urlencoded\"\nrequest.body = \"type=open&format=json&targetUrl=string\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "K5t6-AxodU36YDP7YE22t",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"https://api.campaign.episerver.net/rest/{clientId}/webhooks\"\n\npayload = 'type=open&format=json&targetUrl=string'\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/x-www-form-urlencoded'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "g8J440I3W5eDwrDJLCiX2"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// The webhook was created successfully.\n{\n  \"id\": \"\",\n  \"type\": \"\",\n  \"status\": \"\",\n  \"format\": \"\",\n  \"targetUrl\": \"\",\n  \"authentication\": {\n    \"type\": \"\"\n  },\n  \"created\": \"\",\n  \"modified\": \"\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// The webhook could not be created (either url, type or format was wrong).\n{\n  \"id\": \"\",\n  \"type\": \"\",\n  \"status\": \"\",\n  \"format\": \"\",\n  \"targetUrl\": \"\",\n  \"authentication\": {\n    \"type\": \"\"\n  },\n  \"created\": \"\",\n  \"modified\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}