Skip to content

Practical guide

Keep third-party API secrets in backend workflows

Reference a Twidget global variable from a server-side HTTP request, separate development and production credentials and check responses for accidental disclosure.

1. Keep the credential out of the page

A private provider key belongs in the backend workflow that calls the provider, not a page variable, URL, form default or public JavaScript. Prepare a development workspace and a restricted provider test credential when you are ready to execute the integration. This guide uses only placeholders; do not paste a real credential into shared screenshots or test fixtures.

The frontend calls your protected endpoint. That endpoint validates the application request, authorizes the caller and performs the provider call. Start with an external HTTP workflow if you have not configured one yet. A server-side request is a boundary you must preserve in its inputs and output.

2. Save a deliberately named global variable

Open Global (the Globals and secrets control) in the backend builder and add a Text value such as provider_api_key. The maintained documentation describes Text globals as encrypted and hidden by default. Keep the value concealed while reviewing the configuration; hiding an editor value does not make it safe to return through an endpoint.

Reference it through the backend's $global selector. Globals are configuration values, rather than a place for per-customer state or a mutable counter. Do not remove existing globals or replace the complete configuration while preparing one integration. If the editor reports a load/decryption error, resolve it before saving changes.

Marketing backend toolbar with Global, Run, Test and Publish controls
The current Marketing Global control opens globals and secrets. Values were not opened, entered or revealed; no provider request was run.

3. Map the credential into the provider request

Configure the backend HTTP command's URL, method and authorization according to that provider's current official API reference. If it expects a bearer key, map the global into the appropriate header. Do not assume all providers use the same header or token format.

Keep the destination under application control. Accepting an arbitrary browser-supplied URL or authorization header can send the key somewhere unintended. Allowlist useful request fields, apply input bounds and validate the caller before spending provider quota. Keep a provider credential separate from the customer's Twidget authentication token.

External HTTP request editor showing an illustrative example.com URL and GET method
Earlier Marketing HTTP request controls use a reserved example.com URL. This is request configuration, not a provider integration or a stored credential.

4. Return only the result the interface needs

Map selected provider result fields into your endpoint output. Avoid echoing request headers, credential-bearing objects or raw exception messages. A provider error should become a useful application message without exposing the private request configuration.

Review execution traces, logs, test assertions and error output for potential credential disclosure. Do not assume every diagnostic surface automatically redacts every secret. Use a controlled test value initially so you can check the mapping before running a real provider call. Watch globals and environment-specific secrets for the product workflow.

5. Prepare production values separately

Use distinct restricted test and production credentials in their corresponding workspaces. Prepare the required global names and types before promoting a workflow. Twidget's release documentation states that global values are not moved by workflow promotion; the destination retains its own saved values.

Review which deployed workflows use a key before rotating or revoking it. Coordinate the provider-side change and destination configuration, test the new credential, then retire the old one according to the provider's supported process. Do not treat a changed builder draft as proof that a published endpoint uses the new value.

6. Check denied requests and disclosure paths

Test with a harmless placeholder or restricted test key, then inspect successful and failed endpoint responses, browser requests and relevant logs. The browser should never receive the provider key. Call without a customer token and as a user lacking access; both should be rejected before protected provider work.

Test a missing global, an invalid provider credential and a provider timeout. Keep those failures distinguishable in internal diagnostics while returning safe client messages. Follow workflow debugging for diagnosis and Dev-to-Prod release for publishing. No provider credential was entered or tested to illustrate this article.

Existing Marketing auth/me endpoint with Bearer Token authentication
Existing Marketing identity endpoint with Bearer Token selected. Authentication identifies the caller; each record/action still needs authorization.

Go deeper

Supporting documentation

Find the configuration details and reference material behind this page.

From idea to a working flow

Build one useful thing with Twidget

Start with a small workflow, test it with sample data and make it your own.

Preview

Have any questions? Get in Touch

Starting with Twidget is easy, fast and free

It only takes a few clicks to get started

Get started - it's free

No credit card required.


© Copyright 2026 - Twidget.io