createRole

Creates a new role.


Query Syntax

HTTP

Copied to clipboard!
URL: http://kuzzle:7512/roles/<_id>/_create[?refresh=wait_for]
Method: POST
Body:
Copied to clipboard!
{
  "controllers": {
    "*": {
      "actions": {
        "*": true
      }
    }
  }
}

Other protocols

Copied to clipboard!
{
  "controller": "security",
  "action": "createRole",
  "_id": "<roleId>",
  "body": {
    "controllers": {
      "*": {
        "actions": {
          "*": true
        }
      }
    }
  }
}

Arguments

  • _id: role identifier

Optional:

  • refresh: if set to wait_for, Kuzzle will not respond until the created role is indexed

Body properties


Response

Returns the role creation/replacement status:

  • _id: created/replaced role identifier
  • _source: role definition
  • created: always true
  • version: always 1
Copied to clipboard!
{
  "status": 200,
  "error": null,
  "result": {
    "_id": "<roleId>",
    "_version": 1,
    "created": true,
    "_source": {
      "controllers": {
        "*": {
          "actions": {
            "*": true
          }
        }
      }
    }
  }
  "requestId": "<unique request identifier>",
  "controller": "security",
  "action": "createRole"
}