ZEN Master
...
Configuring API Keys
Example: API keys with Roles and Tags
6 min
control user permissions with roles and tags in this example, we'll create an api key that allows read only access privileges to a specific group of sources step 1 create a tag first, we'll create a tag that can be assigned to zen master objects in the left navigation, select configuration > tags select +add to create a new tag give the tag a name and select save step 2 create an api key next, we'll create an api key in the left navigation, select configuration > api keys select +add key to create a new api key in the create new api key page enter a name for the api key set the expiration date or leave the default leave the other options unchecked/unselected since the read only , account administrator , and administrator options override the roles persmissions, leave them unchecked click save to create the api key step 3 create a role with a role, we can select user permissions for object types in the left navigation, select account management > roles select +add to create a new role in the create new role page enter a name for the role select the tag that we created in step 1 for permissions , select the checkbox for source select the api key that we created in step 2 click save to create the role step 4 add tag to sources now, we can add our tag to the sources that we want to give read access to for our api key in the left navigation, select sources select the sources that you want to grant read access for the api key, and click edit in the edit sources page select the checkbox to update tags select add to add our new tag without overwriting or removing any existing tags from the dropdown menu, select our new tag click save the multi edit dialog should confirm that each selected source has been updated step 5 using the api key let's test our api key persmissions by making a request to the zen master api the new api key grants the api caller read permission only for the sources that share the key's assigned tag and role send a get api request to list all sources curl location 'https //api zen zixi com/v2/sources' \\ \ header 'x api key \<your api key>' \\ \ header 'accept application/json' the api response should only contain the two sources that we tagged { "success" true, "result" \[ { "id" 12345, "name" "api docs zixi other push", }, { "id" 12346, "name" "api docs zixi other push api", } ] } since we only have read access to two sources, we will not be able to read other objects send a get api request to list all zecs curl location 'https //api zen zixi com/v2/zecs' \\ \ header 'x api key \<your api key>' \\ \ header 'accept application/json' the api response will be 200 ok , but the result will be empty { "success" true, "result" \[] } with only read access, we will not be able to create, update, or delete any objects send a post api request to create a new source curl location 'https //api zen zixi com/v2/sources' \\ \ header 'x api key \<your api key>' \\ \ header 'content type application/json' \\ \ header 'accept application/json' \\ \ data '{ "name" "api docs zixi other push", "broadcaster cluster id" 4444, "target broadcaster id" 1, "resource tag ids" \[ 11 ], "autopull latency" 1000 }' the api response will be an unauthorized error { "success" false, "error" "unauthorized" }
