Home > OS >  Creating new roles Using Hasura meatadat API
Creating new roles Using Hasura meatadat API

Time:10-19

I am new to Hasura metadata API, Are there any REST API options to create roles via REST API. I am not asking about inherited roles. inherited roles don't meet my requirements.

CodePudding user response:

You can use HASURA Metadata API to create a Permission and Pass the new role.

For example, let's say you're going to create a role called "MODERATOR" and give insert permission to the "comments" table.

you can use the pg_insert_permission POST API with body:

{
"type": "pg_create_insert_permission",
"args": {
    "table": "comments",
    "source": "default",
    "role": "MODERATOR",
    "permission": {
        "check": {},
        "columns": ["comment"]
        }
    }
 }

This will create New Role "MODERATOR" in Hasura and also set the insert permission as well. Hope that answers your question.

  • Related