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
Copied!
Downloaded!
{
    "Authorization": "Bearer ${token}",
    "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "subscription": {
    "resourceId": "YOUR_ELASTIGROUP_ID || YOUR_OCEAN_ID || YOUR_MANAGED_INSTANCE_ID",
    "protocol": "aws-sns || email || email-json || web ",
    "endpoint": "YOUR@EMAIL.COM || https://YOUR_ENDPOINT.COM || SNS_TOPIC_ARN",
    "eventType": "AWS_EC2_INSTANCE_TERMINATE || AZURE_VM_TERMINATE"
  }
}

Body Attributes


Attribute Type Description
resourceId * String

Spotinst Resource ID (Elastigroup, Ocean or Managed Instance ID)

Example: sig-12345
protocol * String

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

The following values are deprecated: http https
You can use the generic web protocol instead.
aws-sns is only supported with AWS provider

endpoint * String

The endpoint the notification will be sent to. url in case of http/https/web, 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 values: AWS_EC2_INSTANCE_TERMINATE, AWS_EC2_INSTANCE_TERMINATED, AWS_EC2_INSTANCE_LAUNCH, AWS_EC2_INSTANCE_READY_SIGNAL_TIMEOUT, SIGNAL_TIMEOUT_SHUTDOWN_SCRIPT,
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,
GROUP_BEANSTALK_INIT_READY,
AZURE_VM_TERMINATED,
AZURE_VM_TERMINATE,
AWS_EC2_MANAGED_INSTANCE_PAUSING,
AWS_EC2_MANAGED_INSTANCE_RESUMING,
AWS_EC2_MANAGED_INSTANCE_RECYCLING,
AWS_EC2_MANAGED_INSTANCE_DELETING

Ocean Events: CLUSTER_ROLL_FINISHED,
CLUSTER_ROLL_FAILED,
OCEAN_CANT_SCALE_UP_MAX_RESOURCES,
OCEAN_LAUNCH_SPEC_CANT_SCALE_UP_MAX_INSTANCES

eventFormat String

The format of the notification content (JSON Format - Key+Value). Valid Values : %instance-id%, %event%, %resource-id%, %resource-name%, %subnet-id%, %availability-zone%, %reason%,%private-ip%,%launchspec-id%

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 - Elastigroup Resource Subscription

Headers
Copied!
Downloaded!
{
    "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
  }
}
Response - 200 - Ocean Resource Subscription

Headers
Copied!
Downloaded!
{
    "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "request": {
    "id": "7d54311a-f011-448e-998b-31b75f274428",
    "url": "/events/subscription",
    "method": "POST",
    "timestamp": "2019-08-04T12:31:26.567Z"
  },
  "response": {
    "status": {
      "code": 200,
      "message": "OK"
    },
    "kind": "spotinst:subscription",
    "items": [
      {
        "id": "sis-f87696c0",
        "resourceId": "o-1a2vccb7",
        "protocol": "email",
        "endpoint": "jon.doe@spotinst.com",
        "eventType": "CLUSTER_ROLL_FINISHED",
        "updatedAt": "2020-01-12T14:19:10.000Z",
        "createdAt": "2020-01-12T14:19:10.000Z",
        "eventFormat": {
          "event": "%event%",
          "resourceId": "%resource-id%",
          "resourceName": "%resource-name%",
          "launchSpecId": "%launchspec-id%",
          "instanceId": "%instance-id%"
        }
      }
    ],
    "count": 1
  }
}