---
title: "n8n"
description: "Use APIBrasil in your n8n workflows through HTTP Request nodes. n8n is stateless, so our REST API is what powers the automation."
lang: en
canonical: https://doc.apibrasil.io/mcp/automacao/n8n
markdown: https://doc.apibrasil.io/mcp/automacao/n8n.md
source: apibrasil-documentation
---

# n8n

> Use APIBrasil in your n8n workflows through HTTP Request nodes. n8n is stateless, so our REST API is what powers the automation.

- **Category:** Automation
- **Difficulty:** Easy
- **Protocol:** calls the REST gateway over HTTP
- **Updated on:** January 14, 2026

## Prerequisites

- n8n installed (self-hosted or cloud)
- Basic knowledge of n8n workflows
- APIBrasil tokens

## Configuration

- **File:** `HTTP Request Node Configuration`

```json
{
  "method": "POST",
  "url": "https://gateway.apibrasil.io/api/v2/cep/cep",
  "authentication": "genericCredentialType",
  "genericAuthType": "httpHeaderAuth",
  "headers": {
    "Authorization": "Bearer {{$credentials.apibrasilBearer}}",
    "DeviceToken": "{{$credentials.apibrasilDevice}}",
    "Content-Type": "application/json"
  },
  "body": {
    "cep": "={{$json.cep}}"
  }
}
```

## Step by step

1. **Create credentials in n8n** — Go to Settings > Credentials > New and create a 'Header Auth' credential with your APIBrasil tokens
2. **Add an HTTP Request node** — In your workflow, add an HTTP Request node and set the method and URL
3. **Set up authentication** — Pick the credentials you created and set the headers the API needs
   ```text
   Authorization: Bearer SEU_TOKEN
   DeviceToken: SEU_DEVICE_TOKEN
   Content-Type: application/json
   ```
4. **Set the request body** — Fill the body with the parameters the API expects
   ```json
   {
     "cep": "={{$json.cep}}"
   }
   ```
5. **Test the workflow** — Run the workflow by hand to confirm the integration works
6. **Handle the response** — Add further nodes to work with the data APIBrasil returns

## Troubleshooting

- **401 Unauthorized** — Check the tokens in the n8n credentials. They must be active on the APIBrasil platform
- **CORS error** — Use the right endpoint: gateway.apibrasil.io (not the MCP server). The n8n backend has no CORS issues
- **The request times out** — Raise the timeout on the HTTP Request node to 30 seconds or more, especially for slower look-ups
- **The body never arrives** — Make sure Content-Type is set to application/json in the headers

## Related links

- [Official n8n documentation](https://docs.n8n.io)
- [The APIBrasil REST API](https://doc.apibrasil.io/apis.md)
- [Other automations](https://doc.apibrasil.io/mcp/automacao.md)
- [n8n templates with APIBrasil](https://doc.apibrasil.io/mcp/exemplos/n8n.md)

## See also

- MCP guide: [MCP guide](https://doc.apibrasil.io/mcp.md)
- Documentation index: https://doc.apibrasil.io/llms.txt
- HTML version of this page: https://doc.apibrasil.io/mcp/automacao/n8n
