# How to Set Up an Activation Flow?

### Overview

The **Activation Flow** is a foundational template used to automate project or tenant activation. You can use it as-is for testing or customize it for your own setup. It’s available in the **Templates** section of your workspace.

This guide provides a conceptual overview of each step so you can understand the logic and modify it as needed.

### 1. Flow Initialization

The flow begins with a **Request step**, which acts as the entry point for the activation flow. This step captures the headers and the input payload that will be passed along to the subsequent steps.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F2t4iv4S7zsVZckVsLmzB%2Fimage.png?alt=media&#x26;token=73c87f57-bdd1-492e-a285-6f46e5443934" alt=""><figcaption></figcaption></figure>

By default, this template is designed to start on a **new API request**, but you can configure the starting point differently depending on your use case.

{% hint style="info" %}
For more details, see [Flow Types – Choosing a Starting Point](https://docs.fastn.ai/flow-setup-essentials#flow-types)
{% endhint %}

### 2. Initialize Your Flow Variables

The second step is a **Variable step** named **“initiate your flow variables.”**

This sets up key reusable values such as:

* **Project ID** – identifies which project or tenant the activation applies to.
* **Organization ID** – used to associate imported templates or configurations.
* **Template and Webhook objects** – used later in the loop steps for flow creation or validation.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F59fc6Ui2XelxgrDer512%2Fimage.png?alt=media&#x26;token=fbb99fdb-f358-4e12-825d-ec8fd42429ed" alt=""><figcaption></figcaption></figure>

> By standardizing these variables early on, the rest of the flow can reference them consistently without redefining values.

### 3. Switch Step: *Tenant Exists?*

Before moving into template and webhook loops, the flow checks if the **tenant exists**.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F21u9B8QSjeKsBjw6uSSS%2Fimage.png?alt=media&#x26;token=acd0fb33-fb9e-4d10-aeec-0e2a2f040aab" alt=""><figcaption></figcaption></figure>

* **If the tenant does not exist →** return an **error message** response immediately.
* **If a tenant exists →** continue into the next stages (looping through templates and webhooks).

This ensures the flow only proceeds when a valid project/tenant is present.

### 4. Loop Over Templates

If your setup includes templates, the flow loops through each one to check whether a corresponding flow already exists.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F8hOQZiYojFhH3DmpNzJf%2Fimage.png?alt=media&#x26;token=5448c419-87c4-4fd5-b4a6-d854bfaa4c22" alt=""><figcaption></figcaption></figure>

#### **Inside the loop**

* **Get API step** → checks if a flow already exists.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F3HnKFFs5JW8h4EZGuVAv%2Fimage.png?alt=media&#x26;token=03f1776a-60f5-4b41-a857-9960b05e441d" alt=""><figcaption></figcaption></figure>

* If it does not exist, the flow imports it using the defined project and template IDs.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fb09ryFkly5VGCbJoLYxx%2Fimage.png?alt=media&#x26;token=9f3382da-feb1-4df4-8630-a00dbf3169a4" alt=""><figcaption></figcaption></figure>

* This ensures that all required templates for the tenant are created and deployed.

> You can omit this section entirely if your activation doesn’t require template imports.

### 5. Loop Over Webhooks

Once templates are processed, the flow iterates through **webhooks**.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fsd8xBwHCRHdqtgspFnYb%2Fimage.png?alt=media&#x26;token=edc25cc8-a289-414e-bd45-df546d0fbba9" alt=""><figcaption></figcaption></figure>

#### **Inside the loop**

* **Get Webhook step** → checks if the webhook exists.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FRTNdXnOiIkzyfoBMwMUf%2Fimage.png?alt=media&#x26;token=d640424d-46cc-4fb5-979f-925aaf2d9c60" alt=""><figcaption></figcaption></figure>

* **Switch step** → if the webhook does not exist, create it with schedules and routes:

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FOMsHtpUkERX4fOuL922k%2Fimage.png?alt=media&#x26;token=c2473606-c720-4502-80d8-7ed0b1699a8c" alt=""><figcaption></figcaption></figure>

Each webhook can include:

* Schedule details (frequency, unit, flow association).

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FJNxR8C1qvyu6Z6Ktu8b4%2Fimage.png?alt=media&#x26;token=b0fb7d1f-145c-46d6-9ba8-ff10283eb9e2" alt=""><figcaption></figcaption></figure>

#### **Routes configuration**

* Route configurations (headers, flow IDs, routes).

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FxggHUKTbx4X26dO2YcmU%2Fimage.png?alt=media&#x26;token=25821cb9-905a-43fe-9b80-95ffc54d6e93" alt=""><figcaption></figcaption></figure>

#### **Additional configurations**

* Optional settings like auto-generated API keys, retries, and authentication.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FTXGdgJPbRVw8CsahSLQS%2Fimage.png?alt=media&#x26;token=2a247d69-9d71-4bd5-83dd-4ce5501a769a" alt=""><figcaption></figcaption></figure>

> If your project doesn’t use webhooks, you can remove these steps and keep only the relevant logic for your activation.

### 6. Success Response

The final step is a **Response step**, which returns a success message.

* This confirms that templates have been imported (if needed) and webhooks have been created or validated.
* You can fully customize this response.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FHwTXquUyNZ97DszWuTZK%2Fimage.png?alt=media&#x26;token=45988699-8bff-4f82-86f1-7d6b21edc79f" alt=""><figcaption></figcaption></figure>

### When to Use This Flow?

This is a **basic activation flow** typically used in multi-tenant setups. It ensures that each tenant’s templates and webhooks are properly initialized.

You can also adapt this structure for other activation scenarios:

* Use it without templates or webhooks by removing those loops.
* Treat any flow connected through a widget’s **“activate”** function as an activation flow.

> This template helps you structure any activation process, whether for tenants, projects, or custom configurations.
