Assign Organization to Users

This endpoint assigns Organizations to a specific User

Request

To assign Organization to a User, please make a POST request to the following URL:

HTTP MethodURL
POSThttps://nanoview-api.wellairsolutions.com/api/v2.0/users/<user_key>/_/assign_organizations/

Path Parameters

ParameterTypeUse
user_keyStringThe id or username of the User, username should use the prefix ~

Query Parameters

ParameterTypeUseDescription
tokenStringAuthenticationAuthorization Token can optionally be sent as a query parameter.
clearBooleanOptionalDefault false. When true, the User is removed from every Organization not included in the body, so the body becomes the User's complete list of Organizations.

Body Parameters

The body is an array with one object per Organization to assign.

ParameterTypeRequired?Default ValueDescription
idStringYes (or label)N/A (Required)The id of the Organization.
labelStringYes (or id)N/A (Required)The label of the Organization (without the ~ prefix).
roleStringYesN/A (Required)The label of the Role to give the User in that Organization.
invitationObjectNo{}Sends the User an invitation email to an App. See below.

If the User already belongs to one of the Organizations, its Role there is replaced by the one sent.

The invitation object accepts subject (required), message (required), ubiAppId (required, id of the App), expires (optional, days) and resetPassword (optional, default false). Only one invitation per request is allowed: if several items carry different invitations the request fails with 400.

📘

Pro Tip

You can assign multiple Organizations to a single User in the same request by sending one object per Organization in the array. To undo an assignment, use Remove Organizations from User.

Header

ParameterRequired?Description
X-Auth-TokenYesAuthentication Token of account
Content-TypeString (application/json)Content type of body
$ curl -X POST 'https://nanoview-api.wellairsolutions.com/api/v2.0/users/63d3f1247fefea000cd325af/_/assign_organizations/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '[
  {"label": "my-third-customer",
   "role": "viewer",
   "invitation": {
     "subject": "Welcome to app",
     "message": "Hello you are been invited",
     "ubiAppId": "6242336d32b3a5000aa394f2",
     "expires": 365,
     "resetPassword": false
   }    
  }  
]'
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "url": "https://nanoview-api.wellairsolutions.com/api/v2.0/organizations/62b4eb3519cd98007bf410bf",
      "id": "62b4eb3519cd98007bf410bf",
      "label": "my-third-customer",
      "name": "Cliente1",
      "createdAt": "2022-06-23T22:37:41.840643Z",
      "role": {
        "url": "https://nanoview-api.wellairsolutions.com/api/v2.0/roles/viewer",
        "label": "viewer",
        "name": "Viewer",
        "createdAt": "2022-06-02T13:06:50.616480Z"
      }
    }
  ]
}
{
    "code": 400001,
    "message": "Validation Error.",
    "detail": {
        ....
    }
}
{
    "code": 401001,
    "message": "Authentication credentials were not provided.",
    "detail": "Authentication credentials were not provided."
}

Response

Returns an Object with a results array containing all the Organizations the User is assigned to after the request, each with the User's role.