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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Cloud Functions
  • Comparison with other Yandex Cloud services
    • Overview
    • Managing dependencies
    • Request handler
    • Logging
    • Handling errors
    • Using the SDK
  • Tools
  • Pricing policy
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Developing in Bash
  2. Request handler

Handler script for Bash function request

Written by
Yandex Cloud
Updated at February 10, 2023

A request handler is a script that runs to handle each Bash function call. When creating a function version, you should specify the entry point: the name of a file with an extension (for example, handler.sh).

With the stdin standard input stream, the body of a request in JSON format.

The service information is specified in the script using environment variables:

  • REQUEST_ID: ID of the request being handled.
  • FUNCTION_NAME: Function ID.
  • FUNCTION_VERSION: Function version ID.

When handled, the function returns the contents of the stdout standard output stream in JSON format.

ExamplesExamples

The following function outputs the request structure and environment variables to both the execution log and function response:

#!/bin/bash
set -e

RESPONSE=$(cat | jq -sc '.[0] // {}' | jq -c '{statusCode:200, body:{env:env, request:.}}')
echo $RESPONSE >&2
echo $RESPONSE | jq -c '.body |= tostring' # make sure 'body' is a string, not a json node

Was the article helpful?

Previous
Managing dependencies
Next
Logging
Yandex project
© 2025 Yandex.Cloud LLC