---
title: Save Policy Key
slug: single-connect-api-3-0-3/save-policy-key
description: Learn how to send a POST request using curl in this comprehensive document. Gain valuable insights into saving a policy key by referring to our code example, which covers everything from specifying the URL to setting headers and providing the request body
docTags: 
createdAt: 2022-11-10T14:21:49.000Z
---

{
  "id": "CZGN_NRRX-xqVXbtlGgJW",
  "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": "XBkfW2jnK7R2wZQd4lYSn",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url {{url}}/aioc-rest-web/rest/policy/savePolicyKey \\\n     --header 'accept: application/json'"
        },
        {
          "id": "W3sruSKAKE86D_wyUD1B3",
          "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": "py59b58P0JhNX95dn11L2",
          "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": "sxv50EgbzE1K6EanvPrC3",
          "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": "XBkfW2jnK7R2wZQd4lYSn"
    },
    "results": {
      "languages": [
        {
          "id": "5broJO8e1qiW8gpLiDaUj",
          "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": "5broJO8e1qiW8gpLiDaUj"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}