APIv4 Actions¶
With a few exceptions, most API Entities support a basic set of CRUD (create, read, update, delete) actions, along with some metadata actions to retrieve information about the structure of the entity.
API Explorer
The easiest way to see which actions are available for each entity is to browse the API Explorer, which shows all available entities, their actions, and the parameters for each action.
Most entities support the following actions:
Read Actions¶
-
getSearch for records using SQL-like parameters (
select,where,having,join,orderBy,limit). For most entities,getincludes advanced features such as joins. -
autocompleteUsed to populate EntityReference autocomplete results, this action calls
SearchDisplay::runwhich in turn calls thegetaction. -
exportAvailable only for Managed Entity types, outputs code which can be used to package and distribute a record in an extension.
Write Actions¶
-
createInsert a single new record into the database.
-
updateUpdate one or more existing records with new values. If an
idis not supplied, then query params are required to search for records to update. -
saveGiven an array of records, either
createorupdateeach one. By default the presence of aniddetermines whether an existing record will be updated. Thematchparam gives finer control over this, and lets you specify one or more fields; if a single existing record matches all of them, it will be updated instead of a new record created. For example you cansavean array of contacts and specify['external_id']as thematchparam, which will update contacts with matchingexternal_ids. -
deleteDelete one or more records based on query parameters. Some entities, including
Contact, implement "Soft Delete", in which case thedeleteaction's default behavior is to give records an intermediate "trashed" status. For these entities, setuseTrash = FALSEto delete records permanently. -
replaceReplace an existing set of records with a new or modified set of records. For example, replace a group of
Phonenumbers for a givenContact.
Warning
Replace includes an implicit delete action - use with care & test well before using in production.
revert
Available only for Managed Entity types, resets a record to its original packaged state.
Metadata Actions¶
-
checkAccessCheck if current user is authorized to perform a specified action on a given record.
-
getActionsReturns a list of actions avaiable for a given entity.
-
getFieldsFetch the list of fields supported by the entity, including custom fields. Optionally load the option-lists for fields.
Other Entity-Specific Actions¶
Some entities provide extra actions. For example, Afform::submit or SearchDisplay::run.
To discover all available actions for an entity, use the getActions API action.