Skip to main content
The connectionConfigVar() function defines a config variable that holds a connection — a set of authentication credentials (API key, OAuth token, username/password, etc.) used to authenticate with an external service. Connection config variables always have dataType: "connection". A connection config var can be defined in two ways:
  • Connection definition — inline definition with explicit inputs fields (used when building a connection from scratch within a code-native integration).
  • Connection reference — a reference to a connection defined in a component registered in the componentRegistry (used when reusing an existing component’s connection type).

Function signature

export const connectionConfigVar = <T extends ConnectionConfigVar = ConnectionConfigVar>(
  definition: T,
): T

Parameters

definition
ConnectionConfigVar
required
An object describing the connection config variable. The shape depends on whether it is a connection definition or a connection reference.

Return type

connectionConfigVar
T
The same connection config variable definition object passed in, unchanged. Used for type inference.
At runtime, the value of a connection config variable is available as a Connection object in context.configVars. It contains the resolved input values and can be passed directly to component actions or used in your own HTTP client setup.

Examples

import { configPage, connectionConfigVar, input } from "@prismatic-io/spectral";

const connectionPage = configPage({
  tagline: "Authenticate with Acme Corp API",
  elements: {
    "Acme Connection": connectionConfigVar({
      stableKey: "acme-connection",
      dataType: "connection",
      description: "Your Acme Corp API credentials.",
      inputs: {
        apiKey: input({
          label: "API Key",
          type: "password",
          required: true,
          comments: "Your Acme Corp API key.",
          clean: (value) => String(value),
        }),
        baseUrl: input({
          label: "Base URL",
          type: "string",
          required: true,
          default: "https://api.acme.com/v1",
          comments: "The base URL for the Acme Corp API.",
          clean: (value) => String(value),
        }),
      },
    }),
  },
});

Customer-activated and organization-activated connections

For integration-agnostic connections, use the dedicated helper functions instead of connectionConfigVar():
  • customerActivatedConnection({ stableKey }) — Creates a customer-activated connection config var (customers configure the connection themselves).
  • organizationActivatedConnection({ stableKey }) — Creates an org-activated connection config var (the organization configures the connection, not the customer).
These are placed in scopedConfigVars on the integration definition rather than in configPages.
import {
  integration,
  organizationActivatedConnection,
} from "@prismatic-io/spectral";

export default integration({
  name: "My Integration",
  flows: [],
  scopedConfigVars: {
    "Shared API Connection": organizationActivatedConnection({
      stableKey: "shared-api-connection",
    }),
  },
});