# API call (/docs/nodes/api-call)



The **API call** node reaches out to an HTTP service, such as a credit bureau or a pricing API, and brings the answer back as variables. Failures are not fatal unless you say so.

## When to use it [#when-to-use-it]

* Fetch data you do not hold: scores, exchange rates, customer profiles.
* Call a service that returns an answer the next rule needs.

## How it works [#how-it-works]

<Diagram node="api-call" kind="anatomy" />

1. The URL, headers and query are built. `{{customer_id}}` placeholders are replaced with values from the payload and variables. The body is built field by field from the body mapping.
2. The address is checked: private and blocked addresses are refused. The credential, if any, is resolved and added as a header.
3. The request is sent with the configured timeout and retries. An HTTP status of 400 or above counts as a failure.
4. The **response mapping** turns the answer into variables. It can read `response.status`, `response.headers`, `response.body` and `result` (the body).

## Ports [#ports]

| Port      | Taken when                                                                                                                                                 |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Success` | The service answered with a status below 400.                                                                                                              |
| `Error`   | The call failed and the node is set to continue with a fallback. If Error is not connected, the run carries on through Success with the fallback in place. |

## Configuration [#configuration]

| Field             | What it does                                                                   |
| ----------------- | ------------------------------------------------------------------------------ |
| Name              | Label shown on the canvas and in the trace.                                    |
| Method and URL    | GET, POST, PUT, PATCH or DELETE, and the address. Supports `{{placeholders}}`. |
| Headers and query | Key-value pairs. Values support placeholders.                                  |
| Authentication    | None, bearer, basic or API key header, using a stored credential.              |
| Body              | Each body field and the expression that fills it.                              |
| Response mapping  | Each variable and the expression that reads it from the answer.                |
| Store results in  | Optional variable that groups the mapped values. Blank writes them directly.   |
| Timeout           | Milliseconds to wait. Must be positive.                                        |
| Retries           | How many times to retry, and the back-off between attempts.                    |
| On error          | `fail` stops the run. `continue` writes a fallback value and goes on.          |

## What it writes [#what-it-writes]

The mapped values as variables (`vars.bureau.score`), or the fallback when the call failed and the node continues. The trace records the method, the address (secrets redacted), the status and the number of attempts.

## In a real flow [#in-a-real-flow]

<Diagram node="api-call" kind="example" />

A bureau score is fetched. Success goes to the output; if the call fails, the fallback lets the run go to a manual review instead of failing the whole decision.

## When it fails [#when-it-fails]

* With **fail**: the run stops with `UPSTREAM_FAILED` (network, timeout or HTTP 400+), `BLOCKED_URL` or `CREDENTIAL_NOT_FOUND`.
* With **continue**: the fallback is written and the **Error** port is taken, or Success when Error is not connected.
* No URL, a non-positive timeout or an authentication without credential are errors in Checks.

## Good to know [#good-to-know]

* A fallback should look like a real answer (`{ "score": 0 }`) so downstream rules do not have to special-case it.
* To send something out without waiting for the answer, use an [Action](/docs/nodes/action) instead.

## Related [#related]

* [Query](/docs/nodes/query)
* [Security](/docs/operate/security)
