Roles and privilegesGrant a privilege to a role

Grant a privilege to a role

Adds one privilege (an area privilege for an event-type group) to an existing role.

Switches on one cell of a role's privilege matrix — the same change as ticking a privilege checkbox for a role in TimeLog's settings. If the event-type group is connected to pages, the role also gets access to those pages. It does not create a role, and REST v1 has no operation that creates or deletes roles. The call returns 200 with body null. There is no read operation for a role's privileges, so the result cannot be verified through REST v1.

Use it to:

  • Provision a account's role set-up from a template (same privileges on many accounts)

Not for:

  • Creating a role — not possible in REST v1
  • Giving a role to a user — use UserRoleIDs on POST /v1/user/create / update

Rules across fields:

Behaviour:

  • Not idempotent.
  • Safe to retry only under a condition.
  • Duplicates: Not deduplicated — the same mapping can be stored several times.
  • Side effect: Recomputes the time-tracking search rows of the role's users when the privilege is 'register on all tasks' or 'projects available for employee department / resource group'.
  • Side effect: Maps the group's connected pages to the role (page access), each with its own audit events.
  • On failure: Unknown RoleID or AreaPrivilegeGUID with a valid group: the inserts, the allocation recompute and the page mappings are kept; the call returns 500.

Call first: GET /v1/role

See also: DELETE /v1/role, GET /v1/privilege/user-privileges

Not yet documented: behaviour → consistency; examples (success).

curl -X POST "https://app3.timelog.com/your-account/api/v1/role" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
  "RoleID": 123,
  "AreaPrivilegeGUID": "123e4567-e89b-12d3-a456-426614174000",
  "EventTypeGroupGUID": "123e4567-e89b-12d3-a456-426614174000"
}'
"null"
POST
/v1/role
POST
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token
Bearer Tokenstring
Required

OAuth 2.0 bearer token, sent as Authorization: Bearer <token>. JWT and reference tokens are both accepted. The token must carry the required scope (default tlp). The token's sub claim is the acting user. A token WITHOUT sub (client-credentials) acts as the system service user. If the sub user cannot log in (inactive, locked, deleted), the request is rejected with 401 — it is no longer let through without a user. > Not yet documented: how to obtain a token. > Not yet documented: token lifetime.

OAuth 2.0 bearer token, sent as Authorization: Bearer <token>. JWT and reference tokens are both accepted. The token must carry the required scope (default tlp). The token's sub claim is the acting user. A token WITHOUT sub (client-credentials) acts as the system service user. If the sub user cannot log in (inactive, locked, deleted), the request is rejected with 401 — it is no longer let through without a user. > Not yet documented: how to obtain a token. > Not yet documented: token lifetime.
Content-Typestring
Required

The media type of the request body

Options: application/json
RoleIDinteger
Required

The role to change. Refers to RoleRead.RoleID. Look up valid values with GET /v1/role. - On POST the mapping rows are already written when it fails. - The role is a locked system role or an employee-specific role — No check on the role kind. role.list does not return locked system or employee-specific roles, but this field accepts them. Valid values come from GET /v1/role.

AreaPrivilegeGUIDstring
Required

GUID of the area privilege (a row of TimeLog's privilege catalogue, e.g. 'all employees' in the employee area). Reference to another object. - On POST the mapping rows are already written when it fails. - The area privilege does not belong to the event-type group's area — No pairing check. > Not yet documented: values → lookup op.

Format: uuid
EventTypeGroupGUIDstring
Required

GUID of the event-type group: the set of actions (event types) the privilege is granted for, e.g. view / create / edit. Reference to another object. - The group has connected pages — POST also gives the role access to those pages; DELETE removes them unless another group still needs them. > Not yet documented: values → lookup op.

Format: uuid
Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token. OAuth 2.0 bearer token, sent as Authorization: Bearer <token>. JWT and reference tokens are both accepted. The token must carry the required scope (default tlp).

The token's sub claim is the acting user. A token WITHOUT sub (client-credentials) acts as the system service user. If the sub user cannot log in (inactive, locked, deleted), the request is rejected with 401 — it is no longer let through without a user.

Not yet documented: how to obtain a token.

Not yet documented: token lifetime.

Body

application/json
RoleIDinteger
Required

The role to change.

Refers to RoleRead.RoleID. Look up valid values with GET /v1/role.

  • On POST the mapping rows are already written when it fails.

  • The role is a locked system role or an employee-specific role — No check on the role kind.

role.list does not return locked system or employee-specific roles, but this field accepts them.

Valid values come from GET /v1/role.

AreaPrivilegeGUIDstring
Required

GUID of the area privilege (a row of TimeLog's privilege catalogue, e.g. 'all employees' in the employee area).

Reference to another object.

  • On POST the mapping rows are already written when it fails.

  • The area privilege does not belong to the event-type group's area — No pairing check.

Not yet documented: values → lookup op.

EventTypeGroupGUIDstring
Required

GUID of the event-type group: the set of actions (event types) the privilege is granted for, e.g. view / create / edit.

Reference to another object.

  • The group has connected pages — POST also gives the role access to those pages; DELETE removes them unless another group still needs them.

Not yet documented: values → lookup op.

Responses

Success without content: HTTP 200 with the literal JSON body null. Literal JSON null.