---
title: set_error_group_callback (Python agent API)
source: https://docs.newrelic.com/docs/apm/agents/python-agent/python-agent-api/seterrrorgroupcallback-python-agent-api
---

## Syntax [#syntax]

```py
newrelic.agent.set_error_group_callback(callback_function(exception, transaction_data))
```

This method allows error groups within the errors inbox to be set to a specific identifier (or "fingerprint").

## Requirements [#requirements]

Python agent version 8.8.0 or higher.

## Description [#description]

This endpoint takes in a single input, a callback, which is used to register error groups. This callback is customer-defined and must accept the exception that triggered the agent's [`notice_error` API](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/noticeerror-python-agent-api). To unset this setting, call the API again and set the callback to `None`.

## Parameters for `set_error_group_callback` [#parameters-set-error-group-callback]

| Parameter                            | Description                                                                                                           |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| `callback` _callable function_       | Required. The callback function you want to define. Use `None` to unset.                                              |
| `application` _Application Instance_ | Optional. If an application instance is not provided, the function will check for the activated application instance. |

## Parameters for customer defined callback function [#parameters-customer-defined-callback-function]

| Parameter                       | Description                                                                                                                                                                                      |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `exception` _Runtime exception_ | Required. This would be the runtime exception that triggered the agent's [`notice_error` API](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/noticeerror-python-agent-api). |
| `transaction_data` _dictionary_ | Required. A dictionary of transaction data captured by the Python agent.                                                                                                                         |

## Return values [#return-values]

When successful, the API will add a string representing the desired error group name as an agent attribute.

When unsuccessful, the API will not add `error.group.name` as an agent attribute.

## Example usage [#examples]

### Set error group callback [#error-group-callback-example]

An example of using `set_error_group_callback`:

```py
def customer_callback(exc, data):
    if isinstance(exc, ValueError):
        return "group1"


def some_other_function():
    try:
        raise ValueError("Oh no!")
    except Exception:
       newrelic.agent.notice_error()


def example_function(customer_callback):
    try:
        newrelic.agent.set_error_group_callback(customer_callback)
        some_other_function()
    finally:
        newrelic.agent.set_error_group_callback(None)
```
