:doc:`ApiGatewayV2 <../../apigatewayv2>` / Client / create_routing_rule

*******************
create_routing_rule
*******************



.. py:method:: ApiGatewayV2.Client.create_routing_rule(**kwargs)

  

  Creates a RoutingRule.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/apigatewayv2-2018-11-29/CreateRoutingRule>`_  


  **Request Syntax**
  ::

    response = client.create_routing_rule(
        Actions=[
            {
                'InvokeApi': {
                    'ApiId': 'string',
                    'Stage': 'string',
                    'StripBasePath': True|False
                }
            },
        ],
        Conditions=[
            {
                'MatchBasePaths': {
                    'AnyOf': [
                        'string',
                    ]
                },
                'MatchHeaders': {
                    'AnyOf': [
                        {
                            'Header': 'string',
                            'ValueGlob': 'string'
                        },
                    ]
                }
            },
        ],
        DomainName='string',
        DomainNameId='string',
        Priority=123
    )
    
  :type Actions: list
  :param Actions: **[REQUIRED]** 

    Represents a routing rule action. The only supported action is invokeApi.

    

  
    - *(dict) --* 

      The routing rule action.

      

    
      - **InvokeApi** *(dict) --* **[REQUIRED]** 

        Represents an InvokeApi action.

        

      
        - **ApiId** *(string) --* **[REQUIRED]** 

          The identifier.

          

        
        - **Stage** *(string) --* **[REQUIRED]** 

          A string with a length between [1-128].

          

        
        - **StripBasePath** *(boolean) --* 

          The strip base path setting.

          

        
      
    

  :type Conditions: list
  :param Conditions: **[REQUIRED]** 

    Represents a condition. Conditions can contain up to two matchHeaders conditions and one matchBasePaths conditions. API Gateway evaluates header conditions and base path conditions together. You can only use AND between header and base path conditions.

    

  
    - *(dict) --* 

      Represents a routing rule condition.

      

    
      - **MatchBasePaths** *(dict) --* 

        The base path to be matched.

        

      
        - **AnyOf** *(list) --* **[REQUIRED]** The string of the case sensitive base path to be matched.

        
          - *(string) --* 

            After evaluating a selection expression, the result is compared against one or more selection keys to find a matching key. See `Selection Expressions <https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions>`__ for a list of expressions and each expression's associated selection key type.

            

          
      
      
      - **MatchHeaders** *(dict) --* 

        The headers to be matched.

        

      
        - **AnyOf** *(list) --* **[REQUIRED]** 

          The header name and header value glob to be matched. The matchHeaders condition is matched if any of the header name and header value globs are matched.

          

        
          - *(dict) --* 

            Represents a MatchHeaderValue.

            

          
            - **Header** *(string) --* **[REQUIRED]** 

              After evaluating a selection expression, the result is compared against one or more selection keys to find a matching key. See `Selection Expressions <https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions>`__ for a list of expressions and each expression's associated selection key type.

              

            
            - **ValueGlob** *(string) --* **[REQUIRED]** 

              An expression used to extract information at runtime. See `Selection Expressions <https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions>`__ for more information.

              

            
          
      
      
    

  :type DomainName: string
  :param DomainName: **[REQUIRED]** 

    The domain name.

    

  
  :type DomainNameId: string
  :param DomainNameId: 

    The domain name ID.

    

  
  :type Priority: integer
  :param Priority: **[REQUIRED]** Represents the priority of the routing rule.

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'Actions': [
              {
                  'InvokeApi': {
                      'ApiId': 'string',
                      'Stage': 'string',
                      'StripBasePath': True|False
                  }
              },
          ],
          'Conditions': [
              {
                  'MatchBasePaths': {
                      'AnyOf': [
                          'string',
                      ]
                  },
                  'MatchHeaders': {
                      'AnyOf': [
                          {
                              'Header': 'string',
                              'ValueGlob': 'string'
                          },
                      ]
                  }
              },
          ],
          'Priority': 123,
          'RoutingRuleArn': 'string',
          'RoutingRuleId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 

      The request has succeeded and has resulted in the creation of a resource.

      
      

      - **Actions** *(list) --* 

        Represents a routing rule action. The only supported action is invokeApi.

        
        

        - *(dict) --* 

          The routing rule action.

          
          

          - **InvokeApi** *(dict) --* 

            Represents an InvokeApi action.

            
            

            - **ApiId** *(string) --* 

              The identifier.

              
            

            - **Stage** *(string) --* 

              A string with a length between [1-128].

              
            

            - **StripBasePath** *(boolean) --* 

              The strip base path setting.

              
        
      
    
      

      - **Conditions** *(list) --* 

        Represents a condition. Conditions can contain up to two matchHeaders conditions and one matchBasePaths conditions. API Gateway evaluates header conditions and base path conditions together. You can only use AND between header and base path conditions.

        
        

        - *(dict) --* 

          Represents a routing rule condition.

          
          

          - **MatchBasePaths** *(dict) --* 

            The base path to be matched.

            
            

            - **AnyOf** *(list) --* The string of the case sensitive base path to be matched.
              

              - *(string) --* 

                After evaluating a selection expression, the result is compared against one or more selection keys to find a matching key. See `Selection Expressions <https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions>`__ for a list of expressions and each expression's associated selection key type.

                
          
        
          

          - **MatchHeaders** *(dict) --* 

            The headers to be matched.

            
            

            - **AnyOf** *(list) --* 

              The header name and header value glob to be matched. The matchHeaders condition is matched if any of the header name and header value globs are matched.

              
              

              - *(dict) --* 

                Represents a MatchHeaderValue.

                
                

                - **Header** *(string) --* 

                  After evaluating a selection expression, the result is compared against one or more selection keys to find a matching key. See `Selection Expressions <https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions>`__ for a list of expressions and each expression's associated selection key type.

                  
                

                - **ValueGlob** *(string) --* 

                  An expression used to extract information at runtime. See `Selection Expressions <https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-apikey-selection-expressions>`__ for more information.

                  
            
          
        
      
    
      

      - **Priority** *(integer) --* 

        Represents the priority of the routing rule.

        
      

      - **RoutingRuleArn** *(string) --* 

        The ARN of the domain name.

        
      

      - **RoutingRuleId** *(string) --* 

        The routing rule ID.

        
  
  **Exceptions**
  
  *   :py:class:`ApiGatewayV2.Client.exceptions.NotFoundException`

  
  *   :py:class:`ApiGatewayV2.Client.exceptions.TooManyRequestsException`

  
  *   :py:class:`ApiGatewayV2.Client.exceptions.BadRequestException`

  
  *   :py:class:`ApiGatewayV2.Client.exceptions.ConflictException`

  