[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Functions](../../index.md) > [Concepts](../index.md) > [Trigger](index.md) > Trigger for Object Storage

# Trigger for Object Storage that invokes a Cloud Functions function

A [trigger](index.md) for Object Storage runs a Cloud Functions [function](../function.md) when a specific event occurs with a Object Storage [object](../../../storage/concepts/object.md). The trigger must be in the same cloud as the bucket whose events it is subscribed to.

A trigger for Object Storage needs a [service account](../../../iam/concepts/users/service-accounts.md) to invoke a function.

For more information about creating a trigger for Object Storage, see [Creating a trigger for Object Storage that invokes Cloud Functions](../../operations/trigger/os-trigger-create.md).

## Events for setting up a trigger {#event}

Events with bucket objects that can be tracked using a trigger:
- [Creating an object](../../../storage/operations/objects/upload.md).
- [Editing an object ACL](../../../storage/operations/objects/edit-acl.md).
- [Deleting an object](../../../storage/operations/objects/delete.md).

### Filtering events by object {#filter}

Events are filtered using prefixes and suffixes for an object [key](../../../storage/concepts/object.md#key):
* The prefix is a part at the beginning of the object key. 
* The suffix is a part at the end of the object key. 

Prefixes and suffixes can be of any length. When using a prefix and suffix at the same time, filtering is based on the logical `AND`: for the trigger to fire, the object key must match both the prefix and suffix. 

## Event batching {#batching}

Batching settings allow you to send multiple events to a function at the same time. They set a top limit on the event batch size and accumulation time. For example, if the event batch size is `3`, the function can receive batches of one to three events.

## Roles required for the proper operation of a trigger for Object Storage {#roles}

- To create a trigger, you need a permission for the service account under which the trigger runs the operation. This permission comes with the [iam.serviceAccounts.user](../../../iam/security/index.md#iam-serviceAccounts-user) and [editor](../../../iam/roles-reference.md#editor) roles or higher.
- For the trigger to fire, the service account needs the `functions.functionInvoker` role for the folder containing the function invoked by the trigger.

Learn more about access management [here](../../security/index.md).

## Object Storage trigger message format {#format}

After the trigger is activated, it sends the following message to the function: 

```json
{
  "messages": [
    {
      "event_metadata": {
        "event_id": "bb1dd06d-a82c-49b4-af98-d8e0********",
        "event_type": "yandex.cloud.events.storage.ObjectDelete",
        "created_at": "2019-12-19T14:17:47.847365Z",
        "tracing_context": {
          "trace_id": "dd52ace7********",
          "span_id": "",
          "parent_span_id": ""
        },
        "cloud_id": "b1gvlrnlei4l********",
        "folder_id": "b1g88tflru0e********"
      },
      "details": {
        "bucket_id": "s3-for-trigger",
        "object_id": "dev/0_15a775_972dbde4_orig12.jpg"
      }
    }
  ]
}
```

## Use cases {#examples}

* [Automatically copying objects from one Yandex Object Storage bucket to another](../../tutorials/bucket-to-bucket.md)

## Useful links {#see-also}

* [Trigger for Object Storage that invokes a Serverless Containers container](../../../serverless-containers/concepts/trigger/os-trigger.md)
* [Trigger for Object Storage that sends messages to WebSocket connections](../../../api-gateway/concepts/trigger/os-trigger.md)