---
title: Replicate iTunes subscription within eSuite
slug: docs/demo/replicate-itunes-subscription-within-esuite
description: Learn how to make a POST request to a fictive API effortlessly with this code example. Discover how to include headers and data in JSON format, ensuring efficient communication between your application and the API. Boost your coding skills and dive into t
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "Kk7qFvYkH3QNalL469Sim",
  "data": {
    "url": "https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions/native-billing/itunes",
    "name": "Replicate iTunes subscription within eSuite",
    "method": "POST",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "accountReference",
          "type": "string",
          "description": "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": "subscribeITunesAppRequest",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "receipt",
              "type": "string",
              "example": "",
              "description": "The encrypted receipt returned from the iTunes stored when the app was purchased."
            },
            {
              "kind": "optional",
              "name": "itunesproductid",
              "type": "string",
              "example": "",
              "description": "(Optional)The itune product id to be used to validate the receipt if provided."
            },
            {
              "kind": "optional",
              "name": "currency",
              "type": "string",
              "example": "",
              "description": "(Optional) The currency to be used for the purchase flow"
            },
            {
              "kind": "optional",
              "name": "price",
              "type": "number<double>",
              "example": "",
              "description": "(Optional) The price of the subscription being purchased\r\n            Only used for dynamically priced services."
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.SubscribeITunesDetailsForSession",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v1.SubscribeITunesDetailsForSession",
          "isExpanded": true,
          "description": "Information from a recently purchased iTunes application required for creating a new subscription"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "401",
        "description": "• Not Authorized",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "412",
        "description": "Precondition Failed\r\n            <br />• Currency is not set up for this service.\r\n            <br />• The service is not configured correctly. The service must be active.\r\n            <br />• The service is not configured correctly. ITunes must be enabled for the service.\r\n            <br />• The receipt contains multiple valid purchases.\r\n            <br />• Preferred currency is not set up for this service.\r\n            <br />• The service is not configured correctly.",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint will provide the ability to create a subscription against a pre-existing eSuite account that has been purchased via the native iTunes store",
    "examples": {
      "languages": [
        {
          "id": "7Y7ccPfBzWT3M1Vm4VomH",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions/native-billing/itunes \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "dVLZGrDC_3FNQOH7z5zsw",
          "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/native-billing/itunes\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "eN0QDvpDm0pF0ur41p8af",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions/native-billing/itunes\")\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": "fJt0-DJV20rXnVOaNk5no",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/accounts/{accountReference}/subscriptions/native-billing/itunes\"\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": "7Y7ccPfBzWT3M1Vm4VomH"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-401",
          "language": "401",
          "code": "// • Not Authorized\n"
        },
        {
          "id": "response-1-412",
          "language": "412",
          "code": "// Precondition Failed\r\n            • Currency is not set up for this service.\r\n            • The service is not configured correctly. The service must be active.\r\n            • The service is not configured correctly. ITunes must be enabled for the service.\r\n            • The receipt contains multiple valid purchases.\r\n            • Preferred currency is not set up for this service.\r\n            • The service is not configured correctly.\n"
        }
      ],
      "selectedLanguageId": "response-0-401"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}