How share stream using rest api

I need to share stream on graylog with multiple users. I want to use rest API for that.
The users already exist in my graylog, the problem is only associate the user with the stream.

Learning the API-Browser, I didn’t find how to work that

I followed the step:

  1. Create the permission for user
    API /users
    '{"permissions": [ "streams:read:602ad48eec1ab24c865cd285"]}'

  2. share permission on entities
    API /authz/shares/entities/{entityGRN}
    entityGRN = grn::::stream:602afd2296ca933d41b20709
    '{ "selected_grantee_capabilities": { "grn::::stream:602afd2296ca933d41b20709": view"}}'

after, when I check the API /authz/shares/user/{userId}, to see the entities permission. And nothing work. look

  "context": {
    "grantee_capabilities": {}

But, when I try again the entities permission, I receive this message:

  "type": "ApiError",
  "message": "Write failed with error code 11000 and error message 'E11000 duplicate key error collection: graylog.grants index: grantee_1_capability_1_target_1 dup key: { grantee: \"grn::::stream:602afd2296ca933d41b20709\", capability: \"view\", target: \"grn::::stream:602afd2296ca933d41b20709\" }'"

The entities permission somehow work, but no show me.

I want only share stream with users using rest API.
Somebody can help-me?


Your example is wrong, it can’t work because:

  1. Your first step is not necessary. Required step is to only assign permission to stream for user, your step two
  2. You use wrong parameter in step two. You use ID of stream and not ID user. Correct format for JSON:
  • USER_ID should be ID of user, and not stream ID.

Complete example using curl:
curl '' -H 'Accept: application/json' -H 'Authorization: Basic BASE64' -H 'Content-Type: application/json' --data-raw '{"selected_grantee_capabilities":{"grn::::user:USER_ID":"view"}}'

  • Use your selected authentication for API: user name, password, token or session token.

If you want to share stream with multiple user you need to specify all users in API:


If you want to only add new user, you can use API /api/authz/shares/entities/grn::::stream:STREAM_ID/prepare with request {} and use it to return already assigned permissions for other users. Then use it as input, concatenate with new NEW_USER_ID using jq:

curl -s '' -H 'Accept: application/json' -H 'Authorization: Basic BASE64' -H 'Content-Type: application/json' --data-raw '{}' | jq --arg user_id NEW_USER_ID '{selected_grantee_capabilities}|. * {"selected_grantee_capabilities": {("grn::::user:" + $user_id): "view"}}'

Then you can use as input for previous api /api/authz/shares/entities/grn::::stream:STREAM_ID

Now it’s works. Thank you very much!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.