---
title: Initiate a subscription purchase
slug: docs/demo/initiate-a-subscription-purchase
description: Learn how to make a successful POST request to a fictional API endpoint with this comprehensive code example. Understand the significance of various parameters, including voucher code, contract reference, payment method, pricing information, entitlements,
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "lQK-EPwHRe_2Au1gFVdLG",
  "data": {
    "url": "https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions",
    "name": "Initiate a subscription purchase",
    "method": "POST",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "accountReference",
          "type": "string",
          "description": "The account reference identifier"
        }
      ],
      "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": "addSubscriptionRequest",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "voucherCode",
              "type": "string",
              "example": "",
              "description": "Gets or sets the Voucher code"
            },
            {
              "kind": "optional",
              "name": "contractReference",
              "type": "string",
              "example": "",
              "description": "Gets or sets the contract reference, which decodes to a SubscriptionId."
            },
            {
              "kind": "optional",
              "name": "cartReference",
              "type": "string",
              "example": "",
              "description": "Reference to a cart that's already been linked to the service"
            },
            {
              "kind": "optional",
              "name": "paymentMethod",
              "type": "string",
              "example": "",
              "description": "The payment method to use when purchasing this subscription"
            },
            {
              "kind": "optional",
              "name": "cvv",
              "type": "string",
              "example": "",
              "description": "Gets or sets the CVV"
            },
            {
              "kind": "optional",
              "name": "renewalDay",
              "type": "integer<int32>",
              "example": 0,
              "description": "Gets or sets the renewal day"
            },
            {
              "kind": "optional",
              "name": "renewalDayOffset",
              "type": "integer<int32>",
              "example": 0,
              "description": "Gets or sets the renewal day offset"
            },
            {
              "kind": "optional",
              "name": "startDate",
              "type": "string<date-time>",
              "example": "2021-09-21T05:33:09.8539889",
              "description": "Gets or sets the start date"
            },
            {
              "kind": "optional",
              "name": "pricing",
              "type": "object",
              "schema": [
                {
                  "kind": "optional",
                  "name": "subscriptionId",
                  "type": "integer<int32>",
                  "example": 0,
                  "description": "Gets or sets the price id."
                },
                {
                  "kind": "optional",
                  "name": "subscriptionPriceReference",
                  "type": "string",
                  "example": "",
                  "description": "Gets or sets the subscription price reference"
                },
                {
                  "kind": "optional",
                  "name": "paymentMethod",
                  "type": "string",
                  "example": "",
                  "description": "Gets or sets the payment method."
                },
                {
                  "kind": "optional",
                  "name": "currency",
                  "type": "string",
                  "example": "",
                  "description": "Gets or sets the currency."
                },
                {
                  "kind": "optional",
                  "name": "price",
                  "type": "number<double>",
                  "example": "",
                  "description": "Gets or sets the price."
                },
                {
                  "kind": "optional",
                  "name": "taxInfo",
                  "type": "object",
                  "schema": [
                    {
                      "kind": "optional",
                      "name": "zeroRated",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the zero rated"
                    },
                    {
                      "kind": "optional",
                      "name": "country",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the country"
                    },
                    {
                      "kind": "optional",
                      "name": "state",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the state"
                    },
                    {
                      "kind": "optional",
                      "name": "county",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the county"
                    },
                    {
                      "kind": "optional",
                      "name": "city",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the city"
                    },
                    {
                      "kind": "optional",
                      "name": "zipCode",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the zipcode"
                    },
                    {
                      "kind": "optional",
                      "name": "street",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the street"
                    }
                  ],
                  "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.TaxRegionInfo",
                  "customType": "FictiveGlobal.Api.Rest.Dtos.v1.TaxRegionInfo",
                  "description": "Gets or sets the tax info."
                },
                {
                  "kind": "optional",
                  "name": "priceItems",
                  "type": "array",
                  "schema": [
                    {
                      "kind": "optional",
                      "name": "externalReference",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the external reference."
                    },
                    {
                      "kind": "optional",
                      "name": "supplierId",
                      "type": "integer<int32>",
                      "example": 0,
                      "description": "Gets or sets the supplier id."
                    },
                    {
                      "kind": "optional",
                      "name": "price",
                      "type": "number<double>",
                      "example": "",
                      "description": "Gets or sets the price."
                    },
                    {
                      "kind": "optional",
                      "name": "description",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the description."
                    }
                  ],
                  "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.PricingItem",
                  "customType": "FictiveGlobal.Api.Rest.Dtos.v1.PricingItem[]",
                  "description": "Gets or sets the price items."
                }
              ],
              "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v4.PricingDirect",
              "customType": "FictiveGlobal.Api.Rest.Dtos.v4.PricingDirect",
              "description": "Gets or sets the pricing"
            },
            {
              "kind": "optional",
              "name": "entitlements",
              "type": "array",
              "schema": [
                {
                  "kind": "optional",
                  "name": "identifier",
                  "type": "string",
                  "example": "",
                  "description": "Gets or sets the identifier of the entitlement."
                },
                {
                  "kind": "optional",
                  "name": "startDate",
                  "type": "string<date-time>",
                  "example": "2021-09-21T05:33:09.9633582",
                  "description": "Gets or sets the create date of the entitlement"
                },
                {
                  "kind": "optional",
                  "name": "expiryDate",
                  "type": "string<date-time>",
                  "example": "2021-09-21T05:33:09.9633582",
                  "description": "Gets or sets the expire date of the entitlement"
                }
              ],
              "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.EntitlementParameter",
              "customType": "FictiveGlobal.Api.Rest.Dtos.v1.EntitlementParameter[]",
              "description": "Gets or sets the entitlements"
            },
            {
              "kind": "optional",
              "name": "customOrderParameters",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Gets or sets the custom order parameters."
            },
            {
              "kind": "optional",
              "name": "customSubscriptionParameters",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Gets or sets the custom subscription parameters."
            },
            {
              "kind": "optional",
              "name": "enhancedProcessingData",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Gets or sets the Enhanced Processing Data parameters."
            },
            {
              "kind": "optional",
              "name": "groupSubscriptionInfo",
              "type": "object",
              "schema": [
                {
                  "kind": "optional",
                  "name": "groupToken",
                  "type": "string",
                  "example": "",
                  "description": "Gets or sets the group token."
                },
                {
                  "kind": "optional",
                  "name": "subscriberAccounts",
                  "type": "array",
                  "schema": [
                    {
                      "kind": "optional",
                      "name": "clientUserId",
                      "type": "string",
                      "example": "",
                      "description": "Gets or sets the client user id."
                    },
                    {
                      "kind": "optional",
                      "name": "emailAddress",
                      "type": "string",
                      "example": "",
                      "description": "Email Address"
                    },
                    {
                      "kind": "optional",
                      "name": "taxInfo",
                      "type": "object",
                      "schema": [
                        {
                          "kind": "optional",
                          "name": "zeroRated",
                          "type": "string",
                          "example": "",
                          "description": "Gets or sets the zero rated"
                        },
                        {
                          "kind": "optional",
                          "name": "country",
                          "type": "string",
                          "example": "",
                          "description": "Gets or sets the country"
                        },
                        {
                          "kind": "optional",
                          "name": "state",
                          "type": "string",
                          "example": "",
                          "description": "Gets or sets the state"
                        },
                        {
                          "kind": "optional",
                          "name": "county",
                          "type": "string",
                          "example": "",
                          "description": "Gets or sets the county"
                        },
                        {
                          "kind": "optional",
                          "name": "city",
                          "type": "string",
                          "example": "",
                          "description": "Gets or sets the city"
                        },
                        {
                          "kind": "optional",
                          "name": "zipCode",
                          "type": "string",
                          "example": "",
                          "description": "Gets or sets the zipcode"
                        },
                        {
                          "kind": "optional",
                          "name": "street",
                          "type": "string",
                          "example": "",
                          "description": "Gets or sets the street"
                        }
                      ],
                      "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.TaxRegionInfo",
                      "customType": "FictiveGlobal.Api.Rest.Dtos.v1.TaxRegionInfo",
                      "description": "Gets or sets the tax info."
                    }
                  ],
                  "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.SubscriberAccount",
                  "customType": "FictiveGlobal.Api.Rest.Dtos.v1.SubscriberAccount[]",
                  "description": "Gets or sets the subscriber accounts."
                }
              ],
              "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.GroupSubscriptionInfoSummary",
              "customType": "FictiveGlobal.Api.Rest.Dtos.v1.GroupSubscriptionInfoSummary",
              "description": "Gets or sets the group subscription info."
            },
            {
              "kind": "optional",
              "name": "asynchronousInitiationParameters",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Gets or sets the custom subscription parameters."
            },
            {
              "kind": "optional",
              "name": "shippingAddressReference",
              "type": "string",
              "example": "",
              "description": "Address reference for the shipping address"
            },
            {
              "kind": "optional",
              "name": "invoiceAddressReference",
              "type": "string",
              "example": "",
              "description": "Address reference for the invoice address"
            },
            {
              "kind": "optional",
              "name": "sendEReceipt",
              "type": "boolean",
              "example": "",
              "description": "Gets or sets the SendEReceipt."
            },
            {
              "kind": "optional",
              "name": "sendBackOfficeEmail",
              "type": "boolean",
              "example": "",
              "description": "Gets or sets the SendBackOfficeEmail."
            },
            {
              "kind": "optional",
              "name": "customFulfilmentParameters",
              "type": "object",
              "schema": [],
              "example": {},
              "description": "Gets or sets the custom fulfilment parameters."
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v3.AddSubscriptionDirect",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v3.AddSubscriptionDirect",
          "isExpanded": true,
          "description": "Add subscription direct request object"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "kind": "optional",
                "name": "amountCharged",
                "type": "number<double>",
                "example": "",
                "description": "Amount charged"
              },
              {
                "kind": "optional",
                "name": "currency",
                "type": "string",
                "example": "",
                "description": "Currency"
              },
              {
                "kind": "optional",
                "name": "paymentType",
                "type": "string",
                "example": "",
                "description": "Payment type"
              },
              {
                "kind": "optional",
                "name": "subscriptionStatus",
                "type": "string",
                "example": "",
                "description": "Subscription status"
              },
              {
                "kind": "optional",
                "name": "renewalDay",
                "type": "integer<int32>",
                "example": 0,
                "description": "Renewal day"
              },
              {
                "kind": "optional",
                "name": "renewalDayOffset",
                "type": "integer<int32>",
                "example": 0,
                "description": "Renewal day offset"
              },
              {
                "kind": "optional",
                "name": "startDate",
                "type": "string<date-time>",
                "example": "2021-09-21T05:33:10.1821164",
                "description": "Start date"
              },
              {
                "kind": "optional",
                "name": "renewalDate",
                "type": "string<date-time>",
                "example": "2021-09-21T05:33:10.1821164",
                "description": "Renewal date"
              },
              {
                "kind": "optional",
                "name": "orderReference",
                "type": "string",
                "example": "",
                "description": "Order reference"
              },
              {
                "kind": "optional",
                "name": "contractReference",
                "type": "string",
                "example": "",
                "description": "Contract reference (encoded ServiceID)"
              },
              {
                "kind": "optional",
                "name": "subscriptionPriceReference",
                "type": "string",
                "example": "",
                "description": "Subscription price reference"
              },
              {
                "kind": "optional",
                "name": "subscriptionReference",
                "type": "string",
                "example": "",
                "description": "Subscription reference"
              },
              {
                "kind": "optional",
                "name": "resourceReference",
                "type": "string",
                "example": "",
                "description": "Resource reference"
              },
              {
                "kind": "optional",
                "name": "asynchronousProcessingParameters",
                "type": "object",
                "schema": [],
                "example": {},
                "description": "Asynchronous Processing Parameters"
              },
              {
                "kind": "optional",
                "name": "shippingAddressReference",
                "type": "string",
                "example": "",
                "description": "Address reference for the shipping address"
              },
              {
                "kind": "optional",
                "name": "invoiceAddressReference",
                "type": "string",
                "example": "",
                "description": "Address reference for the invoice address"
              },
              {
                "kind": "optional",
                "name": "sessionToken",
                "type": "string",
                "example": "",
                "description": "Session token"
              },
              {
                "kind": "optional",
                "name": "cartReference",
                "type": "string",
                "example": "",
                "description": "Cart reference (if this was a Bundle Purchase subscription)"
              }
            ],
            "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v4.AddSubscriptionSummary",
            "customType": "FictiveGlobal.Api.Rest.Dtos.v4.AddSubscriptionSummary",
            "isExpanded": true,
            "description": "Add subscription response object"
          }
        ],
        "isExpanded": true,
        "statusCode": "200",
        "description": "OK",
        "jsonExample": "{\n  \"amountCharged\": 10,\n  \"currency\": \"GBP\",\n  \"paymentType\": \"eWallet\",\n  \"subscriptionStatus\": \"Active\",\n  \"renewalDay\": 1,\n  \"renewalDayOffset\": 0,\n  \"startDate\": \"2021-09-21T05:33:10.2914978+00:00\",\n  \"renewalDate\": \"2021-09-21T05:33:10.2914978+00:00\",\n  \"orderReference\": \"0010KFS4AXAQTC1VE6\",\n  \"contractReference\": \"0010KFS4WXAQTD1IV1\",\n  \"subscriptionPriceReference\": \"0010NU1UB9TFEGEZ61\",\n  \"subscriptionReference\": \"SubscriptionReference\",\n  \"resourceReference\": \"ResourceReference\",\n  \"asynchronousProcessingParameters\": {\n    \"name1\": \"value1\"\n  },\n  \"shippingAddressReference\": \"0010D0ZRRUGNBNUKM1\",\n  \"invoiceAddressReference\": \"0010DDXSRHB9ZU07Z1\",\n  \"cartReference\": \"CDE456\"\n}"
      },
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Request is invalid.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "403",
        "description": "Unable to authenticate using the provided session.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "Not Found.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "409",
        "description": "Conflict.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "412",
        "description": "Precondition Failed.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "500",
        "description": "Internal Server Error.",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint will provide the ability to initiate the purchase of a subscription.\r\n             In the event the account is paying using a synchronous payment method (such as credit card) the purchase will complete instantly,\r\n             if the account selects an synchronous payment (PayPal, P24, etc.)\r\n             a redirect URL will be provided in the return to the request",
    "examples": {
      "languages": [
        {
          "id": "w7PkLg3ZfzLvAz2dkTr5R",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "sd7XnQyia91zeSJr4uxAe",
          "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/accounts/{accountReference}/subscriptions\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "v7NFlRWKF_KXuGb9WYZPb",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions\")\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": "WmGB7Lz_xLuhe00Yll5wp",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions\"\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": "w7PkLg3ZfzLvAz2dkTr5R"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "{\n  \"amountCharged\": 10,\n  \"currency\": \"GBP\",\n  \"paymentType\": \"eWallet\",\n  \"subscriptionStatus\": \"Active\",\n  \"renewalDay\": 1,\n  \"renewalDayOffset\": 0,\n  \"startDate\": \"2021-09-21T05:33:10.2914978+00:00\",\n  \"renewalDate\": \"2021-09-21T05:33:10.2914978+00:00\",\n  \"orderReference\": \"0010KFS4AXAQTC1VE6\",\n  \"contractReference\": \"0010KFS4WXAQTD1IV1\",\n  \"subscriptionPriceReference\": \"0010NU1UB9TFEGEZ61\",\n  \"subscriptionReference\": \"SubscriptionReference\",\n  \"resourceReference\": \"ResourceReference\",\n  \"asynchronousProcessingParameters\": {\n    \"name1\": \"value1\"\n  },\n  \"shippingAddressReference\": \"0010D0ZRRUGNBNUKM1\",\n  \"invoiceAddressReference\": \"0010DDXSRHB9ZU07Z1\",\n  \"cartReference\": \"CDE456\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Request is invalid.\n"
        },
        {
          "id": "response-2-403",
          "language": "403",
          "code": "// Unable to authenticate using the provided session.\n"
        },
        {
          "id": "response-3-404",
          "language": "404",
          "code": "// Not Found.\n"
        },
        {
          "id": "response-4-409",
          "language": "409",
          "code": "// Conflict.\n"
        },
        {
          "id": "response-5-412",
          "language": "412",
          "code": "// Precondition Failed.\n"
        },
        {
          "id": "response-6-500",
          "language": "500",
          "code": "// Internal Server Error.\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}