---
title: Validate voucher against a cart
slug: docs/demo/validate-voucher-against-a-cart
description: Learn how to make a GET request to a particular endpoint on the Fictive API using cURL. This tutorial provides a code example that includes the cart reference and voucher code in the URL, and explains how to set the appropriate headers for accepting and s
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "uwrCxuKkbuoq6ELmhoCYn",
  "data": {
    "url": "https://api.fictive.com/REST/api/carts/{cartReference}/vouchers/{voucherCode}",
    "name": "Validate voucher against a cart",
    "method": "GET",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "cartReference",
          "type": "string",
          "description": ""
        },
        {
          "kind": "required",
          "name": "voucherCode",
          "type": "string",
          "description": ""
        }
      ],
      "queryParameters": [],
      "headerParameters": [
        {
          "kind": "optional",
          "name": "X-TokenId",
          "type": "string",
          "description": "The eSuite Token Id"
        },
        {
          "kind": "optional",
          "name": "X-SessionId",
          "type": "string",
          "description": "The eSuite Session Id"
        },
        {
          "kind": "required",
          "name": "X-Version",
          "type": "string",
          "description": "The eSuite Version"
        },
        {
          "kind": "optional",
          "name": "Origin",
          "type": "string",
          "description": "The eSuite Origin"
        }
      ],
      "bodyDataParameters": [],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "array",
            "schema": [
              {
                "kind": "optional",
                "name": "resourceReference",
                "type": "string",
                "example": "",
                "description": "Line Item Reference"
              },
              {
                "kind": "optional",
                "name": "description",
                "type": "string",
                "example": "",
                "description": "Description of the Line Item"
              },
              {
                "kind": "optional",
                "name": "pricing",
                "type": "object",
                "schema": [
                  {
                    "kind": "optional",
                    "name": "grossAmount",
                    "type": "number<double>",
                    "example": "",
                    "description": "Gross Amount"
                  },
                  {
                    "kind": "optional",
                    "name": "netAmount",
                    "type": "number<double>",
                    "example": "",
                    "description": "Net Amount"
                  },
                  {
                    "kind": "optional",
                    "name": "taxAmount",
                    "type": "number<double>",
                    "example": "",
                    "description": "Tax Amount"
                  },
                  {
                    "kind": "optional",
                    "name": "currency",
                    "type": "string",
                    "example": "",
                    "description": "Currency"
                  },
                  {
                    "kind": "optional",
                    "name": "priceId",
                    "type": "integer<int32>",
                    "example": 0,
                    "description": "Product Price Id"
                  }
                ],
                "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.CartLineItems.PricePoint",
                "customType": "FictiveGlobal.Api.Rest.Dtos.v1.CartLineItems.PricePoint",
                "description": "Pricing information about Line Item"
              },
              {
                "kind": "optional",
                "name": "quantity",
                "type": "integer<int32>",
                "example": 0,
                "description": "Quantity of items"
              },
              {
                "kind": "optional",
                "name": "productInfo",
                "type": "object",
                "schema": [
                  {
                    "kind": "optional",
                    "name": "productId",
                    "type": "integer<int64>",
                    "example": 0
                  }
                ],
                "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.Cart.LineItemProductInfo",
                "customType": "FictiveGlobal.Api.Rest.Dtos.v1.Cart.LineItemProductInfo",
                "description": "Product"
              },
              {
                "kind": "optional",
                "name": "customLineItemParameters",
                "type": "object",
                "schema": [],
                "example": {},
                "description": "List of cart item detail parameters"
              }
            ],
            "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.Cart.CartItem",
            "customType": "FictiveGlobal.Api.Rest.Dtos.v1.Cart.CartItem[]",
            "isExpanded": true
          }
        ],
        "isExpanded": true,
        "statusCode": "200",
        "description": "OK",
        "jsonExample": "[\n  {\n    \"description\": \"Brown Shirt\",\n    \"pricing\": {\n      \"grossAmount\": 12,\n      \"netAmount\": 10,\n      \"taxAmount\": 2,\n      \"currency\": \"GBP\"\n    },\n    \"quantity\": 1,\n    \"productInfo\": {\n      \"productId\": 221822\n    },\n    \"customLineItemParameters\": {\n      \"size\": \"10\"\n    }\n  },\n  {\n    \"description\": \"Brown Shirt\",\n    \"pricing\": {\n      \"grossAmount\": -2,\n      \"netAmount\": -1.7,\n      \"taxAmount\": -0.3,\n      \"currency\": \"GBP\"\n    },\n    \"quantity\": 1,\n    \"productInfo\": {\n      \"productId\": 221822\n    },\n    \"customLineItemParameters\": {\n      \"size\": \"10\"\n    }\n  }\n]"
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "• Cart cannot be found\r\n             <br /> • Voucher code cannot be found",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "412",
        "description": "• Invalid voucher code type, only Fixed Priced and Percentage discounts are supported\r\n             <br /> • Voucher code is inactive\r\n             <br /> • Cannot amend a cart which is currently used on a payment instruction\r\n             <br /> • Cannot apply more than one voucher to a cart",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint will provide the ability to simulate the impact a voucher will have on a pre-existing cart",
    "examples": {
      "languages": [
        {
          "id": "ySlMmfCDzx3CHNFTrTain",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url https://api.fictive.com/REST/api/carts/{cartReference}/vouchers/{voucherCode} \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "Rkq69HOcp8PnwOud6NCZS",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\nmyHeaders.append(\"x-version\", \"string\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.fictive.com/REST/api/carts/{cartReference}/vouchers/{voucherCode}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "RdZcioIXQGxqIHm2pv5_f",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/carts/{cartReference}/vouchers/{voucherCode}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest[\"x-version\"] = \"string\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "Ejt0YFqoxXko-WFAFT4zC",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/carts/{cartReference}/vouchers/{voucherCode}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-version': 'string'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "ySlMmfCDzx3CHNFTrTain"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "[\n  {\n    \"description\": \"Brown Shirt\",\n    \"pricing\": {\n      \"grossAmount\": 12,\n      \"netAmount\": 10,\n      \"taxAmount\": 2,\n      \"currency\": \"GBP\"\n    },\n    \"quantity\": 1,\n    \"productInfo\": {\n      \"productId\": 221822\n    },\n    \"customLineItemParameters\": {\n      \"size\": \"10\"\n    }\n  },\n  {\n    \"description\": \"Brown Shirt\",\n    \"pricing\": {\n      \"grossAmount\": -2,\n      \"netAmount\": -1.7,\n      \"taxAmount\": -0.3,\n      \"currency\": \"GBP\"\n    },\n    \"quantity\": 1,\n    \"productInfo\": {\n      \"productId\": 221822\n    },\n    \"customLineItemParameters\": {\n      \"size\": \"10\"\n    }\n  }\n]"
        },
        {
          "id": "response-1-404",
          "language": "404",
          "code": "// • Cart cannot be found\r\n              • Voucher code cannot be found\n"
        },
        {
          "id": "response-2-412",
          "language": "412",
          "code": "// • Invalid voucher code type, only Fixed Priced and Percentage discounts are supported\r\n              • Voucher code is inactive\r\n              • Cannot amend a cart which is currently used on a payment instruction\r\n              • Cannot apply more than one voucher to a cart\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}