User Role

A User Role represents the role a user has for a specific resource or resource type.

A role represents a collection of permissions (see Role).

Resource URIs

  • Item URI: /v7.0/user_role/{pk}/
  • Collection URI: /v7.0/user_role/

Item

Item Methods

  • GET Retrieve a User Role by id
  • DELETE Delete a User Role by id
  • self A link to this resource
  • user A link to the User resource that owns the User Role
  • role The assigned role.
  • resource The resource this role applies to.

Collection

Collection methods

  • POST Set or update a role for a user on a resource. Requesting user must have the manage_roles permission on the specified resource.

Collection query parameters

Name Description Type Required
resource The path of the resource you want to see roles for (e.g. /page/123/). string Required unless user_id is provided.
user_id The ID of the user whose roles you wish to have returned. string Required unless resource is provided.

Usage

GET User Role entity

Request GET: /v7.0/user_role/24578713_page_association_16/
Response
{
    "_links": {
        "resource": [
            {
                "href": "/page_association/16/"
            }
        ],
        "self": [
            {
                "href": "/api/v7.0/user_role/24578713_page_association_16/",
                "id": "24578713_page_association_16"
            }
        ],
        "documentation": [
            {
                "href": "https://developer.mapmyfitness.com/docs/v70_User_Role/"
            }
        ],
        "role": [
            {
                "href": "/api/v7.0/role/administrator/",
                "id": "administrator"
            }
        ],
        "user": [
            {
                "href": "/v7.0/user/24578713/",
                "id": "24578713"
            }
        ],
    }
}

POST User Role entity

Request POST: /v7.0/user_role/
{
    "user": "1234",
    "resource": "/api/v7.0/page/1234/",
    "role": "/api/v7.0/role/administrator/"
}
Response
{
    "user": "1234",
    "resource": "/api/v7.0/page/1234/",
    "role": "/api/v7.0/role/administrator/"
}

DELETE User Role entity

Request DELETE: /v7.0/user_role/24578713_page_association_16/
Response
204 No Content