CreateWebhook - AWS CodeBuild


For an existing AWS CodeBuild build project that has its source code stored in a GitHub or Bitbucket repository, enables AWS CodeBuild to start rebuilding the source code every time a code change is pushed to the repository.


If you enable webhooks for an AWS CodeBuild project, and the project is used as a build step in CodePipeline, then two identical builds are created for each commit. One build is triggered through webhooks, and one through CodePipeline. Because billing is on a per-build basis, you are billed for both builds. Therefore, if you are using CodePipeline, we recommend that you disable webhooks in AWS CodeBuild. In the AWS CodeBuild console, clear the Webhook box. For more information, see step 5 in Change a Build Project's Settings.

Request Syntax

{ "branchFilter": "string", "buildType": "string", "filterGroups": [ [ { "excludeMatchedPattern": boolean, "pattern": "string", "type": "string" } ] ], "projectName": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.


In the following list, the required parameters are described first.


The name of the AWS CodeBuild project.

Type: String

Length Constraints: Minimum length of 2. Maximum length of 255.

Pattern: [A-Za-z0-9][A-Za-z0-9\-_]{1,254}

Required: Yes


A regular expression used to determine which repository branches are built when a webhook is triggered. If the name of a branch matches the regular expression, then it is built. If branchFilter is empty, then all branches are built.


It is recommended that you use filterGroups instead of branchFilter.

Type: String

Required: No


Specifies the type of build this webhook will trigger.

Type: String


Required: No


An array of arrays of WebhookFilter objects used to determine which webhooks are triggered. At least one WebhookFilter in the array must specify EVENT as its type.

For a build to be triggered, at least one filter group in the filterGroups array must pass. For a filter group to pass, each of its filters must pass.

Type: Array of arrays of WebhookFilter objects

Required: No

Response Syntax

{ "webhook": { "branchFilter": "string", "buildType": "string", "filterGroups": [ [ { "excludeMatchedPattern": boolean, "pattern": "string", "type": "string" } ] ], "lastModifiedSecret": number, "payloadUrl": "string", "secret": "string", "url": "string" } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.


Information about a webhook that connects repository events to a build project in AWS CodeBuild.

Type: Webhook object


For information about the errors that are common to all actions, see Common Errors.


The input value that was provided is not valid.

HTTP Status Code: 400


There was a problem with the underlying OAuth provider.

HTTP Status Code: 400


The specified AWS resource cannot be created, because an AWS resource with the same settings already exists.

HTTP Status Code: 400


The specified AWS resource cannot be found.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: