Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex API Gateway
  • Getting started
    • Resource relationships
    • Networking
      • Overview
        • Static response
        • Access over HTTP
        • Cloud Functions
        • Serverless Containers
        • Smart Web Security
        • Object Storage
        • DataSphere
        • Data Streams
        • Message Queue
        • Managed Service for YDB
      • Greedy parameters
      • Generic HTTP method
      • Authorization using a Cloud Functions function
      • Authorization using a JWT
      • WebSocket protocol support
      • Data validation
      • CORS
      • Specification parameterization
      • Canary release
      • Request rate limit
      • Response code replacement
      • Transformation of response and request bodies
    • Quotas and limits
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Supported parameters
  • Extension specification
  • Request structure for v0.1
  • Request structure for v1.0
  • Use cases
  1. Concepts
  2. Specification extensions
  3. Integration options
  4. Cloud Functions

x-yc-apigateway-integration:cloud_functions extension

Written by
Yandex Cloud
Updated at April 24, 2025
  • Supported parameters
  • Extension specification
  • Request structure for v0.1
  • Request structure for v1.0
  • Use cases

The x-yc-apigateway-integration:cloud_functions extension invokes the relevant function. As its input, the function accepts the HTTP request data and values of the properties listed in the specification. As the output, it returns the result of function execution to the client.

You can add an extension to a specification using the specification constructor.

Supported parametersSupported parameters

The table below lists the parameters specific to API Gateway API gateways. You can find the description of other parameters in the OpenAPI 3.0 specification.

Parameter Type Description
function_id string Function ID.
tag string This is an optional parameter. It specifies the tag of the function version. The default value is $latest.
The parameters are subsituted into tag.
service_account_id string ID of the service account used for authorization when accessing the function. Invoking a function requires a service account with the functions.functionInvoker role or higher for that function. If you omit the parameter, the service_account_id top-level parameter value will be used. If the top-level parameter is also missing, the function is invoked without authorization.
payload_format_version string Function call format version. It can be either 0.1 or 1.0. 0.1 is the default version.
context object This is an optional parameter. It provides the operation context, i.e., an object in YAML or JSON format. It is provided to a function within a request in the requestContext.apiGateway.operationContext field. The parameters are subsituted into context.

Extension specificationExtension specification

Specification example:

/example/{ID}:
    get:
      summary: Get ID
      operationId: getID
      tags:
        - example
      parameters:
        - name: ID
          in: path
          description: Return ID
          required: true
          schema:
            type: string
      x-yc-apigateway-integration:
        type: cloud_functions
        function_id: b095c95icnvb********
        tag: "$latest"
        service_account_id: ajehfe56hhl********

Function example:

exports.handler= async function (data, context) {
    return {
        'statusCode': 200,
        'isBase64Encoded': false,
        'body': JSON.stringify({
            'petId': data.params.ID
        }),
    }
};

Request structure for v0.1Request structure for v0.1

The request JSON structure for version 0.1 replicates the structure of a request to a function with some additional fields:

{
    "url": <actual request path>,
    "path": <path matching specification request>,
    "httpMethod": <HTTP method name>,
    "headers": <dictionary with HTTP header string values>,
    "multiValueHeaders": <dictionary with lists of HTTP header values>,
    "queryStringParameters": <dictionary of queryString parameters>,
    "multiValueQueryStringParameters": <dictionary with lists of queryString parameter values>,
    "requestContext": <dictionary with request context>,
    "body": <request contents>,
    "isBase64Encoded": <true or false>,
    "pathParams": <dictionary of request path parameter values>,
    "params": <dictionary of request parameter values as described in the OpenAPI spec>,
    "multiValueParams": <dictionary with request parameter value lists as described in the OpenAPI spec>
}

Request structure for v1.0Request structure for v1.0

The request JSON structure for version 1.0 is compatible with the request format for AWS API Gateway version 1.0 with some additional fields:

{
    "version": <request format version>,
    "resource": <resource matching specification request>,
    "path": <actual request path>,
    "httpMethod": <HTTP method name>,
    "headers": <dictionary with HTTP header string values>,
    "multiValueHeaders": <dictionary with lists of HTTP header values>,
    "queryStringParameters": <dictionary of queryString parameters>,
    "multiValueQueryStringParameters": <dictionary with lists of queryString parameter values>,
    "requestContext": <dictionary with request context>,
    "pathParameters": <dictionary of request path parameter values>,
    "body": <request contents>,
    "isBase64Encoded": <true or false>,
    // additional fields:    
    "parameters": <dictionary of request parameter values as described in the OpenAPI spec>,
    "multiValueParameters": <dictionary with request parameter value lists as described in the OpenAPI spec>,
    "operationId": <operationId matching the request in the OpenAPI spec>
}

Structure of the requestContext element:

    {
        "identity": <a set of key:value pairs to authenticate the user>,
        "httpMethod": <DELETE, GET, HEAD, OPTIONS, PATCH, POST, or PUT>,
        "requestId": <request ID generated in the router>,
        "requestTime": <request time in CLF format>,
        "requestTimeEpoch": <request time in Unix format>,
        "authorizer": <dictionary with authorization context>,
        "apiGateway": <dictionary with specific data transmitted by API gateway during function invocation>,
        "connectionId": <web socket connection ID>",
        "connectedAt": <web socket connection time>,
        "eventType": <type of web socket event or operation: CONNECT, MESSAGE, DISCONNECT>,
        "messageId": <ID of the message received from the web socket>,
        "disconnectStatusCode": <web socket close code>,
        "disconnectReason": <text description of the reason the web socket was closed>
    }

Structure of the authorizer element:

    {
        "jwt": { // Field filled in by the API Gateway JWT authorizer. It contains the token data about the user and the user's permissions'
          "claims": <dictionary of JWT body fields>,
          "scopes": <list of JWT owner permissions>
        }
        // Other authorization context fields returned from the authorizer function
    }

Use casesUse cases

  • Developing a custom integration in API Gateway
  • Canary release of a Cloud Functions function
  • Developing a Telegram bot for text recognition in images, audio synthesis and recognition
  • Deploying a web application using the Java Servlet API

Was the article helpful?

Previous
Access over HTTP
Next
Serverless Containers
© 2025 Direct Cursus Technology L.L.C.