---
name: event-notifications-en-destination-codeengine
title: Code Engine
description: IBM Cloud Code Engine is a fully managed, serverless platform that runs your containerized workloads, including web apps, micro-services, event-driven functions, or batch jobs. Code Engine represents a service destination, where an incoming notification can be consumed programmatically. For example, an incoming notification about an event can trigger a Code Engine destination to a backend microservice to act based on the content of the incoming notification.
last-updated: 2024-02-29
---

> ## Documentation Index
> The table of contents for this documentation set is at https://cloud.ibm.com/docs/event-notifications?format=markdown
> The index for all IBM Cloud docs is at: https://cloud.ibm.com/docs/llms.txt
> Use these files to discover more information as needed.

# Code Engine
{: #en-destinations-codeengine}

IBM Cloud Code Engine is a fully managed, serverless platform that runs your containerized workloads, including web apps, micro-services, event-driven functions, or batch jobs. Code Engine represents a service destination, where an incoming notification can be consumed programmatically. For example, an incoming notification about an event can trigger a Code Engine destination to a backend microservice to act based on the content of the incoming notification.
{: shortdesc}

## Configuring a Code Engine destination
{: #en-codeengine-configure}

Before you configure Code Engine as a destination for `run type` Job, make sure that you have a Code Engine project [created and job configured](https://cloud.ibm.com/codeengine/projects) in the same account as your Event Notifications instance.
{: note}

If there is `run type` Job, if you are using Event Notifications CLI or API to configure Code Engine job as a destination, help ensure that you have enabled authorization to grant access between services. For more information, see [Using authorizations to grant access between services](#en-using-s2s-auth1-ce).
{: important}

To configure a Code Engine destination, complete the following steps:

1. From your Event Notifications instance, click **Destinations**.

1. Click **Create** to add a new destination.

1. Enter the following destination details in the **Create destination** dialog:

    - **Name**: Enter a name for your destination.
    - **Description**: Optionally, enter a description for your destination.
    - **Type**: Under **Destination**, select **Code Engine** from the list as your destination type.
    - **Run Type**: Select one of the run type Code Engine jobs or **Code Engine** application.

    If the selected run type is job, provide the following details:
    - **Project name**: Select the Code Engine project name from the list. Otherwise, click **Create new project** to create a Code Engine project.

        When you select a Code Engine project, the authorization between the services is created internally between the two service instances, if the authorization does not exist.
        {: note}

    - **Job name**: Select the job name from the list.

    If the selected run type is application, provide the following details:
    - **URL**: Enter the Code Engine application secured URL (only HTTPS).
    - **Verb**: Select the verb to be called (GET or POST).
    - **Headers**: Optionally, enter a list of headers to be passed to the Code Engine application.

1. Click **Create destination**.

Event Notifications now supports Code Engine Functions.
{: note}

## Using authorizations to grant access between services
{: #en-using-s2s-auth1-ce}

Use IBM Cloud&reg; Identity and Access Management (IAM) to create or remove an authorization that grants one service access to another service.


### Creating an authorization in the console
{: #en-using-s2s-console-ce}

1. In the IBM Cloud console, click **Manage** > **Access (IAM)**, and select **Authorizations**.

1. Click **Create**.

1. Select a source account.
   * If the source service that needs access to the target service is in this account, select **This account**.

1. Select a **Source service such** as **Event Notifications**.

1. Specify whether you want the authorization to be for all resources or Resources based on selected attributes. If you have chosen Resources based on selected attributes, then specify the **Add attributes**: only source resource group or only source service instance.

1. Select a **Target service** as **Code Engine**.

1. For the target service, specify whether you want the authorization to be for all projects, only to a specific project in the account, or projects only in a certain resource group.

1. Select both the roles (Viewer and Writer) to assign access to the source service that accesses the target service.

   If you have selected only one of these two roles (Reader or Writer) during the service to service authorization, you cannot trigger a job or configure destination. You get an error for service to service authorization failure in these cases. Make sure that you recreate an authorization between the services with both the roles selected.
{: important}

1. Click **Authorize**.

### Creating an authorization by using the CLI
{: #en-create-auth-cli1-ce}

To authorize a source service to access a target service, run the `ibmcloud iam authorization-policy-create` command.

For more information about all of the parameters that are available for this command, see [ibmcloud iam authorization-policy-create](https://cloud.ibm.com/docs/cli?topic=cli-ibmcloud_commands_iam&format=markdown#ibmcloud_iam_authorization_policy_create).

### Accessing event payload in Code Engine job
{: #en-codeengine-access-event-payload}

The event payload has been transmitted to Code Engine job by using an environment variable, which can be retrieved by using the `ibmendata` environment variable.

## Testing a Code Engine destination configuration
{: #en-codeengine-test-destination}

You can test a Code Engine destination in the options menu next to the destination. You can test whether the provided configuration is correct with a single click.

For more information on testing a destination, see [Testing Destinations](https://cloud.ibm.com/docs/event-notifications?topic=event-notifications-en-test-destination&format=markdown).

## Code Engine retry policy
{: #en-codengine-retry}

When sending notifications to Code Engine, issues such as network errors and application glitches can cause the requests to fail. Event Notifications automatically retries failed requests to provide resiliency.

For detailed information about retry behavior, including retry attempts, delays, and timeout values, see [Retry policy for destinations](https://cloud.ibm.com/docs/event-notifications?topic=event-notifications-en-destination&format=markdown#en-destination-retry-policy).