Learn how to make HTTP requests in workflows to interact with REST APIs and external services.
Requirements:
- Target API endpoint URLs
- Any required authentication credentials (API keys, tokens, etc.)
- Understanding of the API request/response formats
Fetch and process data
Fetch data from REST API endpoints. Headers and URL parameters must be stringified JSON.
What this workflow does:
Perform HTTP GET call to retrieve data from an API endpoint
Use selectors to extract status code and response data
Log API response status to New Relic
name: http_get_exampleworkflowInputs:apiUrl:type: StringdefaultValue: 'https://api.example.com/data'steps:- name: fetchDatatype: actionaction: http.getversion: 1inputs:url: ${{ .workflowInputs.apiUrl }}headers: '{"Authorization": "Bearer ${{ :secrets:api_token }}"}'urlParams: '{"filter": "active", "limit": "10"}'selectors:- name: statusexpression: .statusCode- name: dataexpression: .responseBody | fromjson- name: logResponsetype: actionaction: newrelic.ingest.sendLogsversion: 1inputs:logs:- message: 'API returned status: ${{ .steps.fetchData.outputs.status }}'attributes:responseData: ${{ .steps.fetchData.outputs.data }}
Key actions: http.get, newrelic.ingest.sendLogs
Send data to external systems
Send data to webhooks, APIs, or notification services. Headers must be stringified JSON, body must be a string.
What this workflow does:
Perform HTTP POST call to send data to an API endpoint
Use selectors to extract HTTP status and response
Log webhook response status to New Relic
name: http_post_exampleworkflowInputs:webhookUrl:type: StringalertMessage:type: Stringsteps:- name: sendNotificationtype: actionaction: http.postversion: 1inputs:url: ${{ .workflowInputs.webhookUrl }}headers: '{"Content-Type": "application/json"}'body: '{"event": "alert_triggered", "message": "${{ .workflowInputs.alertMessage }}", "severity": "high"}'selectors:- name: httpStatusexpression: .statusCode- name: responseexpression: .responseBody- name: logResulttype: actionaction: newrelic.ingest.sendLogsversion: 1inputs:logs:- message: 'Webhook returned status: ${{ .steps.sendNotification.outputs.httpStatus }}'
Common use cases:
- Trigger deployments via CI/CD webhooks
- Send data to ticketing systems (Jira, ServiceNow)
- Post to custom notification services
- Integrate with third-party APIs
Key actions: http.post, newrelic.ingest.sendLogs
What's next
- JSON parsing: Parse JSON responses with selectors
- Data passing: Pass data between workflow steps