---
title: Creates a Bundle for the affiliate
slug: docs/demo/creates-a-bundle-for-the-affiliate
description: Learn how to send a POST request to a simulated API using this code example. Explore the headers needed to handle JSON data and the parameters required to effortlessly create a fresh bundle. Improve your API interaction skills with this informative docume
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "lmXaCrPgN6FIlll_3aiuX",
  "data": {
    "url": "https://api.fictive.com/REST/api/bundles",
    "name": "Creates a Bundle for the affiliate",
    "method": "POST",
    "request": {
      "pathParameters": [],
      "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": "bundle",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "name",
              "type": "string",
              "example": "",
              "description": "The bundle name"
            },
            {
              "kind": "optional",
              "name": "description",
              "type": "string",
              "example": "",
              "description": "The bundle description"
            },
            {
              "kind": "optional",
              "name": "tag",
              "type": "string",
              "example": "",
              "description": "The optional bundle tag"
            },
            {
              "kind": "optional",
              "name": "status",
              "type": "string<Active | Inactive | Archived>",
              "example": "",
              "description": "The bundle's status"
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.Bundle.Bundle",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v1.Bundle.Bundle",
          "isExpanded": true,
          "description": "The Dto of a bundle"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "kind": "optional",
                "name": "bundleReference",
                "type": "string",
                "example": "",
                "description": "The bundle Id converted to a reference"
              },
              {
                "kind": "optional",
                "name": "carts",
                "type": "array",
                "schema": [
                  {
                    "kind": "optional",
                    "name": "cartReference",
                    "type": "string",
                    "example": "",
                    "description": "Cart reference"
                  },
                  {
                    "kind": "optional",
                    "name": "active",
                    "type": "boolean",
                    "example": "",
                    "description": "The flag for displaying if the cart is active"
                  },
                  {
                    "kind": "optional",
                    "name": "trialInfo",
                    "type": "object",
                    "schema": [
                      {
                        "kind": "optional",
                        "name": "trialEnabled",
                        "type": "boolean",
                        "example": "",
                        "description": "Trial enabled"
                      },
                      {
                        "kind": "optional",
                        "name": "trialUnit",
                        "type": "string<Unspecified | None | Minute | Hour | Day | Month | Year>",
                        "example": "",
                        "description": "Trial unit"
                      },
                      {
                        "kind": "optional",
                        "name": "trialPeriod",
                        "type": "integer<int32>",
                        "example": 0,
                        "description": "Trial period"
                      },
                      {
                        "kind": "optional",
                        "name": "discountPercentage",
                        "type": "number<double>",
                        "example": "",
                        "description": "Discount percentage"
                      },
                      {
                        "kind": "optional",
                        "name": "nonPaymentTrial",
                        "type": "boolean",
                        "example": "",
                        "description": "Non payment trial"
                      },
                      {
                        "kind": "optional",
                        "name": "trialChargedAsSinglePeriod",
                        "type": "boolean",
                        "example": "",
                        "description": "Trial charged as single period"
                      }
                    ],
                    "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v2.TrialInfo",
                    "customType": "FictiveGlobal.Api.Rest.Dtos.v2.TrialInfo",
                    "description": "The trial info for the service in the cart"
                  },
                  {
                    "kind": "optional",
                    "name": "contractReference",
                    "type": "string",
                    "example": "",
                    "description": "Contract reference associated to the cart"
                  },
                  {
                    "kind": "optional",
                    "name": "accountReference",
                    "type": "string",
                    "example": "",
                    "description": "Account reference associated to the cart"
                  },
                  {
                    "kind": "optional",
                    "name": "lineItems",
                    "type": "array",
                    "schema": [
                      {
                        "kind": "optional",
                        "name": "lineItemReference",
                        "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": "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 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": "title",
                            "type": "string",
                            "example": "",
                            "description": "Product Title"
                          },
                          {
                            "kind": "optional",
                            "name": "productReference",
                            "type": "string",
                            "example": "",
                            "description": "Product Reference"
                          }
                        ],
                        "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v3.Cart.LineItemProductInfo",
                        "customType": "FictiveGlobal.Api.Rest.Dtos.v3.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.v3.Cart.CartItem",
                    "customType": "FictiveGlobal.Api.Rest.Dtos.v3.Cart.CartItem[]",
                    "description": "Items within the cart"
                  }
                ],
                "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.Bundle.BundleCart",
                "customType": "FictiveGlobal.Api.Rest.Dtos.v1.Bundle.BundleCart[]",
                "description": "The carts attached to the bundle"
              },
              {
                "kind": "optional",
                "name": "name",
                "type": "string",
                "example": "",
                "description": "The bundle name"
              },
              {
                "kind": "optional",
                "name": "description",
                "type": "string",
                "example": "",
                "description": "The bundle description"
              },
              {
                "kind": "optional",
                "name": "tag",
                "type": "string",
                "example": "",
                "description": "The optional bundle tag"
              },
              {
                "kind": "optional",
                "name": "status",
                "type": "string<Active | Inactive | Archived>",
                "example": "",
                "description": "The bundle's status"
              }
            ],
            "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.Bundle.BundleContents",
            "customType": "FictiveGlobal.Api.Rest.Dtos.v1.Bundle.BundleContents",
            "isExpanded": true,
            "description": "The Dto of a bundle contents"
          }
        ],
        "isExpanded": true,
        "statusCode": "201",
        "description": "Created",
        "jsonExample": "{\n  \"bundleReference\": \"001PB4PI6KTEVRY8R2\",\n  \"carts\": [],\n  \"name\": \"First Bundle (With Tag)\",\n  \"description\": \"The first bundle, featuring a tag\",\n  \"tag\": \"A001\",\n  \"status\": \"Active\"\n}"
      },
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Bad Request\r\n            <br />• Bundle name is invalid\r\n            <br />• Bundle description is invalid\r\n            <br />• Bundle tag is invalid\r\n            <br />• Bundle status is invalid",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "409",
        "description": "Conflict\r\n            <br />• Bundle name already exists\r\n            <br />• Bundle tag already exists",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "500",
        "description": "Internal Server Error",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint allows the ability to create a bundle.",
    "examples": {
      "languages": [
        {
          "id": "vZtE6ckgjy_yOnnQDmIF9",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/bundles \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "PW5IHEU9RO95POAoFRg6S",
          "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/bundles\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "egT8sPbs5a9iM2-ktHjhY",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/bundles\")\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": "HP6Ymxcbj7CNJ56CynsRN",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/bundles\"\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": "vZtE6ckgjy_yOnnQDmIF9"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "{\n  \"bundleReference\": \"001PB4PI6KTEVRY8R2\",\n  \"carts\": [],\n  \"name\": \"First Bundle (With Tag)\",\n  \"description\": \"The first bundle, featuring a tag\",\n  \"tag\": \"A001\",\n  \"status\": \"Active\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Bad Request\r\n            • Bundle name is invalid\r\n            • Bundle description is invalid\r\n            • Bundle tag is invalid\r\n            • Bundle status is invalid\n"
        },
        {
          "id": "response-2-409",
          "language": "409",
          "code": "// Conflict\r\n            • Bundle name already exists\r\n            • Bundle tag already exists\n"
        },
        {
          "id": "response-3-500",
          "language": "500",
          "code": "// Internal Server Error\n"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}