---
title: Copy a role to a site
slug: api-documentation/copy-a-role-to-a-site
docTags: 
createdAt: 2026-08-27T17:06:32.549Z
---

{
  "id": "TJE3gku5Ur-xnLrNDYE-m",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://api.upstartcommerce.com/profile-permissions/roles/{roleId}/copy-to-site",
    "servers": [
      {
        "url": "https://api.upstartcommerce.com/profile-permissions/roles/{roleId}/copy-to-site",
        "description": "Production"
      }
    ],
    "name": "Copy a role to a site",
    "description": "<p>Creates a copy of any role (global or tenant) for a specific site.\nThe copied role will have all the same permissions as the original role.</p>\n<p><strong>Required Permission:</strong> <code>profile-permissions.roles.write</code></p>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "roleId",
          "type": "string",
          "description": "Source role identifier to copy"
        }
      ],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "<p>The target site for the copy, and optionally a new name.</p>",
          "customType": "CopyRoleToSiteRequest",
          "schema": [
            {
              "name": "siteId",
              "kind": "required",
              "type": "string",
              "description": "Target site ID to copy the role to"
            },
            {
              "name": "newName",
              "kind": "optional",
              "type": "string",
              "description": "<p>Optional new name for the copied role (uses original name if not specified)</p>",
              "minLength": 1,
              "maxLength": 100
            }
          ],
          "modelRef": "#/components/schemas/CopyRoleToSiteRequest",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "bearerAuth",
          "name": "bearerAuth",
          "kind": "optional",
          "type": "http",
          "description": "<p>JWT token from authentication service.</p>\n<p>The token contains:</p>\n<ul>\n<li>sub: User ID</li>\n<li>tenant: Tenant ID (used for all operations)</li>\n<li>roles: Array of role IDs</li>\n<li>type: \"management\" or \"consumer\"</li>\n</ul>\n<p>Alternatively, tenant can be specified via X-Tenant-Id header.</p>",
          "scheme": "bearer"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "Role copied successfully",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>A role definition - its scope (GLOBAL template, TENANT or SITE) and type (Management or Consumer) - without the permissions it grants.</p>",
            "customType": "Role",
            "schema": [
              {
                "name": "id",
                "kind": "required",
                "type": "string",
                "description": "Role identifier"
              },
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": "<p>Role name (unique within scope/tenant/site)</p>",
                "example": "operator"
              },
              {
                "name": "scope",
                "kind": "required",
                "type": "string<GLOBAL | TENANT | SITE>",
                "description": "<p>Role scope - GLOBAL for templates, TENANT for tenant-specific roles, SITE for site-specific roles</p>",
                "enum": [
                  "GLOBAL",
                  "TENANT",
                  "SITE"
                ]
              },
              {
                "name": "tenantId",
                "kind": "optional",
                "type": "string",
                "description": "<p>Tenant ID (required when scope is TENANT or SITE)</p>"
              },
              {
                "name": "siteId",
                "kind": "optional",
                "type": "string",
                "description": "<p>Site ID (required when scope is SITE)</p>"
              },
              {
                "name": "roleDescription",
                "kind": "optional",
                "type": "string",
                "description": "<p>Human-readable description</p>"
              },
              {
                "name": "roleType",
                "kind": "required",
                "type": "string<Management | Consumer>",
                "description": "<p>Role type - Management for admin users, Consumer for customers</p>",
                "enum": [
                  "Management",
                  "Consumer"
                ]
              },
              {
                "name": "createdAt",
                "kind": "required",
                "type": "string<date-time>",
                "description": "",
                "format": "date-time"
              },
              {
                "name": "updatedAt",
                "kind": "required",
                "type": "string<date-time>",
                "description": "",
                "format": "date-time"
              }
            ],
            "modelRef": "#/components/schemas/Role",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Invalid request",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>Error payload identifying the failure by error code and message, with optional detail.</p>",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "error",
                "kind": "required",
                "type": "string<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>",
                "description": "Error code",
                "example": "not_found",
                "enum": [
                  "bad_request",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "internal_error"
                ]
              },
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "<p>Human-readable error message</p>",
                "example": "Role not found"
              },
              {
                "name": "details",
                "kind": "optional",
                "type": "map",
                "description": "Additional error details",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "401",
        "description": "Missing or invalid authentication token",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>Error payload identifying the failure by error code and message, with optional detail.</p>",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "error",
                "kind": "required",
                "type": "string<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>",
                "description": "Error code",
                "example": "not_found",
                "enum": [
                  "bad_request",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "internal_error"
                ]
              },
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "<p>Human-readable error message</p>",
                "example": "Role not found"
              },
              {
                "name": "details",
                "kind": "optional",
                "type": "map",
                "description": "Additional error details",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "404",
        "description": "Role or site not found",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>Error payload identifying the failure by error code and message, with optional detail.</p>",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "error",
                "kind": "required",
                "type": "string<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>",
                "description": "Error code",
                "example": "not_found",
                "enum": [
                  "bad_request",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "internal_error"
                ]
              },
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "<p>Human-readable error message</p>",
                "example": "Role not found"
              },
              {
                "name": "details",
                "kind": "optional",
                "type": "map",
                "description": "Additional error details",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "409",
        "description": "Role with this name already exists at the site",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>Error payload identifying the failure by error code and message, with optional detail.</p>",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "error",
                "kind": "required",
                "type": "string<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>",
                "description": "Error code",
                "example": "not_found",
                "enum": [
                  "bad_request",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "internal_error"
                ]
              },
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "<p>Human-readable error message</p>",
                "example": "Role not found"
              },
              {
                "name": "details",
                "kind": "optional",
                "type": "map",
                "description": "Additional error details",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "500",
        "description": "Internal server error",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "<p>Error payload identifying the failure by error code and message, with optional detail.</p>",
            "customType": "ErrorResponse",
            "schema": [
              {
                "name": "error",
                "kind": "required",
                "type": "string<bad_request | unauthorized | forbidden | not_found | conflict | internal_error>",
                "description": "Error code",
                "example": "not_found",
                "enum": [
                  "bad_request",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "internal_error"
                ]
              },
              {
                "name": "message",
                "kind": "required",
                "type": "string",
                "description": "<p>Human-readable error message</p>",
                "example": "Role not found"
              },
              {
                "name": "details",
                "kind": "optional",
                "type": "map",
                "description": "Additional error details",
                "example": "",
                "customType": "map<string, string>",
                "schema": []
              }
            ],
            "modelRef": "#/components/schemas/ErrorResponse",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "uoykpewI8r_14HlFNsENy",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://api.upstartcommerce.com/profile-permissions/roles/{roleId}/copy-to-site \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"siteId\": \"\"\n     }'"
        },
        {
          "id": "GFucnzV1nirPJwGRymZYq",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"siteId\": \"\"\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.upstartcommerce.com/profile-permissions/roles/{roleId}/copy-to-site\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "fdZkbo-3CL43l1qyM2CZo",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.upstartcommerce.com/profile-permissions/roles/{roleId}/copy-to-site\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"siteId\": \"\"\n})\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "MctCmaZ2F-9gmZ0UcHfK1",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://api.upstartcommerce.com/profile-permissions/roles/{roleId}/copy-to-site\"\n\npayload = json.dumps({\n   \"siteId\": \"\"\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "uoykpewI8r_14HlFNsENy"
    },
    "results": {
      "languages": [
        {
          "id": "z2HmYhc1M0xFJ1mKz-h-i",
          "language": "201",
          "code": "// Role copied successfully\n{\n  \"id\": \"\",\n  \"name\": \"operator\",\n  \"scope\": \"\",\n  \"tenantId\": \"\",\n  \"siteId\": \"\",\n  \"roleDescription\": \"\",\n  \"roleType\": \"\",\n  \"createdAt\": \"\",\n  \"updatedAt\": \"\"\n}"
        },
        {
          "id": "4A7WpRXRW_qhWDAFSWnGN",
          "language": "400",
          "code": "// Invalid request\n{\n  \"error\": \"not_found\",\n  \"message\": \"Role not found\",\n  \"details\": \"\"\n}"
        },
        {
          "id": "jgn9Xsxvg2sNAjRo8WwY2",
          "language": "401",
          "code": "// Missing or invalid authentication token\n{\n  \"error\": \"not_found\",\n  \"message\": \"Role not found\",\n  \"details\": \"\"\n}"
        },
        {
          "id": "n3SXVV6HaswwpuDQaNGQh",
          "language": "404",
          "code": "// Role or site not found\n{\n  \"error\": \"not_found\",\n  \"message\": \"Role not found\",\n  \"details\": \"\"\n}"
        },
        {
          "id": "W6EhbY5067ii2sm0Krzi7",
          "language": "409",
          "code": "// Role with this name already exists at the site\n{\n  \"error\": \"not_found\",\n  \"message\": \"Role not found\",\n  \"details\": \"\"\n}"
        },
        {
          "id": "jyo9RB_P7j80vukmNs2Nc",
          "language": "500",
          "code": "// Internal server error\n{\n  \"error\": \"not_found\",\n  \"message\": \"Role not found\",\n  \"details\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "z2HmYhc1M0xFJ1mKz-h-i"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}