---
title: Create account if it does not exist, if it exists authenticate account and create a subscription in the system for the service provided in the request object
slug: docs/demo/jzLc-create-account-if-it-does-not-exist-if-it-exists-authenticate-account-and-create-a-subscription-in-the-system-for-the-service-provided-in-the-request-object
description: Learn how to send a POST request to an API endpoint using cURL with this comprehensive code example. Explore the included headers and JSON payload, containing crucial parameters like package name, subscription ID, access tokens, and more. Master the art o
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "SL7BnNDzF7Gk5WU3egROV",
  "data": {
    "url": "https://api.fictive.com/REST/api/native-billing/google",
    "name": "Create account if it does not exist, if it exists authenticate account and create a subscription in the system for the service provided in the request object",
    "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": "request",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "packageName",
              "type": "string",
              "example": "",
              "description": "The purchased subscription name"
            },
            {
              "kind": "optional",
              "name": "googlePlaySubscriptionId",
              "type": "string",
              "example": "",
              "description": "The Google Id of the Subscription"
            },
            {
              "kind": "optional",
              "name": "token",
              "type": "string",
              "example": "",
              "description": "The receipt token"
            },
            {
              "kind": "optional",
              "name": "redirectUrl",
              "type": "string",
              "example": "",
              "description": "The google redirect URL"
            },
            {
              "kind": "optional",
              "name": "authorizationCode",
              "type": "string",
              "example": "",
              "description": "The authorization code used to authenticate with Google"
            },
            {
              "kind": "optional",
              "name": "accessToken",
              "type": "string",
              "example": "",
              "description": "The authorization code used to authenticate with Google"
            },
            {
              "kind": "optional",
              "name": "applicationIdentifier",
              "type": "string",
              "example": "",
              "description": "The Google app identifier"
            },
            {
              "kind": "optional",
              "name": "email",
              "type": "string",
              "example": "",
              "description": "Email address of the purchaser"
            },
            {
              "kind": "optional",
              "name": "password",
              "type": "string",
              "example": "",
              "description": "Password address of the subscriber"
            },
            {
              "kind": "optional",
              "name": "newAccountDetails",
              "type": "object",
              "schema": [
                {
                  "kind": "optional",
                  "name": "firstName",
                  "type": "string",
                  "example": "",
                  "description": "First name of the purchaser."
                },
                {
                  "kind": "optional",
                  "name": "lastName",
                  "type": "string",
                  "example": "",
                  "description": "Last name of the purchaser."
                }
              ],
              "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.NewAccountDetails",
              "customType": "FictiveGlobal.Api.Rest.Dtos.v1.NewAccountDetails",
              "description": "New account details of the purchaser"
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.GooglePurchaseReceipt",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v1.GooglePurchaseReceipt",
          "isExpanded": true,
          "description": "Object used for Native Billing functionality with Google Play"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "• An error occurred while processing the request",
        "jsonExample": ""
      },
      {
        "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. Google Play must be enabled for the service.\r\n            <br />• The service is not configured correctly.",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "500",
        "description": "• Internal Server Error",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "examples": {
      "languages": [
        {
          "id": "NatSYrNaWI7NB5DdjavmU",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/native-billing/google \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "i6HzSDEGn906dhDh3v0Fy",
          "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/native-billing/google\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "4gTIObz3arQvMw0C1etGV",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/native-billing/google\")\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": "DT0ZqQVyjSurybUOUaFJ7",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/native-billing/google\"\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": "NatSYrNaWI7NB5DdjavmU"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-400",
          "language": "400",
          "code": "// • An error occurred while processing the request\n"
        },
        {
          "id": "response-1-401",
          "language": "401",
          "code": "// • Not Authorized\n"
        },
        {
          "id": "response-2-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. Google Play must be enabled for the service.\r\n            • The service is not configured correctly.\n"
        },
        {
          "id": "response-3-500",
          "language": "500",
          "code": "// • Internal Server Error\n"
        }
      ],
      "selectedLanguageId": "response-0-400"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}