Change a user's company role
PATCH/v1/users/:userId/company-role
This route allows you to promote or demote a user's company role.
Prerequisites:
- The caller must have the Company admin role.
- Machine tokens cannot call this route.
- You cannot change your own role.
- Both the caller and target must belong to the same company.
- The last company admin cannot be demoted.
To learn more about multiple organization membership, check out the documentation.
Request
Parameters (JSON)
{
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1
},
"in": "path",
"name": "userId",
"required": true,
"description": "The target user's ID, returned in the `id` field from [Get all users in your organization](https://docs.port.io/api-reference/get-all-users-in-your-organization/) or [Get a user](https://docs.port.io/api-reference/get-a-user/)."
}
]
}Request body schema (JSON)
{
"title": "Body",
"body": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"companyRole": {
"type": "string",
"enum": [
"ADMIN",
"MEMBER"
],
"description": "Use `ADMIN` to promote the user to company admin, or `MEMBER` to demote a company admin to member."
}
},
"required": [
"companyRole"
],
"additionalProperties": false
}
}
},
"required": true
}
}Responses
- 200
- 401
- 403
- 404
- 409
- 413
- 422
Default Response
Default Response
The caller does not have permission to perform this action
A resource with the provided identifier was not found
The request conflicts with the current state of the resource
Request body is too large (limit is 1MiB)
The json provided does not match the route's schema
Responses (JSON)
{
"responses": {
"200": {
"description": "Default Response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"ok": {
"type": "boolean"
}
}
}
}
}
},
"401": {
"description": "Default Response",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error"
],
"additionalProperties": false
}
}
}
},
"403": {
"description": "The caller does not have permission to perform this action",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error",
"message"
],
"additionalProperties": false,
"description": "The caller does not have permission to perform this action"
}
}
}
},
"404": {
"description": "A resource with the provided identifier was not found",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error",
"message"
],
"additionalProperties": false,
"description": "A resource with the provided identifier was not found"
}
}
}
},
"409": {
"description": "The request conflicts with the current state of the resource",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error",
"message"
],
"additionalProperties": false,
"description": "The request conflicts with the current state of the resource"
}
}
}
},
"413": {
"description": "Request body is too large (limit is 1MiB)",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error"
],
"additionalProperties": false,
"description": "Request body is too large (limit is 1MiB)"
}
}
}
},
"422": {
"description": "The json provided does not match the route's schema",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error",
"message"
],
"additionalProperties": false,
"description": "The json provided does not match the route's schema"
}
}
}
}
}
}