Create & Update Actor
The Actor API allows for the creation and modification of actors within the system, such as customers or users. This API provides a flexible way to assign roles, update entity details, and manage user credentials automatically based on assigned roles. Below, you will find the necessary requests and parameters for creating and updating an actor efficiently.
Creating an Actor
The CreateActor API allows you to create a new actor, such as a customer or person, by sending a request with the necessary role assignments and field values.
Method: POST
URL: {host_url}/api/actors/Actor/CreateActor
Minimal Request
{
"modelType":"CreateActorCommand",
"modelUpdates":[
{
"modelType":"ChangePersonFieldsetUpdate",
"firstName":{
"value":"John"
},
"lastName":{
"value":"Smith"
}
}
],
"roleNames":[
"CustomerPerson",
"Person",
"Customer"
]
}
Role Assignment
- The
roleNamesfield is an array of role system names that will be assigned to the newly created actor. - The
roleIdsfield (if used) contains an array of role IDs.
Retrieving Role IDs
To retrieve role IDs dynamically, you can use RoleApiService:
getRoles(): Retrieves a list of roles, with optional filters based on request parameters (e.g., include/exclude specific role IDs).getRoleBySystemName(): Retrieves a role using its system name.
There is a hardcoded role system name, User, which determines whether a security user should be created. If the User role is included in the roleNames array, the system will automatically generate a security user.
- The new user will have the following properties:
- Name = First Name + Last Name
- Email = Same as provided in the request
- Password = Same as Email
Model Updates
- The
modelUpdatesfield contains additional attributes that can be set for the new actor, such as first name, birthdate, email, etc. - Model updates have the
ModelUpdatesuffix. - Properties using
IOptionaltype are not mandatory.
Updating an Actor
The UpdateActor API allows modifications to an existing actor's details, such as changing personal information.
- Method:
POST - URL:
{host_url}/api/actors/Actor/UpdateActor
Minimal Request
{
"modelType":"UpdateActorCommand",
"modelUpdates":[
{
"modelType":"ChangePersonFieldsetUpdate",
"firstName":{
"value":"John"
},
"lastName":{
"value":"Smith"
}
}
],
"entityId": your_actor_id
}
In update actor command ActorId need to be specified in property entityId and also should be presented set of model updates in which should be defined which exactly properties need to be updated.