# Connecting to outside services and taking payment

> Set up a connection so a function can call an outside service, receive that service's events through a webhook, and build payment from the two.

A connection tells your app how to reach an outside service. A webhook lets that service reach your app. One connection can do both. Use them to look something up in another service, react to its events, or take payment.

Connections are on for every self-service app. RADP can close them on one workspace, and the Connections screen then says so. Find them under Build, **Connections**.

## What a connection holds

- **An address.** It must be `https://` on a public host name. A function can only ever call that host.
- **How it signs in.** None, a bearer token, a named header, basic sign-in or a query value.
- **Fixed headers**, such as an API version. These are not secret.
- **A webhook**, if the service sends events to your app.

A workspace holds at most 20 connections.

### Secrets

Secrets are kept apart from the connection. You set them on the Connections screen: one for signing in and one for checking webhooks. They are encrypted, and nobody can read them back: not you, not Rad Bot, not a function. You can replace one at any time.

### Sandbox and live

Each environment has its own connections. They are never promoted, so your sandbox can use a provider's test account and the live environment its real one. After you promote your app, set up the same connection id on the live environment. See [Your app's sandbox and live environments](/docs/app-builder/sandbox-and-live-environments).

## Call a service from a function

Ask Rad Bot, for example: "Add a connection to our geocoding service and a function that looks up a place." Rad Bot proposes the connection and the function.

To call a connection, a function lists its id under `connections` (at most 5 ids) and is written as `run(input, ctx)`. It calls the service with `ctx.http.get`, `post`, `put`, `patch` or `delete`. Each takes `query=`. `post`, `put` and `patch` also take `json=` or `form=`.

The answer has `ok`, `status`, and `json` or `text`. A `status` of 0 means the service could not be reached, and your function can handle that.

| Limit | Value |
| --- | --- |
| Calls per run | 5 |
| Time per call | 10 seconds |
| Size of an answer | 1 MB |
| Calls per month, per environment | 100,000 (5,000 during the trial) |

The Connections screen shows your monthly use. A call that leaves counts whatever it answers. Past the monthly limit a run fails with a message saying when it resets. Ask RADP if your app needs more. Tests never count.

Other rules:

- Redirects are not followed, and addresses inside a private network are refused.
- A call is made once per run.
- Function tests never call out. Each test gives the answer with an `http` fixture.
- **Try it** as a dry run only sends GET calls, because the other kinds may have real effects.
- Run history shows which connection was called and how it answered, never the content.

## Receive a webhook

1. Create or open the connection and set its webhook: the function to run, and how the service signs its events (Paddle, Stripe, or HMAC-SHA256 with the header name).
2. Set the webhook secret.
3. Give the service the webhook address shown on the screen.

A request without a valid signature is refused and leaves nothing behind. An event is a JSON object of at most 60 KB. A valid event is queued and answered at once. Then your function runs with `{event, connection}` as its input. It runs as the system, within its declared access, and must have passed its tests.

Each event runs once, however often the service sends it. If your function fails, the service is not asked to retry. Look in the function's run history.

## Take payment

There is no separate payment feature. You stay the seller, on your own provider account. Build it from a connection, a webhook and functions:

1. A function works out the price itself, never from what the person sent, and creates a pending order.
2. It creates a checkout with your provider through a connection and returns the address.
3. Your webhook function checks the amount against the order and marks it paid.
4. An automation on the paid order delivers what was bought. See [Running a function when records change](/docs/app-builder/automations-and-run-function-step).

Rad Bot knows this recipe. Ask it to build one for your app.

Source: https://radp.io/docs/app-builder/connections-and-webhooks
Last updated: 2026-12-01
