CreateModelCommand

Adds a new Model resource to an existing RestApi resource.

Example Syntax

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

import { APIGatewayClient, CreateModelCommand } from "@aws-sdk/client-api-gateway"; // ES Modules import
// const { APIGatewayClient, CreateModelCommand } = require("@aws-sdk/client-api-gateway"); // CommonJS import
const client = new APIGatewayClient(config);
const input = { // CreateModelRequest
  restApiId: "STRING_VALUE", // required
  name: "STRING_VALUE", // required
  description: "STRING_VALUE",
  schema: "STRING_VALUE",
  contentType: "STRING_VALUE", // required
};
const command = new CreateModelCommand(input);
const response = await client.send(command);
// { // Model
//   id: "STRING_VALUE",
//   name: "STRING_VALUE",
//   description: "STRING_VALUE",
//   schema: "STRING_VALUE",
//   contentType: "STRING_VALUE",
// };

CreateModelCommand Input

See CreateModelCommandInput for more details

Parameter
Type
Description
contentType
Required
string | undefined

The content-type for the model.

name
Required
string | undefined

The name of the model. Must be alphanumeric.

restApiId
Required
string | undefined

The RestApi identifier under which the Model will be created.

description
string | undefined

The description of the model.

schema
string | undefined

The schema for the model. For application/json models, this should be JSON schema draft 4 model. The maximum size of the model is 400 KB.

CreateModelCommand Output

See CreateModelCommandOutput for details

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

The content-type for the model.

description
string | undefined

The description of the model.

id
string | undefined

The identifier for the model resource.

name
string | undefined

The name of the model. Must be an alphanumeric string.

schema
string | undefined

The schema for the model. For application/json models, this should be JSON schema draft 4 model. Do not include "*/" characters in the description of any properties because such "*/" characters may be interpreted as the closing marker for comments in some languages, such as Java or JavaScript, causing the installation of your API's SDK generated by API Gateway to fail.

Throws

Name
Fault
Details
BadRequestException
client

The submitted request is not valid, for example, the input is incomplete or incorrect. See the accompanying error message for details.

ConflictException
client

The request configuration has conflicts. For details, see the accompanying error message.

LimitExceededException
client

The request exceeded the rate limit. Retry after the specified time period.

NotFoundException
client

The requested resource is not found. Make sure that the request URI is correct.

TooManyRequestsException
client

The request has reached its throttling limit. Retry after the specified time period.

UnauthorizedException
client

The request is denied because the caller has insufficient permissions.

APIGatewayServiceException
Base exception class for all service exceptions from APIGateway service.