Amazon API Gateway REST API Reference


Creates a new Model for this API.

HTTP Request

POST /restapis/<restapi_id>/models

Request Body

  "name" : "String",
  "description" : "String",
  "schema" : "String",
  "contentType" : "String"

Request Body Fields

The request accepts the following fields in JSON format.

  • name
  • The name of the model.

  • description
  • The description of the model.

  • schema
  • The schema for the model. For application/json models, this should be JSON-schema draft v4 model.

  • contentType
  • The content-type for the model.




You must create a model and use it for a method response before generating an API's SDK.

Example: Create a model


POST /restapis/uojnr9hd57/models HTTP/1.1
Content-Type: application/json
X-Amz-Date: 20160614T173659Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20160614/us-east-1/apigateway/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature={sig4_hash}

  "name" : "CalcOutput",
  "description" : "Calc output model",
  "schema" : "{\n\t\"title\": \"Calc output\",\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"a\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"b\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"op\": {\n\t\t\t\"description\": \"operation of +, -, * or /\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"c\": {\n\t\t    \"type\": \"number\"\n\t\t}\n\t},\n\t\"required\": [\"a\", \"b\", \"op\"]\n}\n",
  "contentType" : "application/json"

The successful response returns a 201 Created status code and a payload similar to the following:

  "_links": {
    "curies": {
      "href": "{rel}.html&quot;,
      "name": "model",
      "templated": true
    "self": {
      "href": "/restapis/uojnr9hd57/models/CalcOutput?flatten=false"
    "model:create": {
      "href": "/restapis/uojnr9hd57/models"
    "model:delete": {
      "href": "/restapis/uojnr9hd57/models/CalcOutput"
    "model:generate-template": {
      "href": "/restapis/uojnr9hd57/models/CalcOutput/default_template"
    "model:update": {
      "href": "/restapis/uojnr9hd57/models/CalcOutput"
  "contentType": "application/json",
  "description": "Calc output model",
  "id": "mzy1a0",
  "name": "CalcOutput",
  "schema": "{\n\t\"title\": \"Calc output\",\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"a\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"b\": {\n\t\t\t\"type\": \"number\"\n\t\t},\n\t\t\"op\": {\n\t\t\t\"description\": \"operation of +, -, * or /\",\n\t\t\t\"type\": \"string\"\n\t\t},\n\t\t\"c\": {\n\t\t    \"type\": \"number\"\n\t\t}\n\t},\n\t\"required\": [\"a\", \"b\", \"op\"]\n}\n"

This model can be referenced by its name in the responseModels property of a MethodResponse resource. Similarly, you can use this to create an input model that can be referenced in the Method's requestModels property.

See Also

AWS CLI, Method, MethodResponse