// Create the user structure.Useruser=newUser();user.setEmail(email-address);user.setDisplayName(display-name);// Create the assigned user role structure.AssignedUserRoleassignedUserRole=newAssignedUserRole();assignedUserRole.setAdvertiserId(advertiser-id);assignedUserRole.setUserRole("STANDARD");// Add assigned user role list to the user.user.setAssignedUserRoles(ImmutableList.of(assignedUserRole));// Configure the create request.Users.Createrequest=service.users().create(user);// Create the user.Userresponse=request.execute();// Display the user.System.out.printf("User %s was created with email %s.",response.getName(),response.getEmail());
Python
# Create a user object.user_obj={'email':email-address,'displayName':display-name,'assignedUserRoles':[{'advertiserId':advertiser-id,'userRole':'STANDARD'}]}# Build request.request=service.users().create(body=user_obj)# Execute request.response=request.execute()# Display the new user.print('User %s was created with email %s.'%(response['name'],response['email']))
PHP
// Create the user structure.$user = new Google_Service_DisplayVideo_User();$user->setEmail(email-address);$user->setDisplayName(display-name);// Create the assigned user role structure.$assignedUserRole = new Google_Service_DisplayVideo_AssignedUserRole();$assignedUserRole->setAdvertiserId(advertiser-id);$assignedUserRole->setUserRole('STANDARD');// Add assigned user role list to the user.$user->setAssignedUserRoles(array($assignedUserRole));// Call the API, creating the user with the assigned user role.$result = $this->service->users->create($user);// Display the user.printf( 'User %s was created with email %s.\n', $result['name'], $result['email']);
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eAdmins can create users with access to resources they manage, including sub-resources.\u003c/p\u003e\n"],["\u003cp\u003eNew users require a Google Account and at least one assigned user role for access.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003euser.create\u003c/code\u003e method enables user creation, potentially adding roles to existing, inaccessible Display & Video 360 users without error.\u003c/p\u003e\n"],["\u003cp\u003eCode samples in Java, Python, and PHP demonstrate creating a standard access user for an advertiser.\u003c/p\u003e\n"]]],["Users with the Admin role can create new users via the `user.create` method. A new user's email must have a corresponding Google Account and at least one assigned user role. The process involves creating a user object, assigning a user role (e.g., STANDARD), and then executing the creation request. If the email already belongs to a user, roles will be added to it. The examples provided show creating a user with standard access to an advertiser in Java, Python and PHP.\n"],null,["# Create a user\n\nIf assigned the [Admin](/display-video/api/reference/rest/current/users#UserRole.ENUM_VALUES.ADMIN) role for a resource, you can create a user\nwith access to that resource or those under it.\n\nUsers are created through the [`user.create`](/display-video/api/reference/rest/current/users/create) method.\n| **Note:** If you attempt to create a user with an email address associated with an existing Display \\& Video 360 user that you cannot access, no error will be returned. The new assigned user roles will be added to the existing user resource.\n\nA new user's email address must have a corresponding Google Account, which can\nbe [created for an existing email address](//accounts.google.com/signup/v2/webcreateaccount?flowName=GlifWebSignIn&flowEntry=SignUp). The user\nresource created must also include at least one assigned user role.\n\nHere's an example of how to create a new user with standard access to an\nadvertiser: \n\n### Java\n\n```java\n// Create the user structure.\nUser user = new User();\nuser.setEmail(email-address);\nuser.setDisplayName(display-name);\n\n// Create the assigned user role structure.\nAssignedUserRole assignedUserRole = new AssignedUserRole();\nassignedUserRole.setAdvertiserId(advertiser-id);\nassignedUserRole.setUserRole(\"STANDARD\");\n\n// Add assigned user role list to the user.\nuser.setAssignedUserRoles(ImmutableList.of(assignedUserRole));\n\n// Configure the create request.\nUsers.Create request = service.users().create(user);\n\n// Create the user.\nUser response = request.execute();\n\n// Display the user.\nSystem.out.printf(\"User %s was created with email %s.\",\n response.getName(),\n response.getEmail());\n```\n\n### Python\n\n```python\n# Create a user object.\nuser_obj = {\n 'email': email-address,\n 'displayName': display-name,\n 'assignedUserRoles': [\n {\n 'advertiserId': advertiser-id,\n 'userRole': 'STANDARD'\n }\n ]\n}\n\n# Build request.\nrequest = service.users().create(\n body=user_obj\n)\n\n# Execute request.\nresponse = request.execute()\n\n# Display the new user.\nprint('User %s was created with email %s.'\n % (response['name'], response['email']))\n```\n\n### PHP\n\n```php\n// Create the user structure.\n$user = new Google_Service_DisplayVideo_User();\n$user-\u003esetEmail(\u003cvar translate=\"no\"\u003eemail-address\u003c/var\u003e);\n$user-\u003esetDisplayName(\u003cvar translate=\"no\"\u003edisplay-name\u003c/var\u003e);\n\n// Create the assigned user role structure.\n$assignedUserRole = new Google_Service_DisplayVideo_AssignedUserRole();\n$assignedUserRole-\u003esetAdvertiserId(\u003cvar translate=\"no\"\u003eadvertiser-id\u003c/var\u003e);\n$assignedUserRole-\u003esetUserRole('STANDARD');\n\n// Add assigned user role list to the user.\n$user-\u003esetAssignedUserRoles(array($assignedUserRole));\n\n// Call the API, creating the user with the assigned user role.\n$result = $this-\u003eservice-\u003eusers-\u003ecreate($user);\n\n// Display the user.\nprintf(\n 'User %s was created with email %s.\\n',\n $result['name'],\n $result['email']\n);\n```"]]