> For the complete documentation index, see [llms.txt](https://tekos.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tekos.gitbook.io/doc/building-apps-1/building-apps/http-and-rest-connections.md).

# HTTP Requests

Basic explanation of HTTP Requests in the tekos flow.

Now days all apps use the HTTP Requests and we either, our whole ecosystem is based on the requests.

In this tutorial we are going to showcase some example usage of the requests in the flow.&#x20;

The Tekos Flow comes with three basic HTTP nodes which are:

1. **HTTP Request** - Sends HTTP requests and returns the response.
2. **HTTP In** - Creates an HTTP end-point for creating web services.
3. **HTTP Response** - Sends responses back to requests received from an HTTP Input node

It is possible to even create web pages using the tekos flow.

{% hint style="info" %}
Remember to check the HELP tab of the HTTP nodes in the flow editor.  <img src="https://2146957470-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSqSDdProPIpKBElfLq%2F-MRU7GWbbG3cccw3q8zA%2F-MRUaK4Fs1H2EaYr0uGC%2Fimage.png?alt=media&amp;token=72ef7566-7670-4d1d-bb0f-25dd20f33fc1" alt="" data-size="original">&#x20;
{% endhint %}

#### List of available HTTP Methods:&#x20;

| **Method** | Description                                                                                                                             |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| GET        | The `GET` method requests a representation of the specified resource. Requests using `GET` should only retrieve data.                   |
| HEAD       | The `HEAD` method asks for a response identical to that of a `GET` request, but without the response body.                              |
| POST       | The `POST` method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server. |
| PUT        | The `PUT` method replaces all current representations of the target resource with the request payload.                                  |
| DELETE     | The `DELETE` method deletes the specified resource.                                                                                     |
| CONNECT    | The `CONNECT` method establishes a tunnel to the server identified by the target resource.                                              |
| OPTIONS    | The `OPTIONS` method is used to describe the communication options for the target resource.                                             |
| TRACE      | The `TRACE` method performs a message loop-back test along the path to the target resource.                                             |
| PATCH      | The `PATCH` method is used to apply partial modifications to a resource.                                                                |

## Using HTTP In & HTTP Response

Both of those nodes are often necessary to properly configure an endpoint

Let's create an POST endpoint in my flow to adres /tekos/documentation that just responses with payload  "It's working!" and code  200 - OK.

{% hint style="info" %}
Check the full list of available response codes\
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Status>
{% endhint %}

![](https://2146957470-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSqSDdProPIpKBElfLq%2F-MRU7GWbbG3cccw3q8zA%2F-MRUUxtvaq97EqYJ2HPd%2Fimage.png?alt=media\&token=025e6632-4e72-42f4-8a78-3c704c8e4aa5)

Above endpoint will be available under my flow instance adres \
"<https://instance-name.tekos.co/tekos/documentation>"

## Using HTTP Request

This node allows you to do a HTTP Request to any service endpoint. We can use our previously created one using the HTTP In & HTTP Response, but let's use function node instead of change, and in this function we will enter simple command to iterate the number stored in the payload.&#x20;

```javascript
msg.payload++
return msg;
```

While we have our endpoint prepared let's create an flow with POST Request

![](https://2146957470-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSqSDdProPIpKBElfLq%2F-MRU7GWbbG3cccw3q8zA%2F-MRUYRGA2F0boph1YdbX%2Fimage.png?alt=media\&token=f54aa827-7b1c-4b0e-a092-67ccd8ad130f)

As you can see we have an inject node to manually trigger the request, an function node, http request and a debug node, don't mind the change node it is just to hide my instance name.&#x20;

{% code title="Function node" %}

```javascript
msg.url = "https://instance-name.tekos.co/tekos/documentation"
msg.headers ={
    "Content-type": "application/json"
}
msg.payload = 10
return msg;
```

{% endcode %}

We have also set the msg.payload value to 10, while our endpoint have a function to iterate the msg.payload so the response from this endpoint should be 11. Let's take a look

![Example HTTP Request with response](https://2146957470-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSqSDdProPIpKBElfLq%2F-MRU7GWbbG3cccw3q8zA%2F-MRU_A7lyHepj-eJh8km%2FHTTP%20REquest.gif?alt=media\&token=5319d9e3-c0bb-4343-8d9e-311bf575afd7)

Of course this is just a basic example of how to create endpoint and send an http request to it.&#x20;
