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

{
  "id": "MMkphxtApdMXl6urJT1At",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.campaign.episerver.net/rest/{clientId}/recipients/trackingoptout",
    "servers": [
      {
        "url": "https://api.campaign.episerver.net/rest/{clientId}/recipients/trackingoptout"
      }
    ],
    "name": "Create a tracking opt-out",
    "description": "<p>Create a tracking opt-out to deactivate the tracking of action-based data (opens and clicks) of a recipient.</p>",
    "contentType": "application/x-www-form-urlencoded",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "clientId",
          "type": "string",
          "description": "Client ID"
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [
        {
          "name": "recipientId",
          "kind": "required",
          "type": "string",
          "description": "<p>Recipient ID (usually the email address)</p>"
        }
      ],
      "oAuthParameters": [
        {
          "id": "Authorization",
          "name": "Authorization",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "<p>The tracking opt-out was created.</p>",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "406",
        "description": "<p>The tracking opt-out is not activated for this client. Ensure that the 'clientId' is correct and the required feature is enabled in the indicated client.</p>",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "8cKIkgtfEZ2xyQvOSRKGW",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.campaign.episerver.net/rest/{clientId}/recipients/trackingoptout \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/x-www-form-urlencoded' \\\n     --data 'recipientId=string'"
        },
        {
          "id": "fcIeIsaPWCUPCa8OFeqUI",
          "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(\"recipientId\", \"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}/recipients/trackingoptout\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "iNKXsM0Hgnq9Rp8tnURuV",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.campaign.episerver.net/rest/{clientId}/recipients/trackingoptout\")\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 = \"recipientId=string\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "gpZICDkTujxh7HRvuQ0If",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"https://api.campaign.episerver.net/rest/{clientId}/recipients/trackingoptout\"\n\npayload = 'recipientId=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": "8cKIkgtfEZ2xyQvOSRKGW"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// The tracking opt-out was created.\n"
        },
        {
          "id": "response-1-406",
          "language": "406",
          "code": "// The tracking opt-out is not activated for this client. Ensure that the 'clientId' is correct and the required feature is enabled in the indicated client.\n"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}