CreateThingTypeCommand

Creates a new thing type. If this call is made multiple times using the same thing type name and configuration, the call will succeed. If this call is made with the same thing type name but different configuration a ResourceAlreadyExistsException is thrown.

Requires permission to access the CreateThingType  action.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { IoTClient, CreateThingTypeCommand } from "@aws-sdk/client-iot"; // ES Modules import
// const { IoTClient, CreateThingTypeCommand } = require("@aws-sdk/client-iot"); // CommonJS import
const client = new IoTClient(config);
const input = { // CreateThingTypeRequest
  thingTypeName: "STRING_VALUE", // required
  thingTypeProperties: { // ThingTypeProperties
    thingTypeDescription: "STRING_VALUE",
    searchableAttributes: [ // SearchableAttributes
      "STRING_VALUE",
    ],
    mqtt5Configuration: { // Mqtt5Configuration
      propagatingAttributes: [ // PropagatingAttributeList
        { // PropagatingAttribute
          userPropertyKey: "STRING_VALUE",
          thingAttribute: "STRING_VALUE",
          connectionAttribute: "STRING_VALUE",
        },
      ],
    },
  },
  tags: [ // TagList
    { // Tag
      Key: "STRING_VALUE", // required
      Value: "STRING_VALUE",
    },
  ],
};
const command = new CreateThingTypeCommand(input);
const response = await client.send(command);
// { // CreateThingTypeResponse
//   thingTypeName: "STRING_VALUE",
//   thingTypeArn: "STRING_VALUE",
//   thingTypeId: "STRING_VALUE",
// };

CreateThingTypeCommand Input

See CreateThingTypeCommandInput for more details

Parameter
Type
Description
thingTypeName
Required
string | undefined

The name of the thing type.

tags
Tag[] | undefined

Metadata which can be used to manage the thing type.

thingTypeProperties
ThingTypeProperties | undefined

The ThingTypeProperties for the thing type to create. It contains information about the new thing type including a description, and a list of searchable thing attribute names.

CreateThingTypeCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
thingTypeArn
string | undefined

The Amazon Resource Name (ARN) of the thing type.

thingTypeId
string | undefined

The thing type ID.

thingTypeName
string | undefined

The name of the thing type.

Throws

Name
Fault
Details
InternalFailureException
server

An unexpected error has occurred.

InvalidRequestException
client

The request is not valid.

ResourceAlreadyExistsException
client

The resource already exists.

ServiceUnavailableException
server

The service is temporarily unavailable.

ThrottlingException
client

The rate exceeds the limit.

UnauthorizedException
client

You are not authorized to perform this operation.

IoTServiceException
Base exception class for all service exceptions from IoT service.