To assign Organization to a User, please make a POST request to the following URL:
HTTP Method URL POST https://industrial.api.ubidots.com/api/v2.0/users/<user_key>/_/assign_organizations/
Parameter Type Use user_key String The id or username of the User, username should use the prefix ~
Parameter Type Use Description token String Authentication Authorization Token can optionally be sent as a query parameter.
Parameter Type Required? Default Value label String Yes N/A (Required) role String Yes N/A (Required) invitation Object No {}
📘 You can assign multiple Organizations to a single User in the same request separating all the key lists by a comma.
Parameter Required? Description X-Auth-Token Yes Authentication Token of accountContent-Type String (application/json) Content type of body
cURL (Request)
$ curl -X POST 'https://industrial.api.ubidots.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
}
}
]'
200 OK 400 Bad Request 401 Unauthorized
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"url": "https://industrial.api.ubidots.com/api/v2.0/organizations/62b4eb3519cd98007bf410bf",
"id": "62b4eb3519cd98007bf410bf",
"label": "my-third-customer",
"name": "Cliente1",
"createdAt": "2022-06-23T22:37:41.840643Z",
"role": {
"url": "https://industrial.api.ubidots.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."
}
Returns an Object with a results array containing the User assigned to the Organizations.