Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Cloud Functions
  • Getting started
    • Overview
    • Creating and executing functions
    • Creating a timer
    • Creating a trigger for Message Queue
    • Creating a trigger for Object Storage
    • Creating a trigger for Container Registry
    • Creating a trigger for Cloud Logs
    • Creating a trigger for IoT Core
  • Step-by-step instructions
    • All instructions
    • Using functions to get an IAM token for a service account
    • Managing rights to access functions
    • Managing functions
      • Creating a function
      • Managing function versions
      • Working in the code editor
      • Invoking a function
      • Updating a function
      • Viewing monitoring charts
      • Viewing the execution log
      • Deleting a function
    • Managing triggers
      • Getting information about a trigger
      • Creating a timer
      • Creating a trigger for Message Queue
      • Creating a trigger for Object Storage
      • Creating a trigger for Container Registry
      • Creating a trigger for Cloud Logs
      • Creating a trigger for Yandex IoT Core
      • Updating a trigger
      • Deleting a trigger
  • Concepts
    • Overview
    • Function
    • Invoking a function
    • Runtime
      • Overview
      • Environment
      • Execution context
    • Builder
    • Trigger
      • Overview
      • Timer
      • Trigger for Message Queue
      • Trigger for Object Storage
      • Trigger for Container Registry
      • Trigger for Cloud Logs
      • Trigger for Yandex IoT Core
    • Dead Letter Queue
    • Log groups
    • Monitoring
    • Backups
    • Quotas and limits
  • Developing in Node.js
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Python
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Go
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in PHP
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
  • Developing in Bash
    • Overview
    • Request handler
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Java
    • Overview
    • Programming model
      • Overview
      • Function interface
      • YcFunction interface
      • HttpServlet class
      • Spring Boot
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in R
    • Overview
    • Programming model
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
  • Developing in C#
    • Overview
    • Programming model
      • Overview
      • Function interface
      • YcFunction interface
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Use cases
    • Creating skills for Alice
  • Pricing policy
  • Access management
  • API Functions reference
    • Authentication in the API
    • gRPC
      • Overview
      • FunctionService
      • OperationService
    • REST
      • Overview
      • Function
        • Overview
        • create
        • createVersion
        • delete
        • get
        • getVersion
        • getVersionByTag
        • list
        • listAccessBindings
        • listOperations
        • listRuntimes
        • listTagHistory
        • listVersions
        • removeTag
        • setAccessBindings
        • setTag
        • update
        • updateAccessBindings
  • API Triggers reference
    • Authentication in the API
    • gRPC
      • Overview
      • TriggerService
      • OperationService
    • REST
      • Overview
      • Trigger
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • pause
        • resume
        • update
  • Questions and answers
  1. API Triggers reference
  2. REST
  3. Trigger
  4. create

Method create

  • HTTP request
  • Body parameters
  • Response

Creates a trigger in the specified folder.

HTTP request

POST https://serverless-triggers.api.cloud.yandex.net/triggers/v1/triggers

Body parameters

{
  "folderId": "string",
  "name": "string",
  "description": "string",
  "labels": "object",
  "rule": {

    // `rule` includes only one of the fields `timer`, `messageQueue`, `iotMessage`, `objectStorage`, `containerRegistry`, `cloudLogs`
    "timer": {
      "cronExpression": "string",

      // `rule.timer` includes only one of the fields `invokeFunction`, `invokeFunctionWithRetry`
      "invokeFunction": {
        "functionId": "string",
        "functionTag": "string",
        "serviceAccountId": "string"
      },
      "invokeFunctionWithRetry": {
        "functionId": "string",
        "functionTag": "string",
        "serviceAccountId": "string",
        "retrySettings": {
          "retryAttempts": "string",
          "interval": "string"
        },
        "deadLetterQueue": {
          "queueId": "string",
          "serviceAccountId": "string"
        }
      },
      // end of the list of possible fields`rule.timer`

    },
    "messageQueue": {
      "queueId": "string",
      "serviceAccountId": "string",
      "batchSettings": {
        "size": "string",
        "cutoff": "string"
      },
      "visibilityTimeout": "string",
      "invokeFunction": {
        "functionId": "string",
        "functionTag": "string",
        "serviceAccountId": "string"
      }
    },
    "iotMessage": {
      "registryId": "string",
      "deviceId": "string",
      "mqttTopic": "string",
      "invokeFunction": {
        "functionId": "string",
        "functionTag": "string",
        "serviceAccountId": "string",
        "retrySettings": {
          "retryAttempts": "string",
          "interval": "string"
        },
        "deadLetterQueue": {
          "queueId": "string",
          "serviceAccountId": "string"
        }
      }
    },
    "objectStorage": {
      "eventType": [
        "string"
      ],
      "bucketId": "string",
      "prefix": "string",
      "suffix": "string",
      "invokeFunction": {
        "functionId": "string",
        "functionTag": "string",
        "serviceAccountId": "string",
        "retrySettings": {
          "retryAttempts": "string",
          "interval": "string"
        },
        "deadLetterQueue": {
          "queueId": "string",
          "serviceAccountId": "string"
        }
      }
    },
    "containerRegistry": {
      "eventType": [
        "string"
      ],
      "registryId": "string",
      "imageName": "string",
      "tag": "string",
      "invokeFunction": {
        "functionId": "string",
        "functionTag": "string",
        "serviceAccountId": "string",
        "retrySettings": {
          "retryAttempts": "string",
          "interval": "string"
        },
        "deadLetterQueue": {
          "queueId": "string",
          "serviceAccountId": "string"
        }
      }
    },
    "cloudLogs": {
      "logGroupId": [
        "string"
      ],
      "batchSettings": {
        "size": "string",
        "cutoff": "string"
      },
      "invokeFunction": {
        "functionId": "string",
        "functionTag": "string",
        "serviceAccountId": "string",
        "retrySettings": {
          "retryAttempts": "string",
          "interval": "string"
        },
        "deadLetterQueue": {
          "queueId": "string",
          "serviceAccountId": "string"
        }
      }
    },
    // end of the list of possible fields`rule`

  }
}
Field Description
folderId string

Required. ID of the folder to create a trigger in.

To get a folder ID make a list request.

name string

Name of the trigger. The name must be unique within the folder.

Value must match the regular expression \|[a-z][-a-z0-9]{1,61}[a-z0-9].

description string

Description of the trigger.

The maximum string length in characters is 256.

labels object

Resource labels as key:value pairs.

No more than 64 per resource. The string length in characters for each key must be 1-63. Each key must match the regular expression [a-z][-_0-9a-z]*. The maximum string length in characters for each value is 63. Each value must match the regular expression [-_0-9a-z]*.

rule object

Required. Trigger type.

Description of a rule for trigger activation.

rule.
timer
object
Rule for a timed trigger.
rule includes only one of the fields timer, messageQueue, iotMessage, objectStorage, containerRegistry, cloudLogs

Rule for activating a timed trigger.

rule.
timer.
cronExpression
string

Required. Description of a schedule as a cron expression.

The maximum string length in characters is 100.

rule.
timer.
invokeFunction
object
Instructions for invoking a function once.
rule.timer includes only one of the fields invokeFunction, invokeFunctionWithRetry

A single function invocation.

rule.
timer.
invokeFunction.
functionId
string

Required. ID of the function to invoke.

The maximum string length in characters is 50.

rule.
timer.
invokeFunction.
functionTag
string

Version tag of the function to execute.

rule.
timer.
invokeFunction.
serviceAccountId
string

ID of the service account that should be used to invoke the function.

rule.
timer.
invokeFunctionWithRetry
object
Instructions for invoking a function with retries as needed.
rule.timer includes only one of the fields invokeFunction, invokeFunctionWithRetry

A function invocation with retries.

rule.
timer.
invokeFunctionWithRetry.
functionId
string

Required. ID of the function to invoke.

The maximum string length in characters is 50.

rule.
timer.
invokeFunctionWithRetry.
functionTag
string

Version tag of the function to execute.

rule.
timer.
invokeFunctionWithRetry.
serviceAccountId
string

ID of the service account which has permission to invoke the function.

rule.
timer.
invokeFunctionWithRetry.
retrySettings
object

Retry policy. If the field is not specified, or the value is empty, no retries will be attempted.

Settings for retrying to invoke a function.

rule.
timer.
invokeFunctionWithRetry.
retrySettings.
retryAttempts
string (int64)

Maximum number of retries (extra invokes) before the action is considered failed.

Acceptable values are 1 to 5, inclusive.

rule.
timer.
invokeFunctionWithRetry.
retrySettings.
interval
string

Required. Time in seconds to wait between individual retries.

rule.
timer.
invokeFunctionWithRetry.
deadLetterQueue
object

DLQ policy (no value means discarding a message).

rule.
timer.
invokeFunctionWithRetry.
deadLetterQueue.
queueId
string

ID of the queue.

rule.
timer.
invokeFunctionWithRetry.
deadLetterQueue.
serviceAccountId
string

Required. Service account which has write permission on the queue.

The maximum string length in characters is 50.

rule.
messageQueue
object
Rule for a message queue trigger.
rule includes only one of the fields timer, messageQueue, iotMessage, objectStorage, containerRegistry, cloudLogs

Rule for activating a message queue trigger.

rule.
messageQueue.
queueId
string

Required. ID of the message queue in Yandex Message Queue.

rule.
messageQueue.
serviceAccountId
string

Required. ID of the service account which has read access to the message queue.

The maximum string length in characters is 50.

rule.
messageQueue.
batchSettings
object
Required. Batch settings for processing messages in the queue.

Settings for batch processing of messages in a queue.

rule.
messageQueue.
batchSettings.
size
string (int64)

Batch size. Trigger will send the batch of messages to the function when the number of messages in the queue reaches size, or the cutoff time has passed.

Acceptable values are 0 to 10, inclusive.

rule.
messageQueue.
batchSettings.
cutoff
string

Required. Maximum wait time. Trigger will send the batch of messages to the function when the number of messages in the queue reaches size, or the cutoff time has passed.

rule.
messageQueue.
visibilityTimeout
string

Queue visibility timeout override.

The maximum value is 43200 seconds.

rule.
messageQueue.
invokeFunction
object
Instructions for invoking a function once.

A single function invocation.

rule.
messageQueue.
invokeFunction.
functionId
string

Required. ID of the function to invoke.

The maximum string length in characters is 50.

rule.
messageQueue.
invokeFunction.
functionTag
string

Version tag of the function to execute.

rule.
messageQueue.
invokeFunction.
serviceAccountId
string

ID of the service account that should be used to invoke the function.

rule.
iotMessage
object
Rule for a Yandex IoT Core trigger.
rule includes only one of the fields timer, messageQueue, iotMessage, objectStorage, containerRegistry, cloudLogs

Rule for activating a Yandex IoT Core trigger.

rule.
iotMessage.
registryId
string

Required. ID of the Yandex IoT Core registry.

rule.
iotMessage.
deviceId
string

ID of the Yandex IoT Core device in the registry.

rule.
iotMessage.
mqttTopic
string

MQTT topic whose messages activate the trigger.

rule.
iotMessage.
invokeFunction
object
Instructions for invoking a function with retries as needed.

A function invocation with retries.

rule.
iotMessage.
invokeFunction.
functionId
string

Required. ID of the function to invoke.

The maximum string length in characters is 50.

rule.
iotMessage.
invokeFunction.
functionTag
string

Version tag of the function to execute.

rule.
iotMessage.
invokeFunction.
serviceAccountId
string

ID of the service account which has permission to invoke the function.

rule.
iotMessage.
invokeFunction.
retrySettings
object

Retry policy. If the field is not specified, or the value is empty, no retries will be attempted.

Settings for retrying to invoke a function.

rule.
iotMessage.
invokeFunction.
retrySettings.
retryAttempts
string (int64)

Maximum number of retries (extra invokes) before the action is considered failed.

Acceptable values are 1 to 5, inclusive.

rule.
iotMessage.
invokeFunction.
retrySettings.
interval
string

Required. Time in seconds to wait between individual retries.

rule.
iotMessage.
invokeFunction.
deadLetterQueue
object

DLQ policy (no value means discarding a message).

rule.
iotMessage.
invokeFunction.
deadLetterQueue.
queueId
string

ID of the queue.

rule.
iotMessage.
invokeFunction.
deadLetterQueue.
serviceAccountId
string

Required. Service account which has write permission on the queue.

The maximum string length in characters is 50.

rule.
objectStorage
object
rule includes only one of the fields timer, messageQueue, iotMessage, objectStorage, containerRegistry, cloudLogs

rule.
objectStorage.
eventType[]
string

Required. Type (name) of events, at least one value is required.

Must contain at least one element.

rule.
objectStorage.
bucketId
string

ID of the bucket.

rule.
objectStorage.
prefix
string

Prefix of the object key. Filter, optional.

rule.
objectStorage.
suffix
string

Suffix of the object key. Filter, optional.

rule.
objectStorage.
invokeFunction
object
Instructions for invoking a function with retries as needed.

A function invocation with retries.

rule.
objectStorage.
invokeFunction.
functionId
string

Required. ID of the function to invoke.

The maximum string length in characters is 50.

rule.
objectStorage.
invokeFunction.
functionTag
string

Version tag of the function to execute.

rule.
objectStorage.
invokeFunction.
serviceAccountId
string

ID of the service account which has permission to invoke the function.

rule.
objectStorage.
invokeFunction.
retrySettings
object

Retry policy. If the field is not specified, or the value is empty, no retries will be attempted.

Settings for retrying to invoke a function.

rule.
objectStorage.
invokeFunction.
retrySettings.
retryAttempts
string (int64)

Maximum number of retries (extra invokes) before the action is considered failed.

Acceptable values are 1 to 5, inclusive.

rule.
objectStorage.
invokeFunction.
retrySettings.
interval
string

Required. Time in seconds to wait between individual retries.

rule.
objectStorage.
invokeFunction.
deadLetterQueue
object

DLQ policy (no value means discarding a message).

rule.
objectStorage.
invokeFunction.
deadLetterQueue.
queueId
string

ID of the queue.

rule.
objectStorage.
invokeFunction.
deadLetterQueue.
serviceAccountId
string

Required. Service account which has write permission on the queue.

The maximum string length in characters is 50.

rule.
containerRegistry
object
rule includes only one of the fields timer, messageQueue, iotMessage, objectStorage, containerRegistry, cloudLogs

rule.
containerRegistry.
eventType[]
string

Required. Type (name) of events, at least one value is required.

Must contain at least one element.

rule.
containerRegistry.
registryId
string

ID of the registry.

rule.
containerRegistry.
imageName
string

Docker-image name. Filter, optional.

rule.
containerRegistry.
tag
string

Docker-image tag. Filter, optional.

rule.
containerRegistry.
invokeFunction
object
Instructions for invoking a function with retries as needed.

A function invocation with retries.

rule.
containerRegistry.
invokeFunction.
functionId
string

Required. ID of the function to invoke.

The maximum string length in characters is 50.

rule.
containerRegistry.
invokeFunction.
functionTag
string

Version tag of the function to execute.

rule.
containerRegistry.
invokeFunction.
serviceAccountId
string

ID of the service account which has permission to invoke the function.

rule.
containerRegistry.
invokeFunction.
retrySettings
object

Retry policy. If the field is not specified, or the value is empty, no retries will be attempted.

Settings for retrying to invoke a function.

rule.
containerRegistry.
invokeFunction.
retrySettings.
retryAttempts
string (int64)

Maximum number of retries (extra invokes) before the action is considered failed.

Acceptable values are 1 to 5, inclusive.

rule.
containerRegistry.
invokeFunction.
retrySettings.
interval
string

Required. Time in seconds to wait between individual retries.

rule.
containerRegistry.
invokeFunction.
deadLetterQueue
object

DLQ policy (no value means discarding a message).

rule.
containerRegistry.
invokeFunction.
deadLetterQueue.
queueId
string

ID of the queue.

rule.
containerRegistry.
invokeFunction.
deadLetterQueue.
serviceAccountId
string

Required. Service account which has write permission on the queue.

The maximum string length in characters is 50.

rule.
cloudLogs
object
rule includes only one of the fields timer, messageQueue, iotMessage, objectStorage, containerRegistry, cloudLogs

rule.
cloudLogs.
logGroupId[]
string

Log group identifiers, at least one value is required.

rule.
cloudLogs.
batchSettings
object
Required. Batch settings for processing log events.
rule.
cloudLogs.
batchSettings.
size
string (int64)

Batch size. Trigger will send the batch of messages to the function when the number of messages in the log group reaches size, or the cutoff time has passed.

Acceptable values are 0 to 100, inclusive.

rule.
cloudLogs.
batchSettings.
cutoff
string

Maximum wait time. Trigger will send the batch of messages to the function when the number of messages in the log group reaches size, or the cutoff time has passed.

Acceptable values are 1 seconds to 60 seconds, inclusive.

rule.
cloudLogs.
invokeFunction
object
Instructions for invoking a function with retries as needed.

A function invocation with retries.

rule.
cloudLogs.
invokeFunction.
functionId
string

Required. ID of the function to invoke.

The maximum string length in characters is 50.

rule.
cloudLogs.
invokeFunction.
functionTag
string

Version tag of the function to execute.

rule.
cloudLogs.
invokeFunction.
serviceAccountId
string

ID of the service account which has permission to invoke the function.

rule.
cloudLogs.
invokeFunction.
retrySettings
object

Retry policy. If the field is not specified, or the value is empty, no retries will be attempted.

Settings for retrying to invoke a function.

rule.
cloudLogs.
invokeFunction.
retrySettings.
retryAttempts
string (int64)

Maximum number of retries (extra invokes) before the action is considered failed.

Acceptable values are 1 to 5, inclusive.

rule.
cloudLogs.
invokeFunction.
retrySettings.
interval
string

Required. Time in seconds to wait between individual retries.

rule.
cloudLogs.
invokeFunction.
deadLetterQueue
object

DLQ policy (no value means discarding a message).

rule.
cloudLogs.
invokeFunction.
deadLetterQueue.
queueId
string

ID of the queue.

rule.
cloudLogs.
invokeFunction.
deadLetterQueue.
serviceAccountId
string

Required. Service account which has write permission on the queue.

The maximum string length in characters is 50.

Response

HTTP Code: 200 - OK

{
  "id": "string",
  "description": "string",
  "createdAt": "string",
  "createdBy": "string",
  "modifiedAt": "string",
  "done": true,
  "metadata": "object",

  //  includes only one of the fields `error`, `response`
  "error": {
    "code": "integer",
    "message": "string",
    "details": [
      "object"
    ]
  },
  "response": "object",
  // end of the list of possible fields

}

An Operation resource. For more information, see Operation.

Field Description
id string

ID of the operation.

description string

Description of the operation. 0-256 characters long.

createdAt string (date-time)

Creation timestamp.

String in RFC3339 text format.

createdBy string

ID of the user or service account who initiated the operation.

modifiedAt string (date-time)

The time when the Operation resource was last modified.

String in RFC3339 text format.

done boolean (boolean)

If the value is false, it means the operation is still in progress. If true, the operation is completed, and either error or response is available.

metadata object

Service-specific metadata associated with the operation. It typically contains the ID of the target resource that the operation is performed on. Any method that returns a long-running operation should document the metadata type, if any.

error object
The error result of the operation in case of failure or cancellation.
includes only one of the fields error, response

The error result of the operation in case of failure or cancellation.

error.
code
integer (int32)

Error code. An enum value of google.rpc.Code.

error.
message
string

An error message.

error.
details[]
object

A list of messages that carry the error details.

response object
includes only one of the fields error, response

The normal response of the operation in case of success. If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is the standard Create/Update, the response should be the target resource of the operation. Any method that returns a long-running operation should document the response type, if any.

In this article:
  • HTTP request
  • Body parameters
  • Response
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC