Third-Party Integrations
Calling external APIs from blueprints, receiving webhooks, storing credentials safely, and keeping integrations alive.
Most integrations are one of two shapes: your blueprint calls their API, or their service calls yours (a webhook). RUAL handles both with the same primitives. This tutorial sets up a real one end to end and covers the operational rules that keep it healthy.
Outbound: Calling Their API
- Credentials first — store the API key/token as a secure system setting (e.g.
stripe_secret_key), never in the blueprint. Read it withget system setting— see custom keys. - Build the request with the http request blocks: URL, method, headers (auth from the setting), body from
object_new_fieldsor JSON. - Parse the response — map only the fields you need into your documents with
object_update_fields; don't mirror their whole payload. - Handle failure explicitly — success/error pins → log, retry via queue for transient errors (429/5xx), alert path for permanent ones. See error handling.
Many popular services have ready-made block groups (postmark, mailchimp, discord, twilio) — search the service name in the block library before building raw http requests.
Inbound: Receiving Webhooks
- Register an endpoint with
on_startup_register_uri_post— your public webhook URL ishttps://<cluster>/api/v1/<uri>. - Verify the sender — shared-secret signature header, HMAC check, or an unguessable URI segment. Treat every unverified payload as hostile.
- Reply fast (200 with a small ack), then do the real work in the queue — senders time out and retry otherwise, giving you duplicate events.
- Deduplicate by event id: store received ids, skip ones you've seen (webhooks retry).
Keeping Data in Sync
- Pull:
schedule_repeating_eventpolls their list endpoint on an interval and upserts by external id (update if exists, create if new — see Storages). - Push: react to local changes with storage events and forward them to the service.
- Conflict rule: pick one system of record per field and write it down in the flow's comments — two-way sync without it always corrupts something.
Operational Rules
- Rotate credentials by editing the system setting — every flow picks it up next run, no blueprint edits.
- Log every outbound call (endpoint, status, duration) during rollout; sample it later.
- Respect their rate limits with queue debounce instead of bursts.
- Build a tiny health check: a scheduled call that verifies the token still works, and alerts via your own email flow (Email System Setup).
