Skip to main content

Setup Organization

RBAC Structure

The current structure of RBAC is divided into orgs and owners. An org contains owners and owners have access to multiple bots, conversation logic, adapters, and other resources.

Setting up your Organization

Before you can start using these resources and creating new bots, you need to setup your org and owners.

note

The enpoints listed below assume that the base url is that of Auth service.

Creating an Organization With Super User

Everything comes under an organization in BharatSahAIyak. Below is a sample request for creating an organization and adding a default organization admin.

POST
/org Create an org and org admin.

Request Body

NameTypeRequiredDescription
orgNameStringYESName of the organization. (Only alphanumeric characters without spaces).
adminEmailStringYESEmail for the Super User (Org Admin).
adminNameStringYESName for the Super User (Org Admin).
adminNameStringYESPassword for the Super User (Org Admin).

Curl Request

curl --location 'AUTH_SERVICE_BASE_URL/org' \
--header 'Content-Type: application/json' \
--data-raw '{
"orgName": "MyOrg",
"adminEmail": "myOrg@organization.in",
"adminName": "My Org",
"adminPassword": "MyOrgPass"
}'

Response Body

{
"path": "/org",
"apiVersion": "v1",
"msgid": "00000000-0000-0000-0000-000000000000",
"result": {
"orgId": "00000000-0000-0000-0000-000000000000",
"ownerId": "00000000-0000-0000-0000-000000000000",
"name": "My Org",
"email": "myOrg@organization.in",
"role": "superAdmin"
},
"timestamp": "2024-04-05T08:05:23.592Z",
"method": "POST"
}

Login With Org Admin Creds

Once you have created your org and org admin, you can login with admin credentials to get admin JWT which can be used to read and write resources in the BharatSahAIyak system.

Below is the sample curl for logging in using credentials.

POST
/org/login Login using credentials.

Request Body

NameTypeRequiredDescription
emailStringYESEmail for a user.
passwordStringYESPassword for a user.

Curl Request

curl --location 'AUTH_SERVICE_BASE_URL/org/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "myOrg@organization.in",
"password": "MyOrgPass"
}'

Response Body

{
"path": "/org/login",
"apiVersion": "v1",
"msgid": "00000000-0000-0000-0000-000000000000",
"result": {
"token": "AUTH_TOKEN",
"ownerId": "00000000-0000-0000-0000-000000000000",
"orgId": "00000000-0000-0000-0000-000000000000",
"verified": true,
"role": "superAdmin"
},
"timestamp": "2024-04-04T05:40:55.073Z",
"method": "POST"
}

Creating Owners

Now that you have an admin AUTH_TOKEN you "can" start creating and using resources, although you "should" create individual owners instead of directly using your admin AUTH_TOKEN to restrict org-wide privilege.

Below is the curl request for creating an owner.

POST
/org/addOwner Create a new owner.

Headers

NameTypeRequiredDescription
AuthorizationStringYESAuthorization token for organization admin. You can get AUTH_TOKEN by logging in.

Request Body

NameTypeRequiredDescription
emailStringYESEmail for the owner.
nameStringYESName for the owner.
passwordStringYESPassword for the owner.

Curl Request

curl --location 'AUTH_SERVICE_BASE_URL/org/addOwner' \
--header 'Authorization: ADMIN_AUTH_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "Owner@organization.in",
"name": "Owner Name",
"password": "OwnerPass"
}'

Response Body

{
"path": "/org/addOwner",
"apiVersion": "v1",
"msgid": "00000000-0000-0000-0000-000000000000",
"result": {
"orgId": "00000000-0000-0000-0000-000000000000",
"ownerId": "00000000-0000-0000-0000-000000000000",
"name": "Owner Name",
"email": "Owner@organization.in",
"role": "owner"
},
"timestamp": "2024-04-05T08:38:32.187Z",
"method": "POST"
}
  • You can now use these owner credentials to login as explained here.

  • Now that you have an owner JWT you can start using it for managing resources. Take a look here for a guide on setting up a bot.

Validating a JWT

You can validate your JWT using the endpoint below.

POST
/org/validate Validate a JWT.

Headers

NameTypeRequiredDescription
AuthorizationStringYESAuthorization token for a user.

Curl Request

curl --location --request POST 'AUTH_SERVICE_BASE_URL/org/validate' \
--header 'Authorization: AUTH_TOKEN'

Response Body

{
"path": "/org/validate",
"apiVersion": "v1",
"msgid": "00000000-0000-0000-0000-000000000000",
"result": {
"id": "00000000-0000-0000-0000-000000000000",
"orgId": "00000000-0000-0000-0000-000000000000",
"role": "orgAdmin",
"verified": true
},
"timestamp": "2024-04-05T08:46:08.243Z",
"method": "POST"
}