---
title: Creates a gift code and sends it to the recipient
slug: docs/demo/creates-a-gift-code-and-sends-it-to-the-recipient
description: Learn how to make a cURL POST request to a simulated API endpoint with this helpful code example. This document guides you through the process, demonstrating the inclusion of headers and JSON data to achieve a successful request. Enhance your coding skill
docTags: 
createdAt: 2022-03-21T20:12:45.000Z
---

{
  "id": "y5xvCS-hkL2zL4j8WbQxZ",
  "data": {
    "url": "https://api.fictive.com/REST/api/gifts",
    "name": "Creates a gift code and sends it to the recipient",
    "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": "gift",
          "type": "object",
          "schema": [
            {
              "kind": "optional",
              "name": "productPriceReference",
              "type": "string",
              "example": "",
              "description": "The product price reference associated with the gift"
            },
            {
              "kind": "optional",
              "name": "recipientNickName",
              "type": "string",
              "example": "",
              "description": "Recipient's nick name"
            },
            {
              "kind": "optional",
              "name": "senderNickName",
              "type": "string",
              "example": "",
              "description": "Sender's nick name"
            },
            {
              "kind": "optional",
              "name": "message",
              "type": "string",
              "example": "",
              "description": "The gifting message"
            },
            {
              "kind": "optional",
              "name": "startDate",
              "type": "string<date-time>",
              "example": "",
              "description": "Start date"
            },
            {
              "kind": "optional",
              "name": "emailAddress",
              "type": "string",
              "example": "",
              "description": "The email addess"
            },
            {
              "kind": "optional",
              "name": "title",
              "type": "string",
              "example": "",
              "description": "The tile"
            },
            {
              "kind": "optional",
              "name": "firstName",
              "type": "string",
              "example": "",
              "description": "First name"
            },
            {
              "kind": "optional",
              "name": "surname",
              "type": "string",
              "example": "",
              "description": "Surname"
            }
          ],
          "modelRef": "#/definitions/FictiveGlobal.Api.Rest.Dtos.v1.Gifting.Gift",
          "customType": "FictiveGlobal.Api.Rest.Dtos.v1.Gifting.Gift",
          "isExpanded": true,
          "description": "Gift DTO entity"
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Bad request",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "401",
        "description": "Not Authorized",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "Not found",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "500",
        "description": "Internal Server Error",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "This endpoint lets you create a gift, during a product purchase workflow, that will be sent to the recipient and can be redeemed against the configured subscription.",
    "examples": {
      "languages": [
        {
          "id": "I11LyHowNu3eJ_jPn36lF",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.fictive.com/REST/api/gifts \\\n     --header 'accept: application/json' \\\n     --header 'x-version: string'"
        },
        {
          "id": "n2XV8DXBZjo1jqcSY2W_k",
          "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/gifts\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "TVwZSK2EavGD6k8GIPEgl",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.fictive.com/REST/api/gifts\")\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": "v6-g_gLiNTnhtuEWzCEAk",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.fictive.com/REST/api/gifts\"\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": "I11LyHowNu3eJ_jPn36lF"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-400",
          "language": "400",
          "code": "// Bad request\n"
        },
        {
          "id": "response-1-401",
          "language": "401",
          "code": "// Not Authorized\n"
        },
        {
          "id": "response-2-404",
          "language": "404",
          "code": "// Not found\n"
        },
        {
          "id": "response-3-500",
          "language": "500",
          "code": "// Internal Server Error\n"
        }
      ],
      "selectedLanguageId": "response-0-400"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}