An action is one step of a job: send an email, call an API, create a record, loop over records. Actions run in position order, and one nested in a Loop or a condition branch names it as its parent. Each action’s template fields can read $event, $runData (earlier actions’ results, by name), $customData, $siteData, $query, $hook and $batch.
Actions
The steps a job runs, in order: create, change and move them, and read them back. Condition branches are actions too.
About actions
List a job’s actions#
/cdna-api/hooks/actions/{hook.id}
Lists a job’s actions, nested ones included, with parent naming the Loop or branch an action sits in.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
hook.idpathrequired- integer
- The job id.
propertiesquery- selector
- The fields and relations to return, such as
{id,name,type,position,parent}. filtersquery- name=value
- Any stored field, or a relation with a dot, such as
type=SendMailAction. 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/actions/2?limit=2&properties={id,name,type,position,parent} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"totalCount": 2,
"data": [
{
"id": 1,
"name": "HttpRequest-1",
"type": "HttpRequestAction",
"position": 1,
"parent": null
},
{
"id": 2,
"name": "HttpRequest-2",
"type": "HttpRequestAction",
"position": 2,
"parent": null
}
]
}Show an action#
/cdna-api/hooks/action/{id}
Reads one action, or one condition branch, by its id.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The action id.
propertiesquery- selector
- The fields and relations to return, such as
{id,name,type,position}.
Without properties, an HTTP request action comes back with the headers and body it sends, and those usually hold an API key or a token. Select the fields you need, and treat a full response as a secret.
Example
GET /cdna-api/hooks/action/1?properties={id,name,type,position} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"data": {
"id": 1,
"name": "HttpRequest-1",
"type": "HttpRequestAction",
"position": 1
}
}Create an action#
/cdna-api/hooks/action/{type}/{hook.id}
Adds an action at the top level of a job. The path names its type.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Returns
- The new action under its type, such as
data.sendMailAction, and amessage.
Parameters
typepathrequired- string
- The kind of action:
CreateFileAction,CreateRecordAction,DeleteRecordAction,HttpRequestAction,HttpResponseAction,Loop,MergeFilesAction,MergeToPDFAction,RenderTemplateAction,RetrieveRecordsAction,SendMailAction,StopAction,TriggerHookActionorUpdateRecordAction. Conditions have their own routes. 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.
namebody- string
- Letters, digits,
_and-only; anything else is a 422. Later actions read this action’s result by it. positionbody- number
- The order among its siblings.
(the type’s fields)body- Each type has its own, such as
to,subjectandtemplateCodeforSendMailAction; the Job action reference lists them.
Fields rendered as templates, such as createData, updateData, eventData and an HTTP response’s body, are Smarty on a Smarty site, where { starts a tag. JSON typed into them must be wrapped in {literal}…{/literal}, or the action fails when the job runs, not when it is saved.
Example
POST /cdna-api/hooks/action/SendMailAction/12 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"name": "notify-the-team",
"position": 1,
"from": "noreply@example.com",
"replyTo": "team@example.com",
"to": "team@example.com",
"subject": "A job ran",
"templateCode": "Job {$hook->getName()} ran at {$batch->getCreated()|date_format}."
}Learn more
Create an action inside another#
/cdna-api/hooks/action/{type}/{hook.id}/{parent.id}
Adds an action inside a Loop or a condition branch instead of at the top level.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Returns
- The new action under its type, such as
data.sendMailAction, and amessage.
Parameters
typepathrequired- string
- The kind of action:
CreateFileAction,CreateRecordAction,DeleteRecordAction,HttpRequestAction,HttpResponseAction,Loop,MergeFilesAction,MergeToPDFAction,RenderTemplateAction,RetrieveRecordsAction,SendMailAction,StopAction,TriggerHookActionorUpdateRecordAction. Conditions have their own routes. hook.idpathrequired- integer
- The job id.
parent.idpathrequired- integer
- The Loop or condition branch to nest it in.
retrieveUnpublishedquery- 1
- Needed while the job is unpublished, unless the admin shows unpublished records: without it the job is not found.
namebody- string
- Letters, digits,
_and-only; anything else is a 422. Later actions read this action’s result by it. positionbody- number
- The order among its siblings.
(the type’s fields)body- Each type has its own, such as
to,subjectandtemplateCodeforSendMailAction; the Job action reference lists them.
Fields rendered as templates, such as createData, updateData, eventData and an HTTP response’s body, are Smarty on a Smarty site, where { starts a tag. JSON typed into them must be wrapped in {literal}…{/literal}, or the action fails when the job runs, not when it is saved.
Example
POST /cdna-api/hooks/action/SendMailAction/12/9 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"name": "notify-each-owner",
"position": 1,
"from": "noreply@example.com",
"replyTo": "team@example.com",
"to": "team@example.com",
"subject": "A job ran",
"templateCode": "Job {$hook->getName()} ran at {$batch->getCreated()|date_format}."
}Edit an action#
/cdna-api/hooks/action/{id}
Changes an action, or a condition branch, which has no edit route of its own. Fields left out keep their values. On a branch, name, parent and position are ignored.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Returns
- The saved action under
data.action, and amessage.
Parameters
idpathrequired- integer
- The action id.
(the type’s fields)body- The fields to change, as for Create an action.
Fields rendered as templates, such as createData, updateData, eventData and an HTTP response’s body, are Smarty on a Smarty site, where { starts a tag. JSON typed into them must be wrapped in {literal}…{/literal}, or the action fails when the job runs, not when it is saved.
Example
PUT /cdna-api/hooks/action/31 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"subject": "The job ran again"
}Move an action#
/cdna-api/hooks/move-action/{id}
Moves an action into a Loop or a branch, out to the top level, or to another position.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The action id.
parentbody- integer
- The Loop or branch to move it into;
nulllifts it to the top level. positionbody- number
- Its position among its new siblings.
Example
PUT /cdna-api/hooks/move-action/31 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"parent": 9,
"position": 1
}Delete an action#
/cdna-api/hooks/action/{id}
Deletes an action, or a condition branch.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The action id.
Example
DELETE /cdna-api/hooks/action/31 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/jsonDelete several actions#
/cdna-api/hooks/actions
Deletes up to 50 actions at once, their ids in ids. If any id names nothing, nothing is deleted and the answer is 404.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idsbodyrequired- list
- The ids of the actions, at most 50.
Example
DELETE /cdna-api/hooks/actions HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"ids": [
21,
22
]
}