> ## Documentation Index
> Fetch the complete documentation index at: https://noorle.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP Client

> Make HTTP requests to APIs and web services. Full authentication support and header control.

HTTP Client provides direct access to HTTP/HTTPS endpoints. Make requests to APIs, retrieve data, and interact with web services.

## Key Features

* **All HTTP Methods** - GET, POST, PUT, PATCH, DELETE
* **Authentication** - Bearer tokens, OAuth 2.0, Basic auth, custom headers
* **Headers Control** - Set custom headers, manage cookies
* **Body Support** - JSON, form data, raw text
* **Error Handling** - Response status codes, error messages
* **Timeout** - 30-second timeout with retry capability

## How to Enable

### For Agents

1. **Agents** > Select Agent > **Settings** > **Capabilities**
2. Attach **HTTP Client**

### For MCP Gateways

1. **Gateways** > Select Gateway > **Capabilities**
2. Attach **HTTP Client**

## Usage Examples

### Simple GET Request

```
GET https://api.example.com/users/123
```

Response:

```json theme={null}
{
  "id": 123,
  "name": "Alice",
  "email": "alice@example.com"
}
```

### POST with JSON Body

```
POST https://api.example.com/users
Content-Type: application/json

{
  "name": "Bob",
  "email": "bob@example.com"
}
```

### Bearer Token Authentication

```
GET https://api.example.com/profile
Authorization: Bearer sk-abc123def456...
```

### Custom Headers

```
GET https://api.example.com/data
Authorization: Bearer {token}
X-Custom-Header: value
Accept: application/json
```

## Authentication Methods

### No Authentication

```
GET https://api.example.com/public-data
```

### Bearer Token

```
Authorization: Bearer token-here
```

### Basic Authentication

```
Authorization: Basic base64(user:pass)
```

### Custom Headers

```
X-API-Key: your-api-key
X-Auth-Token: your-token
```

### OAuth 2.0

Handled via Connector authentication. For raw OAuth, include Authorization header with token.

## Request Methods

<Tabs>
  <Tab title="GET">
    Retrieve data

    ```
    GET /api/users
    ```
  </Tab>

  <Tab title="POST">
    Create resource

    ```
    POST /api/users
    Content-Type: application/json

    {"name": "Alice"}
    ```
  </Tab>

  <Tab title="PUT">
    Replace resource

    ```
    PUT /api/users/123
    Content-Type: application/json

    {"name": "Bob"}
    ```
  </Tab>

  <Tab title="PATCH">
    Partial update

    ```
    PATCH /api/users/123
    Content-Type: application/json

    {"email": "bob@example.com"}
    ```
  </Tab>

  <Tab title="DELETE">
    Remove resource

    ```
    DELETE /api/users/123
    ```
  </Tab>
</Tabs>

## Response Handling

All responses return:

```json theme={null}
{
  "status_code": 200,
  "headers": {
    "content-type": "application/json",
    "x-rate-limit": "100"
  },
  "body": {
    "data": "..."
  },
  "error": null
}
```

### Status Codes

| Code | Meaning      | Retry       |
| ---- | ------------ | ----------- |
| 2xx  | Success      | N/A         |
| 3xx  | Redirect     | Automatic   |
| 4xx  | Client error | No          |
| 5xx  | Server error | Yes (retry) |

## Resource Limits

| Limit         | Value       | Notes                         |
| ------------- | ----------- | ----------------------------- |
| Request Body  | 2MB         | Maximum size                  |
| Response Body | 2MB         | Maximum size                  |
| Timeout       | 30s default | Min 1s, max 300s configurable |
| Rate Limit    | 1,000/min   | Per user                      |
| Max Redirects | 10          | Per request chain             |

## Configuration

Optional gateway specifications:

```json theme={null}
{
  "http_client": {
    "timeout_seconds": 30,
    "follow_redirects": true,
    "verify_ssl": true,
    "max_body_size": 25000000
  }
}
```

## Common Use Cases

### Fetch Data from API

```
GET https://api.example.com/data?limit=10
Authorization: Bearer {token}
```

### Submit Form

```
POST https://forms.example.com/submit
Content-Type: application/json

{
  "name": "John",
  "email": "john@example.com"
}
```

### Update Remote Resource

```
PATCH https://api.example.com/items/5
Authorization: Bearer {token}
Content-Type: application/json

{
  "status": "completed"
}
```

### Webhook Integration

```
POST https://your-webhook.example.com/events
Content-Type: application/json

{
  "event": "agent_completed",
  "timestamp": "2025-03-20T10:00:00Z"
}
```

## Error Handling

If request fails:

```json theme={null}
{
  "status_code": 0,
  "body": null,
  "error": {
    "type": "timeout",
    "message": "Request exceeded 30-second timeout"
  }
}
```

### Common Errors

| Error               | Cause               | Solution                         |
| ------------------- | ------------------- | -------------------------------- |
| timeout             | Request too slow    | Simplify request, use pagination |
| connection\_refused | Service down        | Check endpoint URL               |
| ssl\_error          | Certificate issue   | Verify SSL settings              |
| invalid\_json       | Response not JSON   | Check Content-Type header        |
| auth\_failed        | Invalid credentials | Verify token/key                 |

## Cost

For current pricing details, see [Pricing](https://noorle.com/pricing/).

Monitor in **Account** > **Usage** dashboard.

## Best Practices

### Use Correct Content-Type

```
Content-Type: application/json      # For JSON
Content-Type: application/x-www-form-urlencoded  # For forms
Content-Type: text/plain            # For text
```

### Check Response Status

Always verify `status_code` before processing response.

### Handle Rate Limiting

If you receive `429 Too Many Requests`, wait before retrying.

### Validate URLs

Ensure URLs are HTTPS and properly formatted.

### Use Pagination

For large datasets, use pagination to avoid timeouts.

## Troubleshooting

### "Connection Refused"

* Check API endpoint is correct and online
* Verify firewall allows outbound HTTPS
* Try different endpoint if available

### "SSL Certificate Error"

* URL should use HTTPS, not HTTP
* Verify certificate is valid
* Check server configuration

### "Timeout"

* Request taking too long (>30 seconds)
* Simplify request or add pagination
* Check server performance

### "Authentication Failed"

* Verify token/key is correct
* Check token hasn't expired
* Ensure correct authentication method

## Next Steps

* [Files - Store Results](/use/capabilities/files)
* [Code Runner - Process Data](/use/capabilities/code-runner)
* [REST Connectors - Reusable APIs](/use/connectors/rest-connectors)
