Amazon CloudWatch Events
API Reference (API Version 2015-10-07)


Adds the specified targets to the specified rule. Updates the targets if they are already associated with the role.

Targets are the resources that can be invoked when a rule is triggered. Example targets include AWS Lambda functions, Amazon Kinesis streams, and built-in targets. Note that creating rules with built-in targets is supported only in the AWS Management Console.

In order to be able to make API calls against the resources you own, Amazon CloudWatch Events needs the appropriate permissions. For AWS Lambda and Amazon SNS resources, CloudWatch Events relies on resource-based policies. For Amazon Kinesis streams, CloudWatch Events relies on IAM roles. For more information, see Authentication and Access Control in the Amazon CloudWatch Events User Guide.

Input and InputPath are mutually-exclusive and optional parameters of a target. When a rule is triggered due to a matched event, if for a target:

  • Neither Input nor InputPath is specified, then the entire event is passed to the target in JSON form.

  • InputPath is specified in the form of JSONPath (for example, $.detail), then only the part of the event specified in the path is passed to the target (for example, only the detail part of the event is passed).

  • Input is specified in the form of a valid JSON, then the matched event is overridden with this constant.

When you add targets to a rule, when the associated rule triggers, new or updated targets might not be immediately invoked. Please allow a short period of time for changes to take effect.

Request Syntax

   "Rule": "string",
   "Targets": [ 
         "Arn": "string",
         "Id": "string",
         "Input": "string",
         "InputPath": "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.


The name of the rule.

Type: String

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

Pattern: [\.\-_A-Za-z0-9]+

Required: Yes


The targets to update or add to the rule.

Type: array of Target objects

Required: Yes

Response Syntax

   "FailedEntries": [ 
         "ErrorCode": "string",
         "ErrorMessage": "string",
         "TargetId": "string"
   "FailedEntryCount": number

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.


The failed target entries.

Type: array of PutTargetsResultEntry objects


The number of failed entries.

Type: Integer


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


There is concurrent modification on a rule or target.

HTTP Status Code: 400


This exception occurs due to unexpected causes.

HTTP Status Code: 500


You tried to create more rules or add more targets to a rule than is allowed.

HTTP Status Code: 400


The rule does not exist.

HTTP Status Code: 400


Adds a target to a Lambda function with the ID "MyTargetId" to the rule named "test"

The following is an example of a PutTargets request.

Sample Request

Host: events.<region>.<domain>
x-amz-Date: <Date>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=content-type;date;host;user-agent;x-amz-date;x-amz-target;x-amzn-requestid, Signature=<Signature>
User-Agent: <UserAgentString>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Connection: Keep-Alive 
X-Amz-Target: AWSEvents.PutTargets

    "Rule": "test", 
    "Targets": [
            "Id": "MyTargetId", 
            "Arn": "arn:aws:lambda:us-east-1:123456789012:function:MyFunction" 

Sample Response

HTTP/1.1 200 OK
x-amzn-RequestId: <RequestId>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Date: <Date>

    "FailedEntries": [],
    "FailedEntryCount": 0