CreateNotificationRule - AWS CodeStar Notifications

CreateNotificationRule

Creates a notification rule for a resource. The rule specifies the events you want notifications about and the targets (such as AWS Chatbot topics or AWS Chatbot clients configured for Slack) where you want to receive them.

Request Syntax

POST /createNotificationRule HTTP/1.1 Content-type: application/json { "ClientRequestToken": "string", "DetailType": "string", "EventTypeIds": [ "string" ], "Name": "string", "Resource": "string", "Status": "string", "Tags": { "string" : "string" }, "Targets": [ { "TargetAddress": "string", "TargetType": "string" } ] }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

ClientRequestToken

A unique, client-generated idempotency token that, when provided in a request, ensures the request cannot be repeated with a changed parameter. If a request with the same parameters is received and a token is included, the request returns information about the initial request that used that token.

Note

The AWS SDKs prepopulate client request tokens. If you are using an AWS SDK, an idempotency token is created for you.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: ^[\w:/-]+$

Required: No

DetailType

The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created.

Type: String

Valid Values: BASIC | FULL

Required: Yes

EventTypeIds

A list of event types associated with this notification rule. For a list of allowed events, see EventTypeSummary.

Type: Array of strings

Length Constraints: Minimum length of 1. Maximum length of 200.

Required: Yes

Name

The name for the notification rule. Notification rule names must be unique in your AWS account.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [A-Za-z0-9\-_ ]+$

Required: Yes

Resource

The Amazon Resource Name (ARN) of the resource to associate with the notification rule. Supported resources include pipelines in AWS CodePipeline, repositories in AWS CodeCommit, and build projects in AWS CodeBuild.

Type: String

Pattern: ^arn:aws[^:\s]*:[^:\s]*:[^:\s]*:[0-9]{12}:[^\s]+$

Required: Yes

Status

The status of the notification rule. The default value is ENABLED. If the status is set to DISABLED, notifications aren't sent for the notification rule.

Type: String

Valid Values: ENABLED | DISABLED

Required: No

Tags

A list of tags to apply to this notification rule. Key names cannot start with "aws".

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Key Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Value Length Constraints: Maximum length of 256.

Value Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Required: No

Targets

A list of Amazon Resource Names (ARNs) of Amazon Simple Notification Service topics and AWS Chatbot clients to associate with the notification rule.

Type: Array of Target objects

Array Members: Maximum number of 10 items.

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "Arn": "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.

Arn

The Amazon Resource Name (ARN) of the notification rule.

Type: String

Pattern: ^arn:aws[^:\s]*:codestar-notifications:[^:\s]+:\d{12}:notificationrule\/(.*\S)?$

Errors

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

AccessDeniedException

AWS CodeStar Notifications can't create the notification rule because you do not have sufficient permissions.

HTTP Status Code: 403

ConcurrentModificationException

AWS CodeStar Notifications can't complete the request because the resource is being modified by another process. Wait a few minutes and try again.

HTTP Status Code: 400

ConfigurationException

Some or all of the configuration is incomplete, missing, or not valid.

HTTP Status Code: 400

LimitExceededException

One of the AWS CodeStar Notifications limits has been exceeded. Limits apply to accounts, notification rules, notifications, resources, and targets. For more information, see Limits.

HTTP Status Code: 400

ResourceAlreadyExistsException

A resource with the same name or ID already exists. Notification rule names must be unique in your AWS account.

HTTP Status Code: 409

ValidationException

One or more parameter values are not valid.

HTTP Status Code: 400

See Also

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