November 23, 2017


Edit User.

Account master users and sub-users who have the User Manage permission in the SoftLayer customer portal
can update other user's information. Use editObject() if you wish to edit a single user account.
Users who do not have the User Manage permission can only update their own information.

Important manual Pages:

@Author: SoftLayer Technologies, Inc. <>
package main

import (

func main() {
	// SoftLayer API username and key
	username := "set me"
	apikey   := "set me"

	// The Id of user you want to delete
	userId := 6660647

	// Build the user structure with the new information about the user.
	userTemplate := datatypes.User_Customer {
		FirstName    : sl.String("firstname0A"),
		LastName     : sl.String("lastname0A"),
		Email        : sl.String("user0A_mail@softlayer.local"),
		Address1     : sl.String("Address 0A"),
		CompanyName  : sl.String("Some Company 0A"),
		City         : sl.String("Houston"),
		OfficePhone  : sl.String("4422335"),
		PostalCode   : sl.String("5500"),

	// Create SoftLayer API session
	sess := session.New(username, apikey)

	// Get SoftLayer_User_Customer service
	service := services.GetUserCustomerService(sess)

	// Update user account with the new information
  	result, err := service.Id(userId).EditObject(&userTemplate)
	if err != nil {
		fmt.Printf("\n Unable to edit selected user:\n - %s\n", err)

	// Print result
	fmt.Printf("\nUser edit: %t", result)
	fmt.Println("\nFollowing is the new user information")

	// Define object-mask used to retrieve specific data information about user
	mask := "id;username;firstName;lastName;email;address1;companyName;country;city;" +

	// Retrieve and check if new information was successfully changed
	user, err := service.Id(userId).Mask(mask).GetObject()
	if err != nil {
		fmt.Printf("\n Unable to retrieve selected user:\n - %s\n", err)

	// Following helps to print the result in json format.
	jsonFormat, jsonErr := json.MarshalIndent(user,"","     ")
	if jsonErr != nil {


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue