# Error Logging

Sometimes things don't work out quite like they should. It happens to the best of us. Yes, we're talking about debugging! So if you find yourself in the unfortunate situation where a workflow is erroring unexpectedly, we've designed an endpoint to help you identify exactly where things went wrong.

## Error Logging

<mark style="color:blue;">`GET`</mark> `https://api.runalloy.com/forge/2021-12/workflow/:workflowId/errors`

This endpoint fetches an array of error logs given a specific child workflow Id. It returns an error `id`, the error message, and the datestamp when the error was thrown.

#### Headers

| Name                                                            | Type   | Description                          |
| --------------------------------------------------------------- | ------ | ------------------------------------ |
| Authorization Bearer {apiKey}<mark style="color:red;">\*</mark> | String | Your Forge API key for authorization |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
  errors: [
    {
    "_id" : ObjectId("6155b192a13d750013322432"),
    "workflowId" : ObjectId("613b2be307575700132ef293"),
    "executionId" : ObjectId("6155ac246093840013297377"),
    "blockId" : "edb4e8e8-1e0e-4fac-84fd-9f9d4855ce93",
    "blockType" : "alloy.shopify",
    "error" : "Error: Request failed with status code 403",
    "createdAt" : ISODate("2021-09-30T12:46:10.562Z"),
    "updatedAt" : ISODate("2021-09-30T12:46:10.562Z"),
    "__v" : 0
   }
 ]
}

```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Remember to use the child workflow Id when querying the workflow errors endpoint. Passing in a parent workflow Id will fail.
{% endhint %}

## Returning Errors in Realtime to your API

If you prefer to get realtime error alerts about when a workflow fails, we support a few different options. You can set up Alloy Forge to stream failed error logs to a POST endpoint on your system. In other words, every time an error occurs in a workflow in Forge, we can make an API call to a webhook on your system with some basic information about the error.&#x20;

You can see a sample of the incoming body data that will be sent to your webhook.

```
{
    "_id" : ObjectId("6155b192a13d750013322432"),
    "workflowId" : ObjectId("613b2be307575700132ef293"),
    "executionId" : ObjectId("6155ac246093840013297377"),
    "blockId" : "edb4e8e8-1e0e-4fac-84fd-9f9d4855ce93",
    "blockType" : "alloy.shopify",
    "error" : "Error: Request failed with status code 403",
    "createdAt" : ISODate("2021-09-30T12:46:10.562Z"),
    "updatedAt" : ISODate("2021-09-30T12:46:10.562Z"),
    "__v" : 0
}

```

Configuring this webhook is easy. Simply navigate to the Forge Settings page and paste in your webhook URL. Note that this endpoint must not have any authentication or password protection as we currently do not support authentication.

## AWS Eventbridge Integration

Forge also supports a direct integration with AWS Eventbridge for streaming error logs. To enable this feature, navigate to the AWS Eventbridge connection in the Forge Settings. You'll be prompted to enter your AWS keys which are securely encrypted in Alloy Forge.

![Setup AWS Event Bridge](/files/U1czT5SXJx7dUl1adTxy) ![Configure AWS Event Bridge](/files/RY8LHwGli1rll9YVFSO1)

From there, enter your **Event Bus Name** and hit save. Turning on this integration will automatically stream Alloy Forge error logs directly to AWS. You can disable this feature at any point by toggling the Event Bridge connector off.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gregg.gitbook.io/alloy-developer/reference/api-reference/error-logging.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
