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
    • Start testing with double trial credits
    • 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 Cloud Functions
  • Comparison with other Yandex Cloud services
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Tools
  • Pricing policy
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Using the invocation context
  • Authentication in the Yandex Cloud API
  • Getting the request body
  1. Developing in Node.js
  2. Invocation context

Node.js function invocation context

Written by
Yandex Cloud
Updated at October 18, 2023
  • Using the invocation context
    • Authentication in the Yandex Cloud API
    • Getting the request body

Invocation context is an object that is accepted by the request handler of a function in Node.js as the second argument.

The invocation context provides additional information about a Node.js function version properties:

  • functionName: The function ID.
  • functionVersion: The ID of the function version.
  • memoryLimitInMB: The amount of memory specified when creating the version, MB.
  • requestId: The ID of the request being handled.
  • token: Yandex Cloud API authentication parameters.

The context also contains the following helper methods:

  • getRemainingTimeInMillis(): Returns the time, in ms, remaining to complete the current request.
  • getPayload(): Returns the request body if HTTP integration. By default, HTTP integration is used for all functions invoked if no ?integration=raw parameter is specified.

Using the invocation contextUsing the invocation context

You can use the invocation context to authenticate in the Yandex Cloud API and manage the process of getting the HTTP request body (the body parameter).

Authentication in the Yandex Cloud APIAuthentication in the Yandex Cloud API

If a function has a service account specified, the token parameter contains information for authentication on behalf of this service account:

  • access_token: IAM token.
  • expires_in: Token lifetime in seconds.
  • token_type: Token type (Bearer).

You can also get this information using the metadata service. For more information, see Authentication from within a VM.

Getting the request bodyGetting the request body

getPayload() is a helper method that makes it easier to get the request body (the body parameter). Depending on the content of the request body and header, the function handles data using different methods:

  • If a JSON document is passed as the request body and the header is set to Content-Type: application/json, the function returns the result of executing the JSON.parse method over the data that is passed in the request body.
  • If form parameters are passed as the request body and the header is set to Content-Type: application/x-www-form-urlencoded, the function returns the result of executing the querystring.parse method: an object containing field keys and passed values.

Was the article helpful?

Previous
Request handler
Next
Logging
© 2025 Direct Cursus Technology L.L.C.