---
title: Save Policy Key
slug: single-connect-api-3-2-0/save-policy-key
description: Learn how to make a POST request to securely save a policy key with this comprehensive code example in CURL. Explore the included headers and data payload to effortlessly implement this crucial functionality.
docTags: 
createdAt: 2022-11-10T14:24:52.000Z
---

{
  "id": "KNKFy_beJCOdTaRz3aHrG",
  "data": {
    "url": "{{url}}/aioc-rest-web/rest/policy/savePolicyKey",
    "method": "POST",
    "request": {
      "pathParameters": [],
      "queryParameters": [],
      "headerParameters": [
        {
          "name": "Content-Type",
          "type": "string",
          "example": "application/json",
          "description": ""
        },
        {
          "name": "X-XSRF-TOKEN",
          "type": "string",
          "example": "{{csrftoken}}",
          "description": ""
        }
      ],
      "bodyDataParameters": [
        {
          "name": "body",
          "type": "string",
          "example": "{\r\n    \"key\": \"ls \",\r\n    \"description\": \"ls\",\r\n    \"type\": \"WHITE\",\r\n    \"deviceTypes\": [\r\n            \"linux\"\r\n     ]\r\n}",
          "description": ""
        }
      ],
      "formDataParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Create Policy Key",
        "jsonExample": "{\n    \"dbId\": 379291,\n    \"userCreate\": \"admin\",\n    \"userUpdate\": null,\n    \"creationDate\": 1581611787840,\n    \"lastUpdate\": null,\n    \"key\": \"ls \",\n    \"description\": \"ls\",\n    \"userBehaviorRate\": null,\n    \"type\": \"WHITE\",\n    \"deviceTypes\": [\n        \"linux\"\n    ],\n    \"taskName\": null,\n    \"xmlContent\": null\n}"
      }
    ],
    "contentType": "application/json",
    "description": "This method creates a new policy key with its features sent in request body.",
    "examples": {
      "languages": [
        {
          "id": "S01r2E_XURsm8tDN_m8J0",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url {{url}}/aioc-rest-web/rest/policy/savePolicyKey \\\n     --header 'accept: application/json'"
        },
        {
          "id": "2T-gpH7nBQwoRKswad23J",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"{{url}}/aioc-rest-web/rest/policy/savePolicyKey\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "M5q1N3au_F3mIN3RRxgFp",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"{{url}}/aioc-rest-web/rest/policy/savePolicyKey\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "6u668C3gsbigELyrchuNb",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"{{url}}/aioc-rest-web/rest/policy/savePolicyKey\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "S01r2E_XURsm8tDN_m8J0"
    },
    "results": {
      "languages": [
        {
          "id": "C_-oWq_-j7KdzGLeEoHWp",
          "language": "200",
          "code": "{\n    \"dbId\": 379291,\n    \"userCreate\": \"admin\",\n    \"userUpdate\": null,\n    \"creationDate\": 1581611787840,\n    \"lastUpdate\": null,\n    \"key\": \"ls \",\n    \"description\": \"ls\",\n    \"userBehaviorRate\": null,\n    \"type\": \"WHITE\",\n    \"deviceTypes\": [\n        \"linux\"\n    ],\n    \"taskName\": null,\n    \"xmlContent\": null\n}"
        }
      ],
      "selectedLanguageId": "C_-oWq_-j7KdzGLeEoHWp"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}