# HTTP

> Call any REST or GraphQL endpoint.

Built-in step · 1 step. Web page: https://docs.lodol.com/docs/integrations/built-in/http

To learn when to use these steps, with examples, read [Call an API or run code](https://docs.lodol.com/docs/guides/http-and-code.md).

## Steps

### Call an API

Call any REST or GraphQL endpoint that Lodol has no built-in step for. Set the method, URL, headers, query parameters, and body, and the response comes back ready for later steps to read. Store an API token as a workspace secret and reference it in a header to make an authenticated call.

**Inputs**

- URL (`url`, text, required): The full address to call, starting with https://. It can be built from workspace values, for example @values.BASE_URL followed by the path.
- Method (`method`, text): The HTTP method the endpoint expects. One of: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS`. Default: `GET`.
- Headers (`headers`, object): Headers to send, such as an Authorization header. Use a workspace secret for a token so it is never stored in the workflow.
- Query parameters (`query`, object): Values added to the end of the URL as a query string. Anything already written into the URL is kept.
- Body (`body`, object): What to send with the request, as JSON or a reference to a value from an earlier step. Leave it empty for a request that carries no body, such as a GET.
- Body format (`body_format`, text): How to encode the body. JSON suits most APIs, including GraphQL. Form sends it the way an HTML form would. One of: `json`, `form`, `text`, `none`. Default: `json`.
- Response format (`response_format`, text): How to read what comes back. Auto follows the response's own content type, so JSON becomes an object and a download becomes a file. One of: `auto`, `json`, `text`, `file`. Default: `auto`.
- Error responses (`on_error`, text): What an error status (a 404, a 500) means for this step. Treating it as a result lets later steps check the status themselves, which suits a 404 that just means not found. A request that gets no answer at all still fails the step; the step's own "If this step fails" setting decides what happens then. One of: `fail` (Fail the step), `continue` (Treat them as results). Default: `fail`.

**Outputs**

- `body` (object)
- `headers` (object)
- `ok` (true/false)
- `status` (number)
- `url` (text)

**Example output**

```json
{
  "body": {},
  "headers": {},
  "ok": true,
  "status": 1,
  "url": "example_value"
}
```
