# Response Actions

By default, a successful request is determined by the response HTTP Code being in the info (1xx) or success (2xx) ranges and anything outside of these is treated as a request failure.

Sometimes, an API will return a response that needs to be treated differently to how it would normally be handled. For example, an API might return a 400 error to indicate a part of the request contains invalid data. We can use a response action to catch that error and do something about it.

## Execution Flow <a href="#execution-flow" id="execution-flow"></a>

The Response Action executes the following steps:

1. Run retry logic. Retry logic takes precedence and will cancel the Response Action if possible. If no more retries can be made (or no retry is required), the Response Action is executed.
2. If no retry error has occurred, the request and transaction states are updated according to the Response Action.
3. Notify the user by adding an integration note. A note will only be added according to the notification script on the Integration.
4. If a script is specified, execute the script.

## Response Action Fields <a href="#fields" id="fields"></a>

### Details

![](https://605238050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MfWt1gC0xYoLovMBuei%2F-MfX1P3sc67i3Kj6b1K_%2FResponse%20Action%201.png?alt=media\&token=c846ecbf-caf8-4ee0-ae60-4afb6b7fba9e)

The Details fields that can be configured for the Response Action record are as follows:

<table><thead><tr><th width="165.7799511002445">Field</th><th width="150">Type</th><th width="407.0834206276623">Description</th></tr></thead><tbody><tr><td>Name</td><td>String</td><td>The quick reference name of this Response Action.</td></tr><tr><td>Description</td><td>String</td><td>An explanation of what the response action is intended to do.</td></tr><tr><td>Integration</td><td>Reference</td><td>The Integration this action applies to.</td></tr><tr><td>Message</td><td>Reference</td><td><em>(Visible when Integration is populated)</em>. Only run this Response action for this message.</td></tr><tr><td>Code</td><td>String</td><td>The status code to match on the request.</td></tr><tr><td>Type</td><td>Choice</td><td>The type of response according to the code.</td></tr><tr><td>Application</td><td>Reference</td><td>Application containing this record.</td></tr></tbody></table>

### Settings

![](https://605238050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MfWt1gC0xYoLovMBuei%2F-MfX2AjEcphQroTLSSb4%2FResponse%20Action%202.png?alt=media\&token=bedbb258-433c-4eab-96b3-7260155979e6)

The Settings fields that can be configured for the Response Action record are as follows:

<table><thead><tr><th width="212">Field</th><th width="150">Type</th><th width="336.1921708185053">Description</th></tr></thead><tbody><tr><td>Retry^</td><td>Boolean</td><td>Retry the request to the limit specified by the <em>Integration</em> before running this response action.</td></tr><tr><td>Notify user*</td><td>Boolean</td><td>Add a note to the Bond and, if the Integration permits, the target record.</td></tr><tr><td>Transaction state**</td><td>Choice</td><td>Override the Transaction State on the Transaction.</td></tr><tr><td>Process state**</td><td>Choice</td><td>Override the Process State on the Transaction.</td></tr><tr><td>Request state**</td><td>Choice</td><td>Override the Request State on the HTTP Request.</td></tr><tr><td>Run script***</td><td>Boolean</td><td>The script to run when this action is executed.</td></tr></tbody></table>

{% hint style="info" %}
*^Retry*

When selected, an additional `Advanced retry` boolean type field becomes available (which if selected, also reveals another additional `Retry script` field in which to configure any scripted method of retrying).
{% endhint %}

{% hint style="info" %}
*\*Notify user*

When selected, an additional `Notify message` string type field becomes available in which to enter the required notification text.
{% endhint %}

{% hint style="info" %}
*\*\*Transaction/Process/Request state*

When *’–None–’* is selected, the state is left as is and not overridden.
{% endhint %}

{% hint style="info" %}
*\*\*\*Run script*

When selected, an additional `Script` field becomes available in which to configure any scripted method of executing the Response Action.
{% endhint %}

### Active

![](https://605238050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MfWt1gC0xYoLovMBuei%2F-MfX2_vRHBumPSo-jSie%2FResponse%20Action%203.png?alt=media\&token=37e87bc9-01cf-4e72-bb0e-7c856faa8f32)

The Active field can be configured for the Response Action record as follows:

<table><thead><tr><th width="150">Field</th><th width="150">Type</th><th width="436.2">Description</th></tr></thead><tbody><tr><td>Active</td><td>Boolean</td><td>Enable/Disable this action.</td></tr></tbody></table>

{% hint style="info" %}
This flag is actually set via the Enable/Disable buttons that are available on the editable action.
{% endhint %}

![](https://605238050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MfWt1gC0xYoLovMBuei%2F-MfXBHrH-f_S2d09s3x8%2FResponse%20Action%204.png?alt=media\&token=7bf04867-6fb9-4026-8460-1eaf92de7d2e)
