Update UserId

Introduction

This operation is used to change/update user id with the new user id. This operation requires an old user id, new user id, is guest (To determine whether the user is guest or registered). This operation update user id of existing user id. 

The user of your e-commerce website can be registered or a guest user. If the user is not registered with your website, it will be treated as a guest user. 

Both users will have a unique id. The guest user will have a temporary id. 

If the guest user customizes the product and adds it to the cart, Artifi will maintain its record as a guest user. 

When the guest user checksout the product, your website will ask the user to register with your website. The user will register, and you will create a unique id of the user and at that time. 

Now you will need to replace the old id of the user with a newly created id in Artifi. To do this, you will need to call the "UpdateUserId" method. 

Use Cases 

This API is used when a guest user on an e-commerce website completes the registration process and is assigned a permanent user ID. During the guest session, all activities such as product customization and cart additions are associated with a temporary guest user ID. Once the user registers, the system needs to update and replace the temporary guest user ID with the newly created registered user ID in Artifi. 

The UpdateUserId API ensures that all previously associated data (such as designs, cart items, and user activities) are seamlessly transferred and mapped to the new registered user ID without any data loss. 

API Details 

Endpoint 

PUT /api/4/User/UpdateUserId 

--header 'webApiClientKey: c961461a-b287-448c-b9ea-e1162bd80b8e' \ 

--header 'websiteId: 156' 

Parameters 
Header Validation 

Header Name 

Type 

Required 

Description 

websiteId 

int 

Yes 

Unique identifier of the website. 

webApiClientKey 

string 

Yes 

API client key used for authentication. 

Query Parameters 

Name 

Type 

Required 

Default 

Description 

newUserId 

string 

Yes 

 

The new user identifier 

oldUserId 

string 

Yes 

 

The current / old user identifier 

isGuest 

bool 

No 

false 

Indicates if the user is a guest 

Success  Responses 

{ 

    "Response": "Success", 

    "Message": "User id updated successfully.", 

    "Data": null, 

    "ErrorCode": "" 

} 

Error Code List (Click Here) 

Q&A  

1. What is the purpose of the UpdateUserId API? 

Answer: 
The UpdateUserId API is used to update or replace an existing user ID with a new user ID in the system. It is typically used when a guest user registers and needs their temporary ID to be replaced with a permanent registered user ID. 

2. When should I use the UpdateUserId API? 

Answer: 
This API should be used when a guest user completes registration on your website. At that point, their temporary guest user ID must be replaced with the newly created registered user ID in Artifi. 

3. What is the difference between a guest user and a registered user? 

Answer: 
A guest user is a temporary user who has not registered on the website and is assigned a temporary user ID. A registered user has completed the registration process and is assigned a permanent unique user ID. 

4. What parameters are required to call the UpdateUserId API? 

Answer: 
The required parameters are: 

  • newUserId (string): The new user ID to be assigned  
  • oldUserId (string): The existing user ID that needs to be updated  
  • websiteId (int): Identifier of the website required in headers  
  • webApiClientKey (string): API key for authentication required in headers  

Optional parameter: 

  • isGuest (bool): Indicates whether the user is a guest (default is false)  

 

6. What happens if I pass an invalid oldUserId? 

Answer: 
If an invalid or non-existent oldUserId is provided, the API will return an error response indicating that the user ID is invalid, along with an appropriate error code. 

{ 
    "Response": "Error", 
    "Message": "Invalid old User Id.", 
    "Data": null, 
    "ErrorCode": "232" 
} 

7. Is the isGuest parameter mandatory? 

Answer: 
No, the isGuest parameter is optional. If not provided, it defaults to false, meaning the system will treat the user as a registered user. 

8. What is the success response of the UpdateUserId API? 

Answer: 
On successful execution, the API returns the following response: 

{ 
    "Response": "Success", 
    "Message": "User id updated successfully.", 
    "Data": null, 
    "ErrorCode": "" 
} 

9. Does this API modify any existing user data apart from the user ID? 

Answer: 
No, this API only updates the User ID. All associated user data (such as designs, cart items, etc.) remains unchanged and is simply mapped to the new user ID. 

10. Can this API be used for registered users as well? 

Answer: 
Yes, the API can be used for both guest and registered users. However, it is most used during the transition from a guest user to a registered user. 

11. Is authentication required to call this API? 

Answer: 
Yes, authentication is required using the webApiClientKey along with the websiteId to validate and authorize the request. 

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.