Menu
AWS CodeBuild
API Reference (API Version 2016-10-06)

CreateWebhook

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

Important

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

Request Syntax

{ "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.

Note

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

projectName

The name of the build 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

Response Syntax

{ "webhook": { "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.

webhook

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

Type: Webhook object

Errors

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

InvalidInputException

The input value that was provided is not valid.

HTTP Status Code: 400

OAuthProviderException

There was a problem with the underlying OAuth provider.

HTTP Status Code: 400

ResourceAlreadyExistsException

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

HTTP Status Code: 400

ResourceNotFoundException

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: