> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1894.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Extend CDN functionality with FastEdge

export const MethodSection = ({children}) => children ?? null;

export const MethodSwitch = ({children}) => {
  const tabs = React.Children.toArray(children).map(c => {
    if (!c || !c.props) return null;
    if (c.props.id) return c;
    const inner = c.props.children;
    if (inner && inner.props && inner.props.id) return inner;
    return null;
  }).filter(Boolean);
  const firstId = tabs.length > 0 ? tabs[0].props.id : "";
  const [active, setActive] = React.useState(firstId);
  React.useEffect(() => {
    try {
      const saved = localStorage.getItem("gcore_docs_method");
      if (saved && tabs.find(t => t.props.id === saved)) {
        setActive(saved);
      }
    } catch (_) {}
  }, []);
  React.useEffect(() => {
    try {
      document.querySelectorAll("h2[id], h3[id]").forEach(heading => {
        const visible = heading.offsetParent !== null;
        document.querySelectorAll(`a[href="#${heading.id}"]`).forEach(link => {
          if (link.closest("h1,h2,h3,h4,h5,h6")) return;
          const li = link.closest("li");
          if (li) li.style.display = visible ? "" : "none";
        });
      });
    } catch (_) {}
    window.dispatchEvent(new Event("scroll"));
  }, [active]);
  const handleClick = id => {
    setActive(id);
    try {
      localStorage.setItem("gcore_docs_method", id);
    } catch (_) {}
  };
  return <div>
      <div className="not-prose flex gap-0 border-b border-zinc-200 dark:border-zinc-800 mb-8 mt-2" role="tablist">
        {tabs.map(tab => {
    const isActive = active === tab.props.id;
    return <button key={tab.props.id} role="tab" aria-selected={isActive} onClick={() => handleClick(tab.props.id)} className={["px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer", isActive ? "border-primary text-primary" : "border-transparent text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-200"].join(" ")}>
              {tab.props.label}
            </button>;
  })}
      </div>

      {tabs.map(tab => <div key={tab.props.id} style={{
    display: active === tab.props.id ? "" : "none"
  }}>
          {tab.props.children}
        </div>)}
    </div>;
};

<MethodSwitch>
  <MethodSection id="portal" label="Customer Portal">
    <p>FastEdge CDN applications run inside the CDN request pipeline, modifying requests and responses before they reach the origin or end users.</p>

    <p>A CDN resource configured for the origin is required. To create one, follow the [CDN resource](/cdn/getting-started/create-a-cdn-resource/overview) guide.</p>

    ## Request lifecycle

    The CDN runtime invokes a CDN application at five stages:

    * **On request headers (before cache):** when the CDN receives request headers, before the cache is checked.
    * **On request headers (after cache):** when the CDN receives request headers, after the cache is checked.
    * **On request body:** when the CDN receives the request body.
    * **On response headers:** before the CDN sends response headers to the client.
    * **On response body:** before the CDN sends the response body to the client.

    <Info>CDN applications are built on the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions.</Info>

    Each stage has an independent application slot.

    <Warning>Only one FastEdge application can be attached to each processing stage.</Warning>

    ## Step 1. Create a FastEdge application

    <p>Deploy an application from a predefined template or upload a custom binary. Custom binaries must conform to the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification.</p>

    <Tabs>
      <Tab title="Deploy from template">
        <p>Several predefined templates are available for common use cases, including JWT authentication, basic HTTP authentication, and header manipulation. The JWT template verifies the JSON Web Token in the request `Authorization` header before the request reaches the origin.</p>

        1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge**.
        2. Open the **CDN Applications** page and click **Create new application**.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=0ee03744b2d26710856fc0a4a57b8afe" alt="CDN Applications page with Create new application button" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png" />
        </Frame>

        3. In the **Create from a template** section, select a template. For JWT authentication, select **Validate JWT in Authorization header**.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=5bce43b5b940471472d06ce7fe3334fc" alt="Create from a template section showing available template options" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png" />
        </Frame>

        4. Enter a name for the application and, optionally, a description.
        5. Fill in the **Template environment variables** section. The variables are pre-defined by the template — for the JWT template, enter the token signing key in the **secret** field. Custom environment variables and secrets can be added in the **Environment variables** and **Secrets** sections.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=dd3925883e9bdfb8adba93c019c92133" alt="JWT template configuration form with Name, template environment variables, and optional sections" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png" />
        </Frame>

        6. Click **Save and deploy**.

        <p>The application is deployed and ready to be linked to a CDN resource.</p>

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=bee9422987d8ba363db4af2fcc13d62f" alt="Application overview page showing active status" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png" />
        </Frame>

        <p>To adjust the configuration later, click the three-dot icon (...) next to the application, select **Manage**, then click **Actions** > **Edit application**.</p>

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=937858f3e46e462d80863221ecfa40ab" alt="Application overview page with Actions menu showing Edit application option" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png" />
        </Frame>
      </Tab>

      <Tab title="Deploy custom binary">
        <p>Custom implementations are available in the [FastEdge-sdk-rust examples](https://github.com/G-Core/FastEdge-sdk-rust/examples) and [proxy-wasm-sdk-as examples](https://github.com/G-Core/proxy-wasm-sdk-as/examples) repositories.</p>

        1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge**.
        2. Open the **CDN Applications** page and click **Create new application**.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=0ee03744b2d26710856fc0a4a57b8afe" alt="CDN Applications page with Create new application button" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png" />
        </Frame>

        3. Click **Upload binary**.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=5a036fb318e0a28e835ee1dafa485bd8" alt="Create application page with Upload binary card" width="1920" height="843" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png" />
        </Frame>

        4. Select the compiled `.wasm` file.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=436d291c512a38ed87a297838db0180a" alt="File selection dialog for uploading a binary" width="1920" height="843" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png" />
        </Frame>

        5. Enter a name for the application and, optionally, a description.
        6. Add any required environment variables as key-value pairs. For sensitive values, click **+ Add Secret** to store them in [Secrets Manager](/fastedge/secrets-manager/manage-secrets) instead.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=3fb8321d029680a24e402fd3009ce3e2" alt="Custom app configuration form with Name, environment variables, and Secrets fields" width="1920" height="843" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png" />
        </Frame>

        7. Click **Save and deploy**.

        <p>The application is deployed and ready to be linked to a CDN resource. To adjust the configuration later, click the three-dot icon (...) next to the application, select **Manage**, then click **Actions** > **Edit application**.</p>

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=2c43d11404d879756772409067ed52f2" alt="Application overview page with Actions menu showing Edit application option" width="1920" height="843" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png" />
        </Frame>
      </Tab>
    </Tabs>

    ## Step 2. Enable FastEdge for a CDN resource

    <p>FastEdge can be enabled for all requests on a CDN resource, or limited to specific URL paths using CDN rules.</p>

    <Tabs>
      <Tab title="For a whole CDN resource">
        1. In the Customer Portal, navigate to **CDN**.
        2. Find the resource and open its settings.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=65c34ae8a6162565c83194d7f7b835d6" alt="CDN resources list with resource settings button" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png" />
        </Frame>

        3. Scroll to the **FastEdge apps** section and enable the **FastEdge** checkbox to activate the feature.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=9ca5e18a12091dbf46ac1e5c8d938617" alt="CDN resource settings showing FastEdge apps section with the top-level FastEdge checkbox" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png" />
        </Frame>

        4. Enable the checkbox for the required processing stage. For the most common use case, enable **On request headers (before cache)**.
        5. Select the application from the dropdown.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=fc878e50692cf6a5b1b5773bd63fc336" alt="FastEdge apps section with On request headers enabled and application dropdown" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png" />
        </Frame>

        6. (Optional) Configure additional stage options:
           * **Interrupt request processing in case of error** — enabled by default. When active, errors on the FastEdge side return the relevant response code to the client. When disabled, the CDN ignores the error and forwards the request to the origin. Keep this enabled for security-sensitive applications.
           * **Invoke FastEdge app on edges** — enabled by default. Runs the application on CDN edge nodes.
           * **Invoke FastEdge app on shield** — disabled by default. Runs the application on CDN shield (precache) nodes in addition to edge nodes.

        7. Click **Save**.
      </Tab>

      <Tab title="For specific URL paths">
        <p>URL-specific rules apply FastEdge logic only to certain paths — protecting `/api/` with JWT validation while leaving static assets unaffected, for instance.</p>

        1. In the Customer Portal, navigate to **CDN**.
        2. Find the resource and open its settings.
        3. Click **Rules** > **Create rule**.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=0229f67ba9ab9d16f05fedf1806fede0" alt="CDN resource settings with Rules tab open" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png" />
        </Frame>

        4. Click **Create blank rule**.
        5. Enter a rule name.
        6. In the **Match criteria** section, specify the URL paths affected by the application.
        7. In the **Options** section, click **Add option**.
        8. Scroll to the **FastEdge apps** section.

        <Frame>
          <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=3013e5c30cd31f88bf287757b280e95c" alt="Add option panel showing FastEdge apps section" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png" />
        </Frame>

        9. Enable the checkbox for the required processing stage. For the most common use case, enable **On request headers (before cache)**.

        10. Select the application from the dropdown.

        11. (Optional) Configure additional stage options:
            * **Interrupt request processing in case of error** — enabled by default. When active, errors on the FastEdge side return the relevant response code to the client. When disabled, the CDN ignores the error and forwards the request to the origin.
            * **Invoke FastEdge app on edges** — enabled by default. Runs the application on CDN edge nodes.
            * **Invoke FastEdge app on shield** — disabled by default. Runs the application on CDN shield (precache) nodes in addition to edge nodes.

        12. Click **Create rule**.
      </Tab>
    </Tabs>

    ## Disconnect FastEdge from CDN

    <p>To stop FastEdge processing on a CDN resource, disable the FastEdge checkbox and save.</p>

    1. In the Customer Portal, navigate to **CDN**.
    2. Find the resource and open its settings.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=65c34ae8a6162565c83194d7f7b835d6" alt="CDN resources list with resource settings button" width="1269" height="556" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png" />
    </Frame>

    3. To disable FastEdge for the **whole CDN resource**, scroll to the **FastEdge apps** section and clear the **FastEdge** checkbox.
    4. To disable FastEdge for **specific URL paths**, open the **Rules** page and disable the relevant rule.
    5. Click **Save changes**.

    ## Delete a CDN application

    <Info>
      An enabled FastEdge application linked to a CDN resource cannot be deleted. Disconnect it from the CDN resource first.
    </Info>

    1. In the Customer Portal, navigate to **FastEdge**.
    2. Open the **CDN Applications** page and click the three-dot icon next to the application.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=878e6bb181242f8c5d53e3fe7c53c981" alt="CDN Applications list with three-dot menu open showing Delete option" width="1920" height="843" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png" />
    </Frame>

    3. Click **Delete**.
    4. Confirm by clicking **Yes, delete**.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/3z195f11z8sZ1rxy/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png?fit=max&auto=format&n=3z195f11z8sZ1rxy&q=85&s=120898a0b428b2da5e43d6270dbc274a" alt="Delete app confirmation dialog" width="1920" height="843" data-path="images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png" />
    </Frame>
  </MethodSection>

  <MethodSection id="api" label="REST API">
    <p>FastEdge CDN applications run inside the CDN request pipeline, modifying requests and responses before they reach the origin or end users.</p>

    <p>A CDN resource configured for the origin is required; the [Create CDN resource](/api-reference/cdn/cdn-resources/create-cdn-resource) endpoint covers the parameters.</p>

    ## Request lifecycle

    <p>The CDN runtime invokes a CDN application at five stages:</p>

    * **on\_request\_headers:** when the CDN receives request headers, before cache.
    * **on\_request\_headers\_after\_cache:** when the CDN receives request headers, after cache.
    * **on\_request\_body:** when the CDN receives the request body.
    * **on\_response\_headers:** before the CDN sends response headers to the client.
    * **on\_response\_body:** before the CDN sends the response body to the client.

    <Info>CDN applications are built on the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions.</Info>

    <p>Each stage has an independent application slot.</p>

    <Warning>Only one FastEdge application can be attached to each processing stage.</Warning>

    <p>The following steps configure FastEdge using the FastEdge API and the CDN API.</p>

    <Info>
      An [API token](/account-settings/api-tokens) is required, along with the ID of an existing [CDN resource](/cdn/getting-started/create-a-cdn-resource/overview).
    </Info>

    <p>Open a terminal and set these environment variables before running the examples:</p>

    ```bash theme={null}
    export GCORE_API_KEY="{YOUR_API_KEY}"
    export CDN_RESOURCE_ID="{YOUR_CDN_RESOURCE_ID}"
    ```

    ## Quickstart

    <p>Scripts that create a FastEdge application from the JWT authentication template and enable it on a CDN resource.</p>

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        import os
        from gcore import Gcore
        from gcore.types.cdn import cdn_resource_update_params as cdn_params

        client = Gcore()
        resource_id = int(os.environ["CDN_RESOURCE_ID"])

        # Step 1. Find the JWT template and create an application
        templates = list(client.fastedge.templates.list())
        jwt_template = next(t for t in templates if "validate jwt" in t.name.lower())

        app = client.fastedge.apps.create(
            name="my-cdn-app-1",
            template=jwt_template.id,
            status=1,
            env={"secret": "your-signing-key"},
        )
        print(f"app id={app.id}")

        # Step 2. Enable FastEdge on the CDN resource
        client.cdn.cdn_resources.update(
            resource_id,
            options=cdn_params.Options(
                fastedge=cdn_params.OptionsFastedge(
                    enabled=True,
                    on_request_headers=cdn_params.OptionsFastedgeOnRequestHeaders(
                        app_id=str(app.id),
                        interrupt_on_error=True,
                    ),
                )
            ),
        )
        print(f"FastEdge enabled on resource {resource_id}")
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        package main

        import (
            "context"
            "fmt"
            "os"
            "strconv"
            "strings"

            gcore "github.com/G-Core/gcore-go"
            "github.com/G-Core/gcore-go/cdn"
            "github.com/G-Core/gcore-go/fastedge"
        )

        func main() {
            client := gcore.NewClient()
            ctx := context.Background()
            resourceID, _ := strconv.ParseInt(os.Getenv("CDN_RESOURCE_ID"), 10, 64)

            // Step 1. Find the JWT template and create an application
            var templateID int64
            pager := client.Fastedge.Templates.ListAutoPaging(ctx, fastedge.TemplateListParams{})
            for pager.Next() {
                t := pager.Current()
                if strings.Contains(strings.ToLower(t.Name), "validate jwt") {
                    templateID = t.ID
                    break
                }
            }
            if err := pager.Err(); err != nil {
                panic(err)
            }

            app, err := client.Fastedge.Apps.New(ctx, fastedge.AppNewParams{
                App: fastedge.AppParam{
                    Name:     gcore.String("my-cdn-app-1"),
                    Template: gcore.Int(templateID),
                    Status:   gcore.Int(1),
                    Env:      map[string]string{"secret": "your-signing-key"},
                },
            })
            if err != nil {
                panic(err)
            }
            fmt.Printf("app id=%d\n", app.ID)

            // Step 2. Enable FastEdge on the CDN resource
            _, err = client.CDN.CDNResources.Update(ctx, resourceID, cdn.CDNResourceUpdateParams{
                Options: cdn.CDNResourceUpdateParamsOptions{
                    Fastedge: cdn.CDNResourceUpdateParamsOptionsFastedge{
                        Enabled: true,
                        OnRequestHeaders: cdn.CDNResourceUpdateParamsOptionsFastedgeOnRequestHeaders{
                            AppID: strconv.FormatInt(app.ID, 10),
                        },
                    },
                },
            })
            if err != nil {
                panic(err)
            }
            fmt.Printf("FastEdge enabled on resource %d\n", resourceID)
        }
        ```
      </Tab>
    </Tabs>

    ## Step-by-step

    <p>Each step explains what the call does, which parameters matter, and what the response looks like.</p>

    <Accordion title="Show all steps">
      ### Step 1. Create a FastEdge application

      <p>Deploy an application from a predefined template or upload a custom Proxy-Wasm binary.</p>

      **From a template**

      <p>List available templates to find the template ID:</p>

      ```bash theme={null}
      curl https://api.gcore.com/fastedge/v1/template \
        -H "Authorization: APIKey $GCORE_API_KEY"
      ```

      <p>The response lists all available templates with their IDs and names:</p>

      ```json theme={null}
      {
        "count": 7,
        "values": [
          { "id": 10, "name": "Validate JWT in Authorization header", "api_type": "proxy-wasm" },
          { "id": 111, "name": "Basic HTTP authentication", "api_type": "proxy-wasm" }
        ]
      }
      ```

      <p>Create the application using the template ID. The `env` object holds values for the template's pre-defined variables (the JWT template requires a `secret` key):</p>

      | Parameter  | Required | Description                                                  |
      | ---------- | -------- | ------------------------------------------------------------ |
      | `name`     | Yes      | Application name — alphanumeric, hyphens allowed             |
      | `template` | Yes      | Template ID from the listing                                 |
      | `status`   | Yes      | Set to active to deploy immediately; inactive saves as draft |
      | `env`      | No       | Template environment variables as key-value pairs            |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          from gcore import Gcore

          client = Gcore()

          app = client.fastedge.apps.create(
              name="my-cdn-app-1",
              template=10,  # Validate JWT in Authorization header
              status=1,
              env={"secret": "your-signing-key"},
          )
          print(f"app id={app.id}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          app, err := client.Fastedge.Apps.New(ctx, fastedge.AppNewParams{
              App: fastedge.AppParam{
                  Name:     gcore.String("my-cdn-app-1"),
                  Template: gcore.Int(10), // Validate JWT in Authorization header
                  Status:   gcore.Int(1),
                  Env:      map[string]string{"secret": "your-signing-key"},
              },
          })
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X POST https://api.gcore.com/fastedge/v1/apps \
            -H "Authorization: APIKey $GCORE_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "name": "my-cdn-app-1",
              "template": 10,
              "status": 1,
              "env": { "secret": "your-signing-key" }
            }'
          ```

          <p>The API returns the application ID used in Step 2:</p>

          ```json theme={null}
          {
            "id": 67890,
            "name": "my-cdn-app-1",
            "status": 1,
            "api_type": "proxy-wasm"
          }
          ```
        </Tab>
      </Tabs>

      **Upload a custom binary**

      <p>Upload the compiled `.wasm` file to the FastEdge binary store. The binary must conform to the Proxy-Wasm specification:</p>

      | Parameter    | Required | Description                                                    |
      | ------------ | -------- | -------------------------------------------------------------- |
      | Request body | Yes      | Raw `.wasm` file with `Content-Type: application/octet-stream` |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          from gcore import Gcore

          client = Gcore()

          with open("app.wasm", "rb") as f:
              binary = client.fastedge.binaries.create(body=f)
          print(f"binary id={binary.id}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          import "os"

          f, err := os.Open("app.wasm")
          if err != nil {
              panic(err)
          }
          defer f.Close()

          binary, err := client.Fastedge.Binaries.New(ctx, f)
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X POST https://api.gcore.com/fastedge/v1/binaries/raw \
            -H "Authorization: APIKey $GCORE_API_KEY" \
            -H "Content-Type: application/octet-stream" \
              --data-binary @app.wasm
          ```

          <p>The API returns the binary ID needed in the next call:</p>

          ```json theme={null}
          {
            "id": 12345,
            "api_type": "proxy-wasm"
          }
          ```
        </Tab>
      </Tabs>

      <p>Create the application using the binary ID:</p>

      | Parameter | Required | Description                                                  |
      | --------- | -------- | ------------------------------------------------------------ |
      | `name`    | Yes      | Application name — alphanumeric, hyphens allowed             |
      | `binary`  | Yes      | Binary ID from the upload response                           |
      | `status`  | Yes      | Set to active to deploy immediately; inactive saves as draft |
      | `env`     | No       | Environment variables as key-value pairs                     |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          app = client.fastedge.apps.create(
              name="my-cdn-app-1",
              binary=binary.id,
              status=1,
              env={"MY_VARIABLE": "value"},
          )
          print(f"app id={app.id}")
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          app, err := client.Fastedge.Apps.New(ctx, fastedge.AppNewParams{
              App: fastedge.AppParam{
                  Name:   gcore.String("my-cdn-app-1"),
                  Binary: gcore.Int(binary.ID),
                  Status: gcore.Int(1),
                  Env:    map[string]string{"MY_VARIABLE": "value"},
              },
          })
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X POST https://api.gcore.com/fastedge/v1/apps \
            -H "Authorization: APIKey $GCORE_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "name": "my-cdn-app-1",
              "binary": 12345,
              "status": 1,
              "env": { "MY_VARIABLE": "value" }
            }'
          ```

          <p>The API returns the application ID used in Step 2:</p>

          ```json theme={null}
          {
            "id": 67890,
            "name": "my-cdn-app-1",
            "status": 1,
            "api_type": "proxy-wasm"
          }
          ```
        </Tab>
      </Tabs>

      ### Step 2. Enable FastEdge for a CDN resource

      <p>Update the CDN resource to route traffic through the FastEdge application. The `fastedge` option accepts five processing stages — configure the stages the application handles.</p>

      | Parameter                               | Required | Description                                                                         |
      | --------------------------------------- | -------- | ----------------------------------------------------------------------------------- |
      | `fastedge.enabled`                      | Yes      | `true` activates FastEdge on the resource                                           |
      | `on_request_headers.app_id`             | Yes      | Application ID from Step 1                                                          |
      | `on_request_headers.interrupt_on_error` | No       | Default `true`. When `false`, errors are ignored and the request forwards to origin |
      | `on_request_headers.execute_on_edge`    | No       | Default `true`. Runs the application on CDN edge nodes                              |
      | `on_request_headers.execute_on_shield`  | No       | Default `false`. Runs the application on shield (precache) nodes                    |

      <Tabs>
        <Tab title="Python SDK">
          ```python theme={null}
          import os
          from gcore.types.cdn import cdn_resource_update_params as cdn_params

          resource_id = int(os.environ["CDN_RESOURCE_ID"])

          client.cdn.cdn_resources.update(
              resource_id,
              options=cdn_params.Options(
                  fastedge=cdn_params.OptionsFastedge(
                      enabled=True,
                      on_request_headers=cdn_params.OptionsFastedgeOnRequestHeaders(
                          app_id=str(app.id),
                          interrupt_on_error=True,
                      ),
                  )
              ),
          )
          ```
        </Tab>

        <Tab title="Go SDK">
          ```go theme={null}
          _, err = client.CDN.CDNResources.Update(ctx, resourceID, cdn.CDNResourceUpdateParams{
              Options: cdn.CDNResourceUpdateParamsOptions{
                  Fastedge: cdn.CDNResourceUpdateParamsOptionsFastedge{
                      Enabled: true,
                      OnRequestHeaders: cdn.CDNResourceUpdateParamsOptionsFastedgeOnRequestHeaders{
                          AppID: strconv.FormatInt(app.ID, 10),
                      },
                  },
              },
          })
          ```
        </Tab>

        <Tab title="curl">
          ```bash theme={null}
          curl -X PATCH https://api.gcore.com/cdn/resources/$CDN_RESOURCE_ID \
            -H "Authorization: APIKey $GCORE_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "options": {
                "fastedge": {
                  "enabled": true,
                  "on_request_headers": {
                    "app_id": "67890",
                    "enabled": true,
                    "interrupt_on_error": true
                  }
                }
              }
            }'
          ```
        </Tab>
      </Tabs>

      <p>The five supported stages are `on_request_headers`, `on_request_headers_after_cache`, `on_request_body`, `on_response_headers`, and `on_response_body`. Each stage accepts the same `app_id`, `interrupt_on_error`, `execute_on_edge`, and `execute_on_shield` parameters.</p>

      <p>To apply FastEdge only to specific URL paths, create a CDN rule with <code>POST [https://api.gcore.com/cdn/resources/RESOURCE\_ID/rules](https://api.gcore.com/cdn/resources/RESOURCE_ID/rules)</code> and include the `fastedge` option in the rule's `options` object.</p>
    </Accordion>

    ## Disable FastEdge integration

    <p>Setting `fastedge.enabled` to `false` stops FastEdge processing on a CDN resource.</p>

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        import os
        from gcore.types.cdn import cdn_resource_update_params as cdn_params

        resource_id = int(os.environ["CDN_RESOURCE_ID"])

        client.cdn.cdn_resources.update(
            resource_id,
            options=cdn_params.Options(
                fastedge=cdn_params.OptionsFastedge(enabled=False),
            ),
        )
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        _, err = client.CDN.CDNResources.Update(ctx, resourceID, cdn.CDNResourceUpdateParams{
            Options: cdn.CDNResourceUpdateParamsOptions{
                Fastedge: cdn.CDNResourceUpdateParamsOptionsFastedge{
                    Enabled: false,
                },
            },
        })
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X PATCH https://api.gcore.com/cdn/resources/$CDN_RESOURCE_ID \
          -H "Authorization: APIKey $GCORE_API_KEY" \
          -H "Content-Type: application/json" \
          -d '{
            "options": {
              "fastedge": {
                "enabled": false
              }
            }
          }'
        ```
      </Tab>
    </Tabs>

    ## Delete a CDN application

    <Info>
      An enabled FastEdge application linked to a CDN resource cannot be deleted. Disable the FastEdge integration on the CDN resource before deleting the application.
    </Info>

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        client.fastedge.apps.delete(app_id)
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        err = client.Fastedge.Apps.Delete(ctx, appID)
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X DELETE https://api.gcore.com/fastedge/v1/apps/$APP_ID \
          -H "Authorization: APIKey $GCORE_API_KEY"
        ```
      </Tab>
    </Tabs>

    <p>A `204 No Content` response confirms the application was deleted.</p>
  </MethodSection>
</MethodSwitch>
