> For the complete documentation index, see [llms.txt](https://docs.avoautomation.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avoautomation.com/avo-assure/actions/apis/assertion/status-code.md).

# Status code

This is a pre-built action available under **@Assertion** element type. This action validates the expected HTTP status code against the status code returned in the API response header. The dynamic variable stores the actual HTTP status code returned in the response header.

{% hint style="info" %}
**Note**: An API request must be added and executed successfully before configuring or evaluating API Assertions.
{% endhint %}

## Syntax

**Input Value**: `<Status code expected value>`

| Argument                                        | Description                                         |
| ----------------------------------------------- | --------------------------------------------------- |
| <p>Status code expected value<br>(Required)</p> | Provide the status code which you want to validate. |

**Output Value**: `<Actual value>(optional);<Keyword Status>(optional)`

| Argument                            | Description                                                       |
| ----------------------------------- | ----------------------------------------------------------------- |
| <p>Actual value<br>(optional)</p>   | The actual value variable stores the actual status code returned. |
| <p>Keyword Status<br>(optional)</p> | The keyword status variable stores the status as True or False.   |

### Example: Validating Status Code of API Response

In this example, we explain how to verify that the API response returns the expected HTTP status code.

* **Action**: Status code
* **Input Value**: 200
  * The value (**200**) specifies the expected HTTP status code to validate.
* **Output Value**: {actual\_result};{keyword\_status}
  * The first output variable **{actual\_result}** stores the actual HTTP status code (**200**) returned by the API.
  * The second output variable **{keyword\_status}** stores the verification result with the following possible values:
    * **True**: If the actual HTTP status code matches the expected status code.
    * **False**: If the actual HTTP status code does not match the expected status code.
* **Logical Explanation**: The Status code action fetches the expected HTTP status code from the Input Value column (**200**) and compares it with the actual status code returned by the API response. The actual status code (**200**) is stored in the **{actual\_result}** variable. If the **{keyword\_status}** variable is defined, it stores **True** when the expected and actual status codes match or **False** when they do not match.

![](/files/RP3J75DGy4wpYVUO4Ixa)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.avoautomation.com/avo-assure/actions/apis/assertion/status-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
