---
title: Create Line item
slug: docs/demo/create-line-item
description: Learn how to make a POST request to an API endpoint and add a line item to a shopping cart using this detailed code example. Explore the required headers and request body parameters for describing, pricing, and customizing the new item. Ensure seamless in
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "NCt-cDQaIGsrSsolNnN3d",
  "data": {
    "url": "https://api.fictive.com/REST/api/carts/{cartReference}/line-items",
    "name": "Create Line item",
    "method": "POST",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "cartReference",
          "type": "string"
        }
      ],
      "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": [
        {
          "kind": "required",
          "name": "cartLineItem",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "description",
              "type": "string",
              "example": "",
              "description": "Description"
            },
            {
              "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": "priceReference",
                  "type": "string",
                  "example": "",
                  "description": "Product Price Reference"
                }
              ],
              "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v3.CartLineItems.PricePoint",
              "customType": "FictiveGlobal.Api.Rest.Dtos.v3.CartLineItems.PricePoint",
              "description": "Pricing"
            },
            {
              "kind": "optional",
              "name": "quantity",
              "type": "integer<int32>",
              "example": 0,
              "description": "Quantity"
            },
            {
              "kind": "optional",
              "name": "productReference",
              "type": "string",
              "example": "",
              "description": "Product Reference"
            },
            {
              "kind": "optional",
              "name": "customLineItemParameters",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Custom Parameters"
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v3.CartLineItems.CartLineItem",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v3.CartLineItems.CartLineItem",
          "isExpanded": true,
          "description": "Cart Line Item"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "201",
        "description": "Include resource location URI will be included in the response",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Null or empty description",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "401",
        "description": "API Authentication Failure: Invalid Authentication Type/Credentials Provided",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "403",
        "description": "Cannot amend or delete a cart that has been purchased",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "PriceId cannot be found",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "409",
        "description": "Net and Tax amount do not equate to the Gross amount",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "412",
        "description": "'Custom Parameter Name' not configured (The parameter name will replace the 'Custom Parameter Name' in the error message",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint will allow you the ability to create a new line item against an existing cart",
    "examples": {
      "languages": [
        {
          "id": "qpzU32ZiZgsDFSzaZ6I64",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/carts/{cartReference}/line-items \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "P3VhjQC0VgQ1tKTlJ11ho",
          "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: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.fictive.com/REST/api/carts/{cartReference}/line-items\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "4w67pWVDa4Rv0E_jaOciu",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/carts/{cartReference}/line-items\")\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\"\nrequest[\"x-version\"] = \"string\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "iPt6qAO7vvwWr9S4pJKtu",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/carts/{cartReference}/line-items\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json',\n   'x-version': 'string'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "qpzU32ZiZgsDFSzaZ6I64"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// Include resource location URI will be included in the response\n"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Null or empty description\n"
        },
        {
          "id": "response-2-401",
          "language": "401",
          "code": "// API Authentication Failure: Invalid Authentication Type/Credentials Provided\n"
        },
        {
          "id": "response-3-403",
          "language": "403",
          "code": "// Cannot amend or delete a cart that has been purchased\n"
        },
        {
          "id": "response-4-404",
          "language": "404",
          "code": "// PriceId cannot be found\n"
        },
        {
          "id": "response-5-409",
          "language": "409",
          "code": "// Net and Tax amount do not equate to the Gross amount\n"
        },
        {
          "id": "response-6-412",
          "language": "412",
          "code": "// 'Custom Parameter Name' not configured (The parameter name will replace the 'Custom Parameter Name' in the error message\n"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}