Skip to content
Reference

Adapter: Generic REST API

Connect to any REST API with custom configuration.

On this page

Purpose

Call any HTTP API: GET, POST, PUT, PATCH and DELETE with a body built from the step or its input. It also sends outbound webhooks.

Auth

  • none, basic, bearer, apikey (a header, X-API-Key by default), oauth2 or oauth2-private-key-jwt. Both OAuth2 types use the client credentials grant, cache the token until it expires, and fetch a new one once after a 401. See OAuth2.
  • It takes the shared connection options: a client certificate for mutual TLS, a private CA, a minimum TLS version and a proxy. They apply to its token requests too.

Settings

Auth is chosen with authType: none, basic, bearer, apikey, oauth2, oauth2-private-key-jwt (default none). Dotted names are fields inside an object setting. Secret settings are encrypted at rest, never returned by a read, and shown masked in the console and in exports; their defaults are not shown.

SettingTypeRequiredDefaultSecretDescription
baseUrlurlYesNoAPI base URL.
authTypeenum: none, basic, bearer, apikey, oauth2, oauth2-private-key-jwtNononeNoAuthentication method. oauth2: client credentials with a client secret. oauth2-private-key-jwt: client credentials with a client assertion signed by your private key (RFC 7523).
credentialsobjectNo
credentials.usernamestringNoNoUsed when authType is basic.
credentials.passwordstringNoYesUsed when authType is basic.
credentials.tokenstringNoYesUsed when authType is bearer.
credentials.apiKeystringNoYesUsed when authType is apikey.
credentials.apiKeyHeaderstringNoX-API-KeyNoUsed when authType is apikey.
credentials.clientIdstringNoNoUsed when authType is oauth2 or oauth2-private-key-jwt.
credentials.clientSecretstringNoYesUsed when authType is oauth2.
credentials.tokenUrlurlNoNoUsed when authType is oauth2 or oauth2-private-key-jwt.
credentials.scopesstringNoNoUsed when authType is oauth2 or oauth2-private-key-jwt.
credentials.privateKeyPEMstringNoYesPEM RSA private key that signs the client assertion (oauth2-private-key-jwt). Used when authType is oauth2-private-key-jwt.
credentials.keyIdstringNoNokid of the registered public key (oauth2-private-key-jwt). Used when authType is oauth2-private-key-jwt.
oauth2ClientAuthenum: client_secret_basic, client_secret_postNoNooauth2: how the client secret reaches the token endpoint. client_secret_basic (default): an Authorization header. client_secret_post: in the form body. Used when authType is oauth2.
oauth2AudiencestringNoNooauth2: the audience parameter of the token request (Auth0, Okta). Used when authType is oauth2 or oauth2-private-key-jwt.
oauth2ResourcestringNoNooauth2: the resource parameter of the token request (RFC 8707, Azure AD v1). Used when authType is oauth2 or oauth2-private-key-jwt.
oauth2AssertionAlgorithmenum: RS384, RS256NoNooauth2-private-key-jwt: the client assertion's signing algorithm (default RS384). Used when authType is oauth2-private-key-jwt.
defaultContentTypestringNoNoContent-Type for writes when the step sets none (default: text/plain for a string body, else application/json).
defaultHeadersmapNoYesDefault headers for all requests.
timeoutnumberNo30000NoRequest timeout in milliseconds.
correlationHeaderstringNoX-Request-IdNoHeader that carries the run's correlation id: the inbound x-request-id, else the execution id. Empty: none.
signDeliveriesbooleanNotrueNoSign each request (Standard Webhooks: webhook-id, webhook-timestamp, webhook-signature) so the receiver can verify it came from this engine. Applies once the profile has a signing secret.
signingSecretstringNoYeswhsec_ signing secret. Leave empty to have one generated when you save; it is shown once.
tlsCaPemstringNoYesPEM CA certificate(s) to verify the server against. See tlsCaMode.
tlsCaModeenum: replace, addNoNoTrust: replace = only this CA (default), add = the system CAs plus this CA. Needs tlsCaPem.
tlsClientCertPemstringNoYesPEM client certificate, for servers that require mutual TLS. Set with tlsClientKeyPem.
tlsClientKeyPemstringNoYesPEM private key for the client certificate (encrypted at rest).
tlsClientPfxstringNoYesClient certificate and key as a base64 PKCS#12 (.p12 / .pfx) bundle, instead of the PEM pair.
tlsClientPassphrasestringNoYesPassphrase of the PKCS#12 bundle.
tlsMinVersionenum: TLSv1.2, TLSv1.3NoNoLowest TLS version to accept (default TLSv1.2).
proxyUrlurlNoNoHTTP(S) proxy, e.g. http://proxy.example.test:3128 (opens in a new tab). The proxy host must pass the SSRF rules (SSRF_ALLOWLIST for a private one).
proxyUsernamestringNoNoProxy user (Basic auth).
proxyPasswordstringNoYesProxy password.
noProxyarray of stringNoNoHosts sent direct, not through the proxy: a name (and its subdomains), .suffix, host:port or *.

Actions

A trailing ? marks an optional step parameter. A message can supply only the keys in the last column; everything else comes from the step.

ActionWhat it doesStep parametersKeys a message may supply
getHTTP GET request.endpoint?, query?, headers?, response?, answerStatuses?, urlTemplate?, pagination?None
postHTTP POST request.endpoint?, body?, headers?, response?, answerStatuses?, urlTemplate?, contentType?body
putHTTP PUT request.endpoint?, body?, headers?, response?, answerStatuses?, urlTemplate?body
deleteHTTP DELETE request.endpoint?, headers?, response?, answerStatuses?, urlTemplate?None
patchHTTP PATCH request.endpoint?, body?, headers?, response?, answerStatuses?, urlTemplate?body

Minimal example

The smallest profile the engine accepts: the required settings only, with synthetic values. Create it with POST /api/adapter-profiles, then test it with POST /api/adapter-profiles/{id}/test.

json
{
  "name": "Generic REST API (example)",
  "adapterType": "generic-rest",
  "config": {
    "baseUrl": "https://generic-rest.example.test/base"
  }
}

OAuth2

Both OAuth2 auth types post grant_type=client_credentials to credentials.tokenUrl and send the API the token as Authorization: Bearer.

SettingWhat it does
oauth2ClientAuthoauth2 only. client_secret_basic (default) sends the client id and secret as an HTTP Basic header; client_secret_post sends them in the form body.
oauth2AudienceSends audience, which Auth0 and Okta custom authorization servers need to issue a token for your API.
oauth2ResourceSends resource (RFC 8707; Azure AD v1 and ADFS).
credentials.scopesSends scope. Azure AD v2 wants <application id URI>/.default.
oauth2AssertionAlgorithmoauth2-private-key-jwt only. RS384 (default, as SMART Backend Services) or RS256 (Azure AD, Okta).

private_key_jwt. With oauth2-private-key-jwt the profile has no client secret. The engine signs an RFC 7523 client assertion with credentials.privateKeyPEM, as the FHIR REST adapter's backend services auth does: iss and sub are the client id, aud is the token URL, it expires after 5 minutes and has a unique jti, and credentials.keyId is its kid header when set. The request carries client_id, client_assertion_type (urn:ietf:params:oauth:client-assertion-type:jwt-bearer) and client_assertion. Register the matching public key, or a JWKS URL that serves it, with the authorization server.

The client secret and the private key are in the encrypted credentials and go only to the token URL, which passes the same SSRF check as the base URL. A failed token request names the endpoint's OAuth error, never the secret, the key or the token, and fails the step before anything reaches the API, so it is retried. A token is cached per profile settings, so two profiles that differ in audience, resource, scope or client authentication never share one.

URL templates

A step can build its URL from the message with urlTemplate, in place of endpoint. Reads (get) and writes (post, put, patch, delete) take one.

json
{ "action": "put", "config": { "urlTemplate": "/appointments/{{data.id}}" } }

With baseUrl https://scheduling.example.test/api/v1 and a step input { "id": "APT-1001", ... }, the step sends PUT https://scheduling.example.test/api/v1/appointments/APT-1001 with the input as the body.

PlaceholderValue
{{data.PATH}}A field of the step's input, such as {{data.patient.mrn}} or {{data.ids[0]}}.
{{channel.KEY}}A channel map value an earlier JavaScript step set ($c, channelMap, vars).
{{sender.KEY}}A per-sender setting.
{{env.NAME}}A workspace variable. At the very start of the template it is the base URL.
{{cursor}}Reads only: the polling trigger's cursor, or the next cursor of cursor pagination.

The rules:

  • Each value is encoded for where it lands. A path value is one segment: /, ?, # and & are escaped, and . or .. are refused. A query value is one parameter value.
  • A relative template starts with / or ? and follows baseUrl. An absolute template must end its host before the first placeholder. No value can change the host.
  • The SSRF check runs on the final URL, and on every redirect.
  • A missing path value fails the step without sending anything, and the error names the placeholder, never the data. A missing query value drops that parameter.
  • The template is the step's setting. A message can't set it.
  • Each templated call is in the audit log (adapter.rest.templated_read or adapter.rest.templated_write, with the method): the template as written, the placeholder names and the host, never the values. One entry per configuration per hour.

The response

A step's output is the response body: JSON when the Content-Type is application/json or any application/*+json (application/fhir+json, application/problem+json), text otherwise. A delete answered 204 outputs { "success": true }.

Set the step's response to full to output the status and headers too:

json
{
  "status": 201,
  "headers": {
    "content-type": "application/fhir+json",
    "location": "/api/v1/appointments/CONF-1"
  },
  "body": { "id": "CONF-1", "status": "booked" }
}
  • A condition step can then branch on the status, such as data.status === 201 (booked) or data.status === 202 (queued), and a later step can read {{data.headers.location}} in its URL template.
  • Header names are lower-case. Credential headers, such as set-cookie or a token, read [redacted], as in the Delivered tab.
  • An empty body is null.
  • A status outside 200-299 still fails the step, so retries and the error path work as before.
  • The setting is the step's: a message can't set it. A paginated read outputs its items, so it refuses full.
  • A write step after it that has no body of its own sends the body field of this output (a message may supply body).

Correlation id

Each request a workflow step sends carries the run's correlation id in the profile's correlationHeader, X-Request-Id by default, so your team and the API's team can find the same call.

  • For a run started by an HTTP request (a webhook), it is that request's x-request-id: the sender's own, or the one the engine gave the request and answered in its X-Request-ID header. Otherwise (MLLP, a schedule, a poll, a manual run) it is the execution id. A step's retries keep it, and a replay of a webhook run keeps the request's id.
  • An inbound value that is not a plain id (letters, digits and . _ : @ / + = -, at most 128 characters) is replaced with the execution id.
  • Set correlationHeader to another name, such as X-Correlation-ID, or to an empty string to send none. A header the step or profile sets under that name wins.
  • The token request of an OAuth2 profile does not carry it.
  • The Delivered tab shows it as Correlation id on each request, to viewers too, and each call writes a log line ("Generic REST call") with correlationId, the method, the host and the status, never the path.

Signed requests

A profile can sign every request it sends, following Standard Webhooks (opens in a new tab), so the receiver can check that the request came from your engine and was not changed or replayed.

Each signed request carries three headers:

HeaderValue
webhook-idThe message id. A write uses its Idempotency-Key, so a retry of the same step for the same message keeps the same id. Other requests get a new msg_... id.
webhook-timestampUnix time of this attempt, in seconds.
webhook-signaturev1, and the base64 HMAC-SHA256 of <webhook-id>.<webhook-timestamp>.<body>, keyed with the secret. A request with no body signs an empty body.

How to turn it on:

  • New profiles. New connection has Sign deliveries on, under More settings. Leave Signing secret empty and the engine generates one (whsec_ followed by base64) when you save, and shows it once. Copy it and give it to the receiver. No read returns it again.
  • Existing profiles. Profiles saved before signing existed do not sign, so their receivers keep working. To start signing, call POST /api/adapter-profiles/{id}/signing-secret. It generates a secret, turns signing on and returns the secret once. Call it again to rotate: the old secret stops working at once.
  • Your own secret. Set signingSecret to a secret you and the receiver agreed on. A secret without the whsec_ prefix is used as plain text bytes and the save returns a warning, because Standard Webhooks libraries expect whsec_ and base64.
  • Off. Set signDeliveries to false. The stored secret is kept.

A step's headers cannot set or replace the three signature headers. Signing over http:// works, with a warning: the signature proves the sender, but the body is not encrypted.

Verify on the receiver

Use a Standard Webhooks library for your language, or check it yourself. This Node.js example verifies the raw body bytes, compares in constant time, and refuses a timestamp more than five minutes from now:

js
import { createHmac, timingSafeEqual } from "node:crypto";

// secret: the whsec_ value the engine showed you, from your secret store.
export function verifyMedHookRequest(secret, headers, rawBody) {
  const id = headers["webhook-id"];
  const timestamp = headers["webhook-timestamp"];
  const signatures = headers["webhook-signature"];
  if (!id || !timestamp || !signatures) return false;

  const now = Math.floor(Date.now() / 1000);
  if (Math.abs(now - Number(timestamp)) > 5 * 60) return false;

  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const expected = createHmac("sha256", key)
    .update(`${id}.${timestamp}.`)
    .update(rawBody)
    .digest();

  // The header can hold several space-separated "v1,<base64>" values.
  return signatures.split(" ").some((entry) => {
    const [version, value] = entry.split(",");
    if (version !== "v1" || !value) return false;
    const received = Buffer.from(value, "base64");
    return (
      received.length === expected.length && timingSafeEqual(received, expected)
    );
  });
}

Hash the bytes you received, not a re-serialized copy of the JSON. To reject a replayed request inside the five minutes, remember each webhook-id you accepted for that long and refuse a repeat.

Header and query values from the message

A step's headers and query values can use {{data.PATH}}, {{channel.KEY}} and {{sender.KEY}}, as a URL template does. A value with no placeholder is sent as written.

json
{
  "action": "get",
  "config": {
    "endpoint": "/appointments",
    "headers": { "X-Patient-Id": "{{data.patient.id}}", "X-Batch": "{{channel.batchId}}" },
    "query": { "mrn": "{{data.patient.mrn}}", "since": "{{channel.cursor}}" }
  }
}
  • A header value can't hold a line break (CR, LF or NUL): the step fails without sending, so a message can't add a header. A header whose value is missing fails the step, and the error names the placeholder, never the data.
  • A query value is URL-encoded into its own parameter, so & or = in the data stay inside it. A parameter whose value is missing is left out.
  • The placeholders are the step's settings; a message still can't set the headers or query themselves.
  • Keep PHI out of headers where you can: proxies and the receiving server may log them.

Limits

  • A write with no endpoint sends to baseUrl; with no body it sends the step's input. A string is sent as it is; an object is JSON, or form-encoded for application/x-www-form-urlencoded.
  • A write carries an Idempotency-Key that stays the same across retries of the step for the same message.
  • A message cannot set the endpoint, URL template, headers or method: only the body. Its fields reach the URL, headers and query only through the step's own placeholders.
  • The engine refuses a URL that resolves to a private address unless the host is in SSRF_ALLOWLIST (see Environment variables).

Reference