fbpx
POSThttps://api.spotinst.io/events/subscription?accountId={ACCOUNT_ID}

Create a notification for your resources

URL Parameters

Parameter Type Description
ACCOUNT_ID String

Your Spotinst accountId associated with your token

Example: act-123abc
Request

Headers
{
    "Authorization": "Bearer ${token}",
    "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "subscription": {
    "resourceId": "",
    "protocol": "aws-sns",
    "endpoint": "SNS_TOPIC_ARN",
    "eventType": "AWS_EC2_INSTANCE_TERMINATE"
  }
}

Body Attributes


Attribute Type Description
resourceId * String

Spotinst Resource id(Elastigroup ID)

Example: sig-12345
protocol * String

The protocol to send the notification. Valid values: http https email email-json aws-sns

endpoint * String

The endpoint the notification will be sent to. url in case of http/https, email address in case of email/email-json and sns-topic-arn in case of aws-sns

eventType * enum: Enumeration

The event to send the notification when triggered. Valid value: AWS_EC2_INSTANCE_TERMINATE, AWS_EC2_INSTANCE_TERMINATED, AWS_EC2_INSTANCE_LAUNCH, AWS_EC2_CANT_SPIN_OD, AWS_EC2_INSTANCE_UNHEALTHY_IN_ELB, GROUP_ROLL_FAILED, GROUP_ROLL_FINISHED, CANT_SCALE_UP_GROUP_MAX_CAPACITY, GROUP_UPDATED, AWS_EMR_PROVISION_TIMEOUT

eventFormat String

The format of the notification content (JSON Format - Key+Value). Supported variables : %instance-id%, %event%, %resource-id%, %resource-name%

Example: {"event": "%event%", "resourceId": "%resource-id%", "resourceName": "%resource-name%", "myCustomKey": "My content is set here" }
Default: {"event": "<event>", "instanceId": "<instance-id>", "resourceId": "<resource-id>", "resourceName": "<resource-name>" }
Response - 200

Headers
{
    "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "request": {
    "id": "7d54311a-f011-448e-998b-31b75f274428",
    "url": "/events/subscription",
    "method": "POST",
    "timestamp": "2015-08-04T12:31:26.567Z"
  },
  "response": {
    "status": {
      "code": 200,
      "message": "OK"
    },
    "kind": "spotinst:subscription",
    "items": [
      {
        "id": "sis-d2109541",
        "resourceId": "sig-5cf38a24",
        "protocol": "http",
        "endpoint": "http://localhost:5000",
        "eventType": "AWS_EC2_INSTANCE_TERMINIATE",
        "updatedAt": "2015-08-04T12:31:26.000Z",
        "createdAt": "2015-08-04T12:31:26.000Z"
      }
    ],
    "count": 1
  }
}