---
title: HTTP GET and POST
source: https://docs.newrelic.com/docs/workflow-automation/workflow-examples/basic-patterns/http-get-post
---

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

    ```yaml
      name: http_get_example

      workflowInputs:
        apiUrl:
          type: String
          defaultValue: 'https://api.example.com/data'

      steps:
        - name: fetchData
          type: action
          action: http.get
          version: 1
          inputs:
            url: ${{ .workflowInputs.apiUrl }}
            headers: '{"Authorization": "Bearer ${{ :secrets:api_token }}"}'
            urlParams: '{"filter": "active", "limit": "10"}'
            selectors:
              - name: status
                expression: .statusCode
              - name: data
                expression: .responseBody | fromjson

        - name: logResponse
          type: action
          action: newrelic.ingest.sendLogs
          version: 1
          inputs:
            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

    ```yaml
      name: http_post_example

      workflowInputs:
        webhookUrl:
          type: String
        alertMessage:
          type: String

      steps:
        - name: sendNotification
          type: action
          action: http.post
          version: 1
          inputs:
            url: ${{ .workflowInputs.webhookUrl }}
            headers: '{"Content-Type": "application/json"}'
            body: '{"event": "alert_triggered", "message": "${{ .workflowInputs.alertMessage }}", "severity": "high"}'
            selectors:
              - name: httpStatus
                expression: .statusCode
              - name: response
                expression: .responseBody

        - name: logResult
          type: action
          action: newrelic.ingest.sendLogs
          version: 1
          inputs:
            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`

## Related topics [#related-topics]

[JSON parsing](https://docs.newrelic.com/docs/workflow-automation/workflow-examples/basic-patterns/json-parsing)

Parse and transform HTTP responses

[REST API polling](https://docs.newrelic.com/docs/workflow-automation/workflow-examples/integrations/rest-api-polling)

Build complete API integration workflows

[HTTP actions](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/actions-catalog)

Learn all HTTP action parameters
