Remove Organizations from User

This endpoint removes one or more Organizations from a specific User

Request

To remove one or more Organizations from a User, please make a POST request to the following URL:

HTTP MethodURL
POSThttps://industrial.api.ubidots.com/api/v2.0/users/<user_key>/_/remove_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.

Body Parameters

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

ParameterTypeRequired?Description
idStringYes (or label)The id of the Organization.
labelStringYes (or id)The label of the Organization (without the ~ prefix).
roleStringYesThe label of the Role the User currently has in that Organization, e.g. viewer.
🚧

The Role must match

An Organization is only removed when the role sent is the Role the User currently has in it. If the Role is different, that Organization is left unchanged and the request still returns 200. Use Get all Organizations of User to check the current Role first.

📘

Pro Tip

You can remove multiple Organizations from a single User in the same request by sending one object per Organization in the array.

Removing an Organization also removes any assignment the User had directly on its sub-Organizations.

Header

ParameterRequired?Description
X-Auth-TokenYesAuthentication Token of account
Content-TypeString (application/json)Content type of body
$ curl -X POST 'https://industrial.api.ubidots.com/api/v2.0/users/63d3f1247fefea000cd325af/_/remove_organizations/' \
 -H 'Content-Type: application/json' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
 -d '[
  {"label": "my-third-customer", "role": "viewer"}
]'
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "url": "https://industrial.api.ubidots.com/api/v2.0/organizations/6298b72cb8f9ee01abd67001",
      "id": "6298b72cb8f9ee01abd67001",
      "label": "my-first-customer",
      "name": "Cliente0",
      "createdAt": "2022-06-02T13:12:12.267973Z",
      "role": {
        "url": "https://industrial.api.ubidots.com/api/v2.0/roles/manager",
        "label": "manager",
        "name": "Manager",
        "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 the Organizations the User is still assigned to after the removal, each with the User's role.