---
title: "How to get API data with send_request"
description: "Configure a Send Request node, map fields from a JSON response to scenario variables, and verify the successful and error paths."
---

# How to Get Data from API Using send_request

The `send_request` action allows getting data from external APIs and processing the response in a scenario. This is useful for getting exchange rates, weather, order information from CRM, and other data.

> **Scenario secrets:** if your instance administrator enabled saved secrets, insert authentication and secret fields into the Send Request URL, headers, or body (**Insert credential field**, **Insert auth header**). See [manage scenario secrets](/en/settings/how-to/manage-action-credentials.md) and [secrets in Send Request](/en/scenariobuilder/how-to/use-saved-credential-in-send-request.md).

---

## How Does Data Retrieval Work?

1. The `send_request` action sends an HTTP request to the specified URL
2. Receives a response in JSON format
3. Processes the response through `response_mapping` or saves it in state
4. Data becomes available in the scenario through placeholders

---

## Processing JSON Object in Response

### Example 1: Getting a Task Title

**Configuration:**

```json
{
  "url": "https://jsonplaceholder.typicode.com/todos/1",
  "method": "GET",
  "response_mapping": {
    "title": "task_title"
  }
}
```

**Explanation:**
- `response_mapping` specifies which placeholder to write the response parameter to
- The API response field `title` will be available in the scenario as `{{task_title}}`.

**Usage in scenario:**

After the request completes, use `{{task_title}}` in subsequent scenario nodes. JSONPlaceholder is a public test API; use your own controlled endpoint in production.

---

## Processing Array of Objects in Response

### Example 2: Getting Exchange Rates

**Configuration:**

```json
{
  "url": "https://api.privatbank.ua/p24api/pubinfo?json&exchange&coursid=5",
  "method": "GET",
  "response_mapping": {
    "list_obj": {
      "text": "{{ccy}}/{{base_ccy}}",
      "value": "{{buy}}"
    }
  },
  "save_mapped_list_obj": "currency_mapped_obj"
}
```

**Configuration explanation:**

- `list_obj` — indicates that we are processing an array of objects
- `text` — text that will be displayed (can contain placeholders from API response)
- `value` — value that will be saved when selected (can contain placeholders from API response)
- `save_mapped_list_obj` — variable name where the processed array will be saved

**Example API response:**

```json
[
  {
    "ccy": "USD",
    "base_ccy": "UAH",
    "buy": "36.56860"
  },
  {
    "ccy": "EUR",
    "base_ccy": "UAH",
    "buy": "40.20000"
  }
]
```

**Processing result:**

After processing, `currency_mapped_obj` will contain:

```json
[
  {
    "text": "USD/UAH",
    "value": "36.56860"
  },
  {
    "text": "EUR/UAH",
    "value": "40.20000"
  }
]
```

**Usage in "List" block:**

In the "List" block, specify variable `{{currency_mapped_obj}}` as the data source. The block will receive exchange rate data and display them as buttons.

**Using selection result:**

After the user selects a currency, you can use the result in the scenario, for example, to display the currency rate.

---

## Saving Unprocessed Request Result

If you add the `save_responce` configuration parameter to the `send_request` block, the request execution result will be written to state in the variable:

```json
{
  "url": "https://api.example.com/data",
  "method": "GET",
  "save_responce": "currency_arr"
}
```

After executing the request, the entire JSON response will be available in the `{{currency_arr}}` variable for further processing through action jail or other mechanisms.

---

## Error Handling

If the API request ended with an error:

- Action returns `"not_ok"`
- `response_mapping` is not executed
- `save_responce` is not saved

In the scenario, you can handle the `"not_ok"` event for:

- Retry
- Sending a message to the user
- Using a backup data source

---

## Limitations

- `response_mapping` works only with successful responses (HTTP 200)
- Maximum response size is limited by system settings
- Complex nested structures may require additional processing through action jail

---

## Related Articles

- [Send data via send_request](/en/integrations/how-to/data-transfer/send-data-via-send-request.md)
- [Manage scenario secrets](/en/settings/how-to/manage-action-credentials.md)
- [Credential in Send Request](/en/scenariobuilder/how-to/use-saved-credential-in-send-request.md)
- [What are integrations](/en/integrations/explanation/what-are-integrations.md)
