---
title: "POST /detector-models"
method: POST
path: "/detector-models"
---

# POST /detector-models

`POST /detector-models`

Creates a detector model.

## Request body

- object
  - `detectorModelName` string, required — The name of the detector model.
  - `detectorModelDefinition` object, required — Information that defines how a detector operates.
    - `states` State[] — Information about the states of the detector.
      - `stateName` string, required — The name of the state.
      - `onInput` object — When an input is received and the <code>condition</code> is TRUE, perform the specified <code>actions</code>.
        - `events` Event[] — Specifies the actions performed when the <code>condition</code> evaluates to TRUE.
          - `eventName` string, required — The name of the event.
          - `condition` string — Optional. The Boolean expression that, when TRUE, causes the <code>actions</code> to be performed. If not present, the actions are performed (=TRUE). If the expression result is not a Boolean value, the actions are not performed (=FALSE).
          - `actions` Action[] — The actions to be performed.
            - `setVariable` object — Sets a variable to a specified value.
              - …
            - `sns` object — Sends an Amazon SNS message.
              - …
            - `iotTopicPublish` object — Publishes an MQTT message with the given topic to the AWS IoT message broker.
              - …
            - `setTimer` object — Information needed to set the timer.
              - …
            - `clearTimer` object — Information needed to clear the timer.
              - …
            - `resetTimer` object — Information needed to reset the timer.
              - …
            - `lambda` object — Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action.
              - …
            - `iotEvents` object — Sends AWS IoT Events input, which passes information about the detector model instance and the event that triggered the action.
              - …
            - `sqs` object — Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue.
              - …
            - `firehose` object — Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream.
              - …
            - `dynamoDB` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. One column of the DynamoDB table receives all attribute-value pairs in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `dynamoDBv2` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. A separate column of the DynamoDB table receives one attribute-value pair in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `iotSiteWise` object — Sends information about the detector model instance and the event that triggered the action to an asset property in AWS IoT SiteWise .
              - …
        - `transitionEvents` TransitionEvent[] — Specifies the actions performed, and the next state entered, when a <code>condition</code> evaluates to TRUE.
          - `eventName` string, required — The name of the transition event.
          - `condition` string, required — Required. A Boolean expression that when TRUE causes the actions to be performed and the <code>nextState</code> to be entered.
          - `actions` Action[] — The actions to be performed.
            - `setVariable` object — Sets a variable to a specified value.
              - …
            - `sns` object — Sends an Amazon SNS message.
              - …
            - `iotTopicPublish` object — Publishes an MQTT message with the given topic to the AWS IoT message broker.
              - …
            - `setTimer` object — Information needed to set the timer.
              - …
            - `clearTimer` object — Information needed to clear the timer.
              - …
            - `resetTimer` object — Information needed to reset the timer.
              - …
            - `lambda` object — Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action.
              - …
            - `iotEvents` object — Sends AWS IoT Events input, which passes information about the detector model instance and the event that triggered the action.
              - …
            - `sqs` object — Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue.
              - …
            - `firehose` object — Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream.
              - …
            - `dynamoDB` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. One column of the DynamoDB table receives all attribute-value pairs in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `dynamoDBv2` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. A separate column of the DynamoDB table receives one attribute-value pair in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `iotSiteWise` object — Sends information about the detector model instance and the event that triggered the action to an asset property in AWS IoT SiteWise .
              - …
          - `nextState` string, required — The next state to enter.
      - `onEnter` object — When entering this state, perform these <code>actions</code> if the <code>condition</code> is TRUE.
        - `events` Event[] — Specifies the actions that are performed when the state is entered and the <code>condition</code> is <code>TRUE</code>.
          - `eventName` string, required — The name of the event.
          - `condition` string — Optional. The Boolean expression that, when TRUE, causes the <code>actions</code> to be performed. If not present, the actions are performed (=TRUE). If the expression result is not a Boolean value, the actions are not performed (=FALSE).
          - `actions` Action[] — The actions to be performed.
            - `setVariable` object — Sets a variable to a specified value.
              - …
            - `sns` object — Sends an Amazon SNS message.
              - …
            - `iotTopicPublish` object — Publishes an MQTT message with the given topic to the AWS IoT message broker.
              - …
            - `setTimer` object — Information needed to set the timer.
              - …
            - `clearTimer` object — Information needed to clear the timer.
              - …
            - `resetTimer` object — Information needed to reset the timer.
              - …
            - `lambda` object — Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action.
              - …
            - `iotEvents` object — Sends AWS IoT Events input, which passes information about the detector model instance and the event that triggered the action.
              - …
            - `sqs` object — Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue.
              - …
            - `firehose` object — Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream.
              - …
            - `dynamoDB` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. One column of the DynamoDB table receives all attribute-value pairs in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `dynamoDBv2` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. A separate column of the DynamoDB table receives one attribute-value pair in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `iotSiteWise` object — Sends information about the detector model instance and the event that triggered the action to an asset property in AWS IoT SiteWise .
              - …
      - `onExit` object — When exiting this state, perform these <code>actions</code> if the specified <code>condition</code> is <code>TRUE</code>.
        - `events` Event[] — Specifies the <code>actions</code> that are performed when the state is exited and the <code>condition</code> is <code>TRUE</code>.
          - `eventName` string, required — The name of the event.
          - `condition` string — Optional. The Boolean expression that, when TRUE, causes the <code>actions</code> to be performed. If not present, the actions are performed (=TRUE). If the expression result is not a Boolean value, the actions are not performed (=FALSE).
          - `actions` Action[] — The actions to be performed.
            - `setVariable` object — Sets a variable to a specified value.
              - …
            - `sns` object — Sends an Amazon SNS message.
              - …
            - `iotTopicPublish` object — Publishes an MQTT message with the given topic to the AWS IoT message broker.
              - …
            - `setTimer` object — Information needed to set the timer.
              - …
            - `clearTimer` object — Information needed to clear the timer.
              - …
            - `resetTimer` object — Information needed to reset the timer.
              - …
            - `lambda` object — Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action.
              - …
            - `iotEvents` object — Sends AWS IoT Events input, which passes information about the detector model instance and the event that triggered the action.
              - …
            - `sqs` object — Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue.
              - …
            - `firehose` object — Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream.
              - …
            - `dynamoDB` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. One column of the DynamoDB table receives all attribute-value pairs in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `dynamoDBv2` object — Writes to the DynamoDB table that you created. The default action payload contains all attribute-value pairs that have the information about the detector model instance and the event that triggered the action. You can customize the <a href="https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html">payload</a>. A separate column of the DynamoDB table receives one attribute-value pair in the payload that you specify. For more information, see <a href="https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html">Actions</a> in <i>AWS IoT Events Developer Guide</i>.
              - …
            - `iotSiteWise` object — Sends information about the detector model instance and the event that triggered the action to an asset property in AWS IoT SiteWise .
              - …
    - `initialStateName` string — The state that is entered at the creation of each detector (instance).
  - `detectorModelDescription` string — A brief description of the detector model.
  - `key` string — The input attribute key used to identify a device or system to create a detector (an instance of the detector model) and then to route each input received to the appropriate detector (instance). This parameter uses a JSON-path expression in the message payload of each input to specify the attribute-value pair that is used to identify the device associated with the input.
  - `roleArn` string, required — The ARN of the role that grants permission to AWS IoT Events to perform its operations.
  - `tags` Tag[] — Metadata that can be used to manage the detector model.
    - `key` string, required — The tag's key.
    - `value` string, required — The tag's value.
  - `evaluationMethod` 'BATCH' | 'SERIAL' — Information about the order in which events are evaluated and how actions are executed.

## Response `200`

Success

- CreateDetectorModelResponse
  - `detectorModelConfiguration` object — Information about how the detector model is configured.
    - `detectorModelName` string — The name of the detector model.
    - `detectorModelVersion` string — The version of the detector model.
    - `detectorModelDescription` string — A brief description of the detector model.
    - `detectorModelArn` string — The ARN of the detector model.
    - `roleArn` string — The ARN of the role that grants permission to AWS IoT Events to perform its operations.
    - `creationTime` string, date-time — The time the detector model was created.
    - `lastUpdateTime` string, date-time — The time the detector model was last updated.
    - `status` 'ACTIVE' | 'ACTIVATING' | 'INACTIVE' | 'DEPRECATED' | 'DRAFT' | 'PAUSED' | 'FAILED' — The status of the detector model.
    - `key` string — <p>The value used to identify a detector instance. When a device or system sends input, a new detector instance with a unique key value is created. AWS IoT Events can continue to route input to its corresponding detector instance based on this identifying information. </p> <p>This parameter uses a JSON-path expression to select the attribute-value pair in the message payload that is used for identification. To route the message to the correct detector instance, the device must send a message payload that contains the same attribute-value.</p>
    - `evaluationMethod` 'BATCH' | 'SERIAL' — Information about the order in which events are evaluated and how actions are executed.

## Other responses

- `480` — InvalidRequestException
- `481` — ResourceInUseException
- `482` — ResourceAlreadyExistsException
- `483` — LimitExceededException
- `484` — ThrottlingException
- `485` — InternalFailureException
- `486` — ServiceUnavailableException

---

[API](https://skmtc.net/aws/apis/iotevents.md) · [All operations](https://skmtc.net/aws/apis/iotevents/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aws/iotevents/versions/d3ae7b052b1d/schema)
