Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Content Management API > Build trigger

Create build trigger

Body parameters

namestringRequired

Name of the build trigger

Example:"Custom build trigger"
adapterenumRequired

The type of build trigger

Example:"custom"
customOptional

adapter_settings must include the following properties: trigger_url, headers and payload. The custom adapter also supports CircleCI webhooks for backward compatibility.

netlifyOptional

adapter_settings must include the following properties: trigger_url, access_token, branch, site_id

vercelOptional

adapter_settings must include the following properties: project_id, token, branch, team_id, deploy_hook_url

gitlabOptional

adapter_settings must include the following properties: trigger_url, token, ref, build_parameters

frontend_urlstring, nullRequired

The public URL of the frontend.

Example:"https://www.mywebsite.com/"
adapter_settingsobjectRequired

Additional settings for the build trigger. The value depends on the adapter.

Example:{ trigger_url: "http://some-url.com/trigger", headers: { Authorization: "Bearer abc123" }, payload: { type: "build_request" }, }
autotrigger_on_scheduled_publicationsbooleanRequired

Wheter an automatic build request to webhook_url should be made on scheduled publications/unpublishings

webhook_tokenstringOptional

Unique token for the webhook (it's the same token present in webhook_url)

Example:"xA1239ajsk123"
enabledbooleanOptional

Whether the build trigger is enabled or not

indexing_enabledbooleanDeprecated

Wether Site Search is enabled or not. With Site Search, everytime the website is built, DatoCMS will respider it to get updated content

Site Search features have been detached from build triggers. This attribute has no effect anymore: we keep it present for retrocompatibility. If you're programmatically using this field, please get in touch with support@datocms.com

Returns

Returns a resource object of type build_trigger

Examples

import { buildClient } from "@datocms/cma-client-node";
async function run() {
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const buildTrigger = await client.buildTriggers.create({
name: "Custom build trigger",
adapter: "custom",
frontend_url: "https://www.mywebsite.com/",
adapter_settings: {
trigger_url: "http://some-url.com/trigger",
headers: { Authorization: "Bearer abc123" },
payload: { type: "build_request" },
},
autotrigger_on_scheduled_publications: true,
});
// Check the 'Returned output' tab for the result ☝️
console.log(buildTrigger);
}
run();
{
id: "1822",
name: "Custom build trigger",
adapter: "custom",
adapter_settings: {
trigger_url: "http://some-url.com/trigger",
headers: { Authorization: "Bearer abc123" },
payload: { type: "build_request" },
},
last_build_completed_at: "2017-03-30T09:29:14.872Z",
build_status: "success",
webhook_token: "xA1239ajsk123",
webhook_url: "https://webhooks.datocoms.com/xA1239ajsk123/deploy-results",
frontend_url: "https://www.mywebsite.com/",
enabled: true,
autotrigger_on_scheduled_publications: true,
}