An entity event starts its job when a record of one type fires one event, optionally only for one record or the children of one parent. Entity events always queue the run; they never fire from command-line scripts.
Entity Events
The record events that start a job: a kind of record created, changed, deleted or completed.
About entity events
List a job’s entity events#
/cdna-api/hooks/entity-events/{hook.id}
Lists the entity events that start one job.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Model
- EntityEvent, in the Reference
Parameters
hook.idpathrequired- integer
- The job id.
propertiesquery- selector
- The fields and relations to return, such as
{id,entity,method,recordId,parentRecordId}. filtersquery- name=value
- Any stored field, or a relation with a dot, such as
method=UpdateRecord. Prefix the name with!,>,<,%or|. Use stored field names exactly as in the model, and comparetotalCountwith the unfiltered list's to confirm a filter applied. orderByquery- string
field:ASCorfield:DESC, comma-separated. Stored fields only.limitquery- integer
- Records per response: 100 when left out, at most 500. A larger value answers 400.
pagequery- integer
- The page to return, counting from 1.
offsetworks too.
Example
GET /cdna-api/hooks/entity-events/2?limit=2&properties={id,entity,method,recordId,parentRecordId} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"totalCount": 1,
"data": [
{
"id": 2,
"entity": "Documentation\\Entities\\Page",
"method": "UpdateRecord",
"recordId": null,
"parentRecordId": null
}
]
}Show an entity event#
/cdna-api/hooks/entity-event/{id}
Reads one entity event by its id.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Model
- EntityEvent, in the Reference
Parameters
idpathrequired- integer
- The entity event id.
propertiesquery- selector
- The fields and relations to return, such as
{id,entity,method,recordId,parentRecordId}.
Example
GET /cdna-api/hooks/entity-event/2?properties={id,entity,method,recordId,parentRecordId} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"data": {
"id": 2,
"entity": "Documentation\\Entities\\Page",
"method": "UpdateRecord",
"recordId": null,
"parentRecordId": null
}
}Create an entity event#
/cdna-api/hooks/entity-event/{hook.id}
Adds an entity event to a job. The example starts the job when a submission of form 7 is completed.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Returns
- The new entity event under
data.entityEvent, and amessage.
Parameters
hook.idpathrequired- integer
- The job id.
retrieveUnpublishedquery- 1
- Needed while the job is unpublished, unless the admin shows unpublished records: without it the job is not found.
entitybody- string
- The record class, such as
Blogs\Entities\Post. methodbody- string
- The event: one of the names List the events a record type fires returns, such as
CreateRecordorCompleted. recordIdbody- integer
- One record of that type; left out, any record.
parentRecordIdbody- integer
- The record’s parent, such as a form’s id for its submissions.
propertiesbody- string
- For
UpdateRecord: a selector of the fields to capture before the change, so the job can compare.
method is not checked when it is saved. A name the record type does not fire, such as create instead of CreateRecord, is stored and never starts the job. Take the value from List the events a record type fires.
Example
POST /cdna-api/hooks/entity-event/12 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"entity": "Forms\\Entities\\FormSubmission",
"method": "Completed",
"parentRecordId": 7
}Edit an entity event#
/cdna-api/hooks/entity-event/{id}
Changes an entity event. Fields left out keep their values.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Returns
- The saved entity event under
data.entityEvent, and amessage.
Parameters
idpathrequired- integer
- The entity event id.
methodbody- string
- The event: one of the names List the events a record type fires returns, such as
CreateRecordorCompleted.
method is not checked when it is saved. A name the record type does not fire, such as create instead of CreateRecord, is stored and never starts the job. Take the value from List the events a record type fires.
Example
PUT /cdna-api/hooks/entity-event/14 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"method": "UpdateRecord"
}Delete an entity event#
/cdna-api/hooks/entity-event/{id}
Deletes an entity event.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The entity event id.
Example
DELETE /cdna-api/hooks/entity-event/14 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json