> 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.

![](https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FQRLsVdWvcuh5ymDaBqNT%2Funknown.png?alt=media\&token=976da29b-d46f-4b8f-8980-78fd745df004)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
