The `SET HEADER` keyword configures HTTP request headers for subsequent API calls, enabling authentication, content type specification, and custom headers.
---
## Syntax
```basic
SET HEADER "header-name", "value"
SET HEADER "header-name", ""
```
---
## Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| `header-name` | String | The HTTP header name (e.g., "Authorization") |
| `value` | String | The header value (empty string to clear) |
---
## Description
`SET HEADER` configures headers that will be sent with subsequent HTTP requests (GET, POST, PUT, PATCH, DELETE HTTP). Headers persist until explicitly cleared or the script ends.
Common uses include:
- Setting authentication tokens
- Specifying content types
- Adding API keys
- Setting custom request identifiers
- Configuring accept headers
---
## Examples
### Basic Authentication Header
```basic
' Set Bearer token for API authentication
SET HEADER "Authorization", "Bearer " + api_token
' Make authenticated request
result = GET "https://api.example.com/protected/resource"
' Clear header when done
SET HEADER "Authorization", ""
```
### API Key Header
```basic
' Set API key in custom header
SET HEADER "X-API-Key", api_key
result = POST "https://api.service.com/data" WITH
query = user_query
SET HEADER "X-API-Key", ""
```
### Multiple Headers
```basic
' Set multiple headers for a request
SET HEADER "Authorization", "Bearer " + token
SET HEADER "Content-Type", "application/json"
SET HEADER "Accept", "application/json"
SET HEADER "X-Request-ID", request_id
result = POST "https://api.example.com/orders" WITH
product_id = "SKU-001",
quantity = 5
' Clear all headers
SET HEADER "Authorization", ""
SET HEADER "Content-Type", ""
SET HEADER "Accept", ""
SET HEADER "X-Request-ID", ""
```
### Content Type for Form Data
```basic
' Set content type for form submission
SET HEADER "Content-Type", "application/x-www-form-urlencoded"
result = POST "https://api.legacy.com/submit", form_data
`SET HEADER` configures HTTP headers for API requests. Use it to add authentication tokens, specify content types, and include custom headers. Always clear sensitive headers after use and store credentials securely in Vault rather than hardcoding them. Headers persist until explicitly cleared, so you can set them once for multiple related requests.