---
title: How to add a trigger to a function
description: Learn how to add triggers to your Serverless Functions in Scaleway.
tags: functions
dates:
  validation: 2025-10-27
  posted: 2023-04-27
---

This page shows you how to configure triggers for your Serverless Functions. A trigger is an event that invokes a function.

In a serverless architecture, a function only runs when it is called by an event. A trigger is a mechanism that connects the function to an event source and enables the function to run automatically in response to specific events.

A trigger can be an HTTP request, a message from a queue or stream, a CRON schedule etc. It is configured during the function deployment, and determines how and when the function will run.

## Before you start

To complete the following actions, you must have:

* A Scaleway account logged into the [console](https://console.scaleway.com)
* [Owner](/en/docs/iam/concepts/glossary/#owner) status or [IAM permissions](/en/docs/iam/concepts/glossary/#permission) allowing you to perform actions in the intended Organization
* Created a [functions namespace](/en/docs/serverless-functions/how-to/create-manage-delete-functions-namespace/)
* Created a [function](/en/docs/serverless-functions/how-to/create-a-function/)
* [Created credentials](/en/docs/queues/how-to/create-credentials/) for Scaleway Queues
* [Created a queue](/en/docs/queues/how-to/create-manage-queues/)

> **Important**
>
> You can create triggers on private functions, but to update the privacy of a function from **public** to **private**, you must recreate the existing **Queues** and **NATS** triggers after the privacy change. We are actively working to make this operation as seamless as possible.

> **Note**
>
> Triggers send messages through a `POST` request with the message body in the request body.

## Queue triggers

> **Note**
>
> You must have at least the `MessagingAndQueuingReadOnly` permission in the Project containing the queue to add a queue trigger to Serverless Functions.
>
> Refer to the [permissions sets documentation](/en/docs/iam/policies-permissions/permission-sets/) for more information.

[Queue triggers](/en/docs/serverless-functions/concepts/#queue-trigger) allow you to automatically invoke a function using events stored in a [queue](/en/docs/queues/concepts/#queue).

Only queues created with the Scaleway Queues product are compatible with Serverless Functions.

The configuration of the queue retention may affect the behavior of the trigger. Refer to the [Considerations to configure event retention for queue trigger inputs](/en/docs/serverless-functions/reference-content/configure-trigger-inputs/) page for more information.

1. Click **Functions** in the **Serverless** section of the side menu. The functions page displays.
2. Click the relevant functions namespace.
3. Click the name of the function you want to manage. The function **Code** tab displays.
4. Click the **Triggers** tab. The trigger configuration displays.
5. Click **Create trigger**. The trigger creation form displays in a pop-up.
6. Enter a **name** for your trigger and select the **Queues (Scaleway)** type, then select your queue name.
7. Click **Create trigger** to launch trigger creation.

> **Note**
>
> **Retry Policy:** If the Function returns a status code superior or equal to 300, sending the message will be retried up to three times.

## NATS triggers

> **Note**
>
> You must have at least the `MessagingAndQueuingReadOnly` permission in the Project containing the NATS account to add to Serverless Functions.
>
> Refer to the [permissions sets documentation](/en/docs/iam/policies-permissions/permission-sets/) for more information.

[NATS triggers](/en/docs/serverless-functions/concepts/#nats-trigger) allow you to automatically invoke a function using messages sent in a [NATS](/en/docs/nats/concepts/#nats-messaging-system) subject.

Scaleway [NATS subjects](/en/docs/nats/quickstart/) are compatible with Serverless Functions.

1. Click **Functions** in the **Serverless** section of the side menu. The functions page displays.
2. Click the relevant functions namespace.
3. Click the name of the function you want to manage. The function **Code** tab displays.
4. Click the **Triggers** tab. The trigger configuration displays.
5. Click **Create trigger**. The trigger creation form displays in a pop-up.
6. Enter a **name** for your trigger and select the **NATS (Scaleway)** type, then select your NATS account and subject name.
7. Click **Create trigger** to launch trigger creation.

> **Note**
>
> **Retry Policy:** If the Function returns a status code superior or equal to 300, sending the message will be retried up to three times.

## CRON triggers

[CRON triggers](/en/docs/serverless-functions/concepts/#cron-trigger) allow you to invoke your functions based on a recurring schedule. The CRON triggers for Serverless Functions use the **UTC** time zone.

> **Note**
>
> The arguments of a CRON trigger are injected in the body of the `POST` HTTP request, and sent to the `/` endpoint.

1. Click **Functions** in the **Serverless** section of the side menu. The functions page displays.
2. Click the relevant functions namespace.
3. Click the name of the function you want to manage. The function **Code** tab displays.
4. Click the **Triggers** tab. The trigger configuration displays.
5. Click **Create trigger**. The trigger creation form displays in a pop-up.
6. Enter a **name** for your trigger and select the **CRON** type.
7. Enter the cron schedule in UNIX format (`* * * * *`) and paste your JSON arguments in the form.
8. Click **Create trigger** to launch trigger creation.

> **Note**
>
> Refer to the [cron schedules reference](/en/docs/serverless-functions/reference-content/cron-schedules/) for more information.
