---
title: Set User Roles
slug: api-documentation/set-user-roles
docTags: 
createdAt: 2026-08-27T16:18:26.773Z
---

{
  "id": "6Q_BcCSm0w7wYvo8QSREM",
  "type": "api-oas-v2",
  "data": {
    "method": "PUT",
    "url": "https://api.upstartcommerce.com/v1/user/{userId}/user-roles",
    "servers": [
      {
        "url": "https://api.upstartcommerce.com/v1/user/{userId}/user-roles"
      }
    ],
    "name": "Set User Roles",
    "description": "<p>This endpoint sets the roles associated with the user to the provided values.</p>\n<p>Required permissions:</p>\n<ul>\n<li><code>user.user-role.update</code></li>\n</ul>\n<p>Authorized system roles:</p>\n<ul>\n<li><code>system.admin</code></li>\n<li><code>user.mgmt</code></li>\n</ul>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "userId",
          "type": "string",
          "description": "This is the path parameter indicating the user to be interacted with."
        }
      ],
      "headerParameters": [
        {
          "kind": "required",
          "name": "x-upstart-tenant",
          "type": "string",
          "description": "Tenant identifier associated with the site this call is for."
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "example": "{\"tenant-name-1\":{\"roleIds\":[\"catalog.mgmt\"],\"sites\":{\"example-site-name-1\":{\"roleIds\":[\"order.mgmt\"]},\"example-site-name-2\":{\"roleIds\":[\"order.mgmt\"]}}},\"tenant-name-2\":{\"roleIds\":[\"user.mgmt\"],\"sites\":{\"example-site-name-1\":{\"roleIds\":[]},\"example-site-name-2\":{\"roleIds\":[\"inventory.mgmt\"]}}}}",
          "description": "This contains the set of roles to assign to the user.",
          "customType": "UserRoles",
          "schema": [],
          "modelRef": "#/components/schemas/UserRoles",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "NoChannelPortalAccess",
          "name": "NoChannelPortalAccess",
          "kind": "optional",
          "type": "http",
          "description": "<p>(DEPRECATED) This authentication is required for clients to interact with any of the management APIs. Similar to 'LoggedIn', it indicates that the user has actually logged into the system, but in this case with a management role.</p>",
          "scheme": "bearer"
        },
        {
          "id": "SessionIdAccess",
          "name": "X-Upstart-Session-Id",
          "kind": "optional",
          "type": "apiKey",
          "description": "<p>Session based authorization. This authentication is required for clients to interact with any of the management APIs. Similar to ''LoggedIn'', it indicates that the user has actually logged into the system, but in this case with a management role.</p>",
          "in": "header"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "Response indicating that this processed correctly",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "400",
        "description": "The request contained information that the server was unable to process. Appropriate errors are provided in the response body.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "Details of a request that failed validation.",
            "customType": "ValidationErrorResponse",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "array",
                "description": "",
                "example": "",
                "itemType": "string",
                "customType": "string[]",
                "itemExample": "",
                "itemDefault": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/ValidationErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "The provided credentials were not valid for this endpoint. It may be that they are expired or that the user's roles are insufficient.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>Credentials are missing, expired or insufficient (HTTP 401).</p>",
            "customType": "UnauthorizedError",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/UnauthorizedError",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "403",
        "description": "<p>An update to this resource requires the if-match and if-unmodified-since headers to be sent in order to process the request.</p>",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>The request is understood but refused (HTTP 403).</p>",
            "customType": "ForbiddenError",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/ForbiddenError",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "The requested resource was not found in the NoChannel system.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>The addressed resource does not exist (HTTP 404).</p>",
            "customType": "NotFoundError",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/NotFoundError",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "409",
        "description": "The request conflicts with the current state of the resource.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>The request conflicts with existing state (HTTP 409).</p>",
            "customType": "ConflictError",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/ConflictError",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "500",
        "description": "Internal server error. The server encountered an unexpected condition that prevented it from fulfilling the request.",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>The request failed for an unexpected reason (HTTP 500).</p>",
            "customType": "InternalServerError",
            "schema": [
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "code",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "detail",
                "kind": "required",
                "type": "string",
                "description": ""
              },
              {
                "name": "reason",
                "kind": "optional",
                "type": "string",
                "description": ""
              }
            ],
            "modelRef": "#/components/schemas/InternalServerError",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "6VCSrSl4QXZ_d-NnXIzwc",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request PUT \\\n     --url https://api.upstartcommerce.com/v1/user/{userId}/user-roles \\\n     --header 'accept: application/json' \\\n     --header 'x-upstart-tenant: string'"
        },
        {
          "id": "lxYDS6cjGfy_vxQUscQOI",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"x-upstart-tenant\", \"string\");\n\nvar requestOptions = {\n   method: 'PUT',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.upstartcommerce.com/v1/user/{userId}/user-roles\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "1mZ0xThkKnuagmD1vJPf1",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.upstartcommerce.com/v1/user/{userId}/user-roles\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Put.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"x-upstart-tenant\"] = \"string\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "8pdjpJUItU7fQ3TrGvwXp",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"https://api.upstartcommerce.com/v1/user/{userId}/user-roles\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'x-upstart-tenant': 'string'\n}\n\nresponse = requests.request(\"PUT\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "6VCSrSl4QXZ_d-NnXIzwc"
    },
    "results": {
      "languages": [
        {
          "id": "cYFbGBz9y8JvfUU0WYLEB",
          "language": "200",
          "code": "// Response indicating that this processed correctly\n"
        },
        {
          "id": "Llx_8bq3Yz-aYDCyj_K-O",
          "language": "400",
          "code": "// The request contained information that the server was unable to process. Appropriate errors are provided in the response body.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": [\n    \"\"\n  ],\n  \"reason\": \"\"\n}"
        },
        {
          "id": "QPwPtgTr7ZsZkMUFN5612",
          "language": "401",
          "code": "// The provided credentials were not valid for this endpoint. It may be that they are expired or that the user's roles are insufficient.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        },
        {
          "id": "jwYdtbaaDUQVgcEQG5Cud",
          "language": "403",
          "code": "// An update to this resource requires the if-match and if-unmodified-since headers to be sent in order to process the request.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        },
        {
          "id": "EMoTXR6h437VWuHlzMg9H",
          "language": "404",
          "code": "// The requested resource was not found in the NoChannel system.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        },
        {
          "id": "RFx3izQBurazwnKwcMDl-",
          "language": "409",
          "code": "// The request conflicts with the current state of the resource.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        },
        {
          "id": "N41nPyR-_iEvSj2T7m3Qr",
          "language": "500",
          "code": "// Internal server error. The server encountered an unexpected condition that prevented it from fulfilling the request.\n{\n  \"name\": \"\",\n  \"code\": \"\",\n  \"detail\": \"\",\n  \"reason\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "cYFbGBz9y8JvfUU0WYLEB"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}