POST

Create Security Policy

Creates a new Security Policy for users or apps.

Creating a custom (non-default) Security Policy requires the “Custom Security Policies” plan feature. Accounts without this feature enabled receive a 406 Not Acceptable response.

Resource URL

https://<subdomain>.onelogin.com/api/2/policies

Header Parameters

ParameterDescription
Authorizationbearer:<access_token>. Requires a scope of Manage All.
Content-Typeapplication/json

Request Parameters

ParameterTypeDescription
nameStringRequired. Policy name.
kindStringRequired. user or app. Cannot be changed after creation.
...Any attribute listed on the Policy Resource page appropriate to the chosen kind.

Sample Responses

201 Created

{
  "status": {
    "error": false,
    "code": 201,
    "type": "success",
    "message": "Success"
  },
  "data": [
    {
      "id": 3,
      "name": "Custom User Policy",
      "kind": "user",
      "is_default": false,
      "minimum_password_length": 10
    }
  ]
}

406 Not Acceptable

{
  "status": {
    "error": true,
    "code": 406,
    "type": "not_acceptable",
    "message": "Custom Security Policies feature is not available on your plan"
  }
}

422 Unprocessable Entity

{
  "status": {
    "error": true,
    "code": 422,
    "type": "unprocessable_entity",
    "message": "Validation failed"
  },
  "data": {
    "name": ["can't be blank"]
  }
}

Postman Collection

Add the Security Policies endpoints to your Postman workspace using the OneLogin Postman collection.

Run In Postman

    Clicking Run in Postman button navigates to the page where you can fork the collection to your workspace. Forking the collection into your workspace will enable you to contribute to the source collection using pull requests. You can also view the collection in a public workspace if you like and even import a copy of the collection using the links present on the screen.

Sample Code

curl -X POST \
  https://<subdomain>.onelogin.com/api/2/policies \
  -H 'Authorization: bearer:<access_token>' \
  -H 'Content-Type: application/json' \
  -d '{
        "name": "Custom User Policy",
        "kind": "user",
        "minimum_password_length": 10
      }'