---
title: Invalidate a coupon code
slug: campaign/api/invalidate-a-coupon-code
docTags: 
createdAt: 2026-09-02T15:04:15.718Z
---

{
  "id": "XtZkJHqmBM_pMYa796T6b",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.campaign.episerver.net/rest/{clientId}/couponblocks/{couponBlockId}/codes/{code}",
    "servers": [
      {
        "url": "https://api.campaign.episerver.net/rest/{clientId}/couponblocks/{couponBlockId}/codes/{code}"
      }
    ],
    "name": "Invalidate a coupon code",
    "description": "Mark a coupon code as used.",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "clientId",
          "type": "integer<int64>",
          "description": "Client ID",
          "format": "int64"
        },
        {
          "kind": "required",
          "name": "code",
          "type": "string",
          "description": "Coupon code"
        },
        {
          "kind": "required",
          "name": "couponBlockId",
          "type": "integer<int64>",
          "description": "Coupon block 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": [],
      "oAuthParameters": [
        {
          "id": "Authorization",
          "name": "Authorization",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "The coupon code was invalidated successfully.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "RestCouponCode",
            "schema": [
              {
                "name": "code",
                "kind": "optional",
                "type": "string",
                "description": "Coupon code"
              },
              {
                "name": "assignedMailing",
                "kind": "optional",
                "type": "integer<int64>",
                "description": "Mailing assigned to the coupon code",
                "format": "int64"
              },
              {
                "name": "assignedRecipient",
                "kind": "optional",
                "type": "string",
                "description": "Recipient assigned to the coupon code"
              },
              {
                "name": "assigned",
                "kind": "optional",
                "type": "boolean",
                "description": "<p>If true, the code of the coupon block is assigned to a mailing</p>"
              },
              {
                "name": "used",
                "kind": "optional",
                "type": "boolean",
                "description": "<p>If true, the code of the coupon block was used</p>"
              },
              {
                "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"
              },
              {
                "name": "links",
                "kind": "optional",
                "type": "array",
                "description": "Restful links",
                "example": "",
                "itemType": "object",
                "customType": "object[]",
                "schema": [
                  {
                    "name": "uriBuilder",
                    "kind": "optional",
                    "type": "object",
                    "description": "",
                    "example": "",
                    "schema": []
                  },
                  {
                    "name": "rels",
                    "kind": "optional",
                    "type": "array",
                    "description": "",
                    "example": "",
                    "itemType": "string",
                    "customType": "string[]",
                    "itemExample": "",
                    "itemDefault": ""
                  },
                  {
                    "name": "rel",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  },
                  {
                    "name": "type",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  },
                  {
                    "name": "params",
                    "kind": "optional",
                    "type": "map",
                    "description": "",
                    "example": "",
                    "customType": "map<string, string>",
                    "schema": []
                  },
                  {
                    "name": "title",
                    "kind": "optional",
                    "type": "string",
                    "description": ""
                  },
                  {
                    "name": "uri",
                    "kind": "optional",
                    "type": "string<uri>",
                    "description": "",
                    "format": "uri"
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/RestCouponCode",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "The coupon code could not be found. Ensure that the required parameters such as \"couponBlockId\" are correct and the coupon code exists.",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "409",
        "description": "The coupon code is not assigned to the indicated client. Ensure that \"clientId\" and the coupon code are correct and that the \"couponBlockId\" is assigned to the indicated client.",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "IUxBhwT2r-Oz1vQWRsCJl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.campaign.episerver.net/rest/{clientId}/couponblocks/{couponBlockId}/codes/{code} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "cGRTWzJhOiElMZKdAT-Mk",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.campaign.episerver.net/rest/{clientId}/couponblocks/{couponBlockId}/codes/{code}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "iDuxX_-ToqnZUKUMFxSTL",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.campaign.episerver.net/rest/{clientId}/couponblocks/{couponBlockId}/codes/{code}\")\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/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "un43Cg1-48Ceg6z98ZtOU",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.campaign.episerver.net/rest/{clientId}/couponblocks/{couponBlockId}/codes/{code}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "IUxBhwT2r-Oz1vQWRsCJl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// The coupon code was invalidated successfully.\n{\n  \"code\": \"\",\n  \"assignedMailing\": \"\",\n  \"assignedRecipient\": \"\",\n  \"assigned\": false,\n  \"used\": false,\n  \"created\": \"\",\n  \"modified\": \"\",\n  \"links\": [\n    {\n      \"uriBuilder\": {},\n      \"rels\": [\n        \"\"\n      ],\n      \"rel\": \"\",\n      \"type\": \"\",\n      \"params\": \"\",\n      \"title\": \"\",\n      \"uri\": \"\"\n    }\n  ]\n}"
        },
        {
          "id": "response-1-404",
          "language": "404",
          "code": "// The coupon code could not be found. Ensure that the required parameters such as \"couponBlockId\" are correct and the coupon code exists.\n"
        },
        {
          "id": "response-2-409",
          "language": "409",
          "code": "// The coupon code is not assigned to the indicated client. Ensure that \"clientId\" and the coupon code are correct and that the \"couponBlockId\" is assigned to the indicated client.\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}