Amazon API Gateway REST API Reference

authorizer:create

Creates an Authorizer resource.

HTTP Request

POST /restapis/<restapi_id>/authorizers

Request Body

{
  "name" : "String",
  "type" : "String",
  "providerARNs" : [ "String" ],
  "authType" : "String",
  "authorizerUri" : "String",
  "authorizerCredentials" : "String",
  "identitySource" : "String",
  "identityValidationExpression" : "String",
  "authorizerResultTtlInSeconds" : "Integer"
}

Request Body Fields

The request accepts the following fields in JSON format.

  • name
  • [Required] The name of the authorizer.

  • type
  • [Required] The type of the authorizer.

  • providerARNs
  • A list of the Cognito Your User Pool authorizer's provider ARNs.

  • authType
  • Optional customer-defined field, used in Swagger imports/exports. Has no functional impact.

  • authorizerUri
  • [Required] Specifies the authorizer's Uniform Resource Identifier (URI).

  • authorizerCredentials
  • Specifies the credentials required for the authorizer, if any.

  • identitySource
  • [Required] The source of the identity in an incoming request.

  • identityValidationExpression
  • A validation expression for the incoming identity.

  • authorizerResultTtlInSeconds
  • The TTL of cached authorizer results.

Response

Authorizer

Remarks

Example: Create a custom authorizer

Request

POST /restapis/mxsmn867vb/authorizers HTTP/1.1
Content-Type: application/json
Host: apigateway.us-east-1.amazonaws.com
X-Amz-Date: 20170223T232342Z
Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20170223/us-east-1/apigateway/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature={sig4_hash}

{
"authType": "custom",
"authorizerResultTtlInSeconds": 300,
"authorizerCredentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole",
"authorizerUri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:myApiAuthroizer/invocations",
"identitySource": "method.request.header.CustAuth",
"name": "my-other-cust-auth",
"type": "TOKEN"
}
Response

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

{
"_links": {
  "curies": {
    "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-authorizer-{rel}.html&quot;,
    "name": "authorizer",
    "templated": true
  },
  "self": {
    "href": "/restapis/mxsmn867vb/authorizers/4unj71"
  },
  "authorizer:delete": {
    "href": "/restapis/mxsmn867vb/authorizers/4unj71"
  },
  "authorizer:update": {
    "href": "/restapis/mxsmn867vb/authorizers/4unj71"
  }
},
"authType": "custom",
"authorizerCredentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole",
"authorizerResultTtlInSeconds": 300,
"authorizerUri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789012:function:myApiAuthroizer/invocations",
"id": "4unj71",
"identitySource": "method.request.header.CustAuth",
"name": "my-other-cust-auth",
"type": "TOKEN"
}

See Also

AWS CLI