Core
API v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

createOrReplaceRole #

Creates a new role or, if the provided role identifier already exists, replaces it.


Query Syntax #

HTTP #

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

Other protocols #

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

Arguments #

  • _id: role identifier

Optional: #

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

Body properties #


Response #

Returns the role creation/replacement status:

  • _id: created/replaced role identifier
  • _source: role definition
  • created: if true, the role has been created. Otherwise, it has been replaced
  • version: updated role version number
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": "createOrReplaceRole"
}