Add connection management to your app
- New
- How-to guide
- 10-min read
If your app integrates with a third-party service such as Slack, Jira, or ServiceNow, users need a way to authenticate to that service. With connections, users store reusable sets of credentials under a name. Workflow actions reference a connection by name, so they never handle raw secrets. Only your connection form handles a secret, while the user enters it.
This guide shows you how to add connection management to your app with the @dynatrace/connectors-management package. You will:
- Define the schema that describes a connection.
- Build the connection form.
- Show a connections overview in your app.
- Register the intents that open the connection form.
- Use the connections in a workflow action.
Already have a connector and want to use its connections in a workflow action widget? Go to Design a UI for workflow actions.
What are connectors and connections?
A connector defines an integration type, for example GitHub or Jira Cloud, and specifies the fields a connection needs, such as URL, API token, or authentication method.
A connection is a specific, named instance of a connector, such as "My team's GitHub" or "Production Slack workspace". Users create a connection once and reuse it across workflows.
Dynatrace ships built-in connectors for common third-party services. If none of them match your integration, you can build your own with @dynatrace/connectors-management.
Access control for connectors is managed separately. See Access control.
Prerequisites
- A Dynatrace app scaffolded with the App Toolkit. See First app in 5 minutes if you're starting from scratch.
- Familiarity with add-on intents. The Workflows app uses them to open your connection form.
Install the package
npm install @dynatrace/connectors-management
The package has peer dependencies that your app must include. The App Toolkit scaffolding installs most of them. Make sure all of them are available:
npm install \
@dynatrace-sdk/app-environment \
@dynatrace-sdk/client-app-settings-v2 \
@dynatrace-sdk/navigation \
@dynatrace-sdk/shared-errors \
@dynatrace/strato-components \
@dynatrace/strato-design-tokens \
@dynatrace/strato-icons \
react \
react-hook-form \
react-intl
| Peer dependency | Required version |
|---|---|
@dynatrace-sdk/app-environment | >=1.1.4 < 2.x |
@dynatrace-sdk/client-app-settings-v2 | >=1.1.0 < 2.x |
@dynatrace-sdk/navigation | >=2.1.0 < 3.x |
@dynatrace-sdk/shared-errors | ^1.0.0 |
@dynatrace/strato-components | >=3.7.0 < 4.x |
@dynatrace/strato-design-tokens | >=1.5.0 < 2.x |
@dynatrace/strato-icons | >=2.3.0 < 3.x |
react | ^18.3.1 || ^19.0.0 |
react-hook-form | ^7.90.0 |
react-intl | 6.x || 7.x |
1. Define the connection settings schema
Connections are stored as app settings. Create a JSON schema file in settings/schemas/ that describes what a connection requires. This guide uses connection as the schemaId. The components and intents in the following steps reference it. The schema must have:
multiObject: true— multiple connections can exist per environment.ownerBasedAccessControl: true— users can only manage their own connections.ordered: false— order has no meaning for connections.- A schema-level
UNIQUEconstraint on thenameproperty, so each connection has a distinct identifier. - A
SECRET_RESUBMISSIONconstraint andforceSecretResubmission: trueon any non-secret field that influences how secrets are used. For details, see Use secrets.
{
"dynatrace": "1",
"schemaId": "connection",
"version": "1.0.0",
"displayName": "My third party service connections",
"description": "Authentication details for my third party service",
"summaryPattern": "{name}",
"multiObject": true,
"maxObjects": 100,
"ordered": false,
"ownerBasedAccessControl": true,
"properties": {
"name": {
"displayName": "Connection name",
"description": "A unique name for this connection",
"type": "text",
"nullable": false,
"default": "",
"forceSecretResubmission": false,
"constraints": [
{
"type": "LENGTH",
"minLength": 1,
"maxLength": 50,
"customMessage": "Name has to be between 1 and 50 characters long"
}
]
},
"url": {
"displayName": "URL",
"description": "The base URL of my third party service (for example, https://myservice.example.com)",
"type": "text",
"subType": "url",
"nullable": false,
"default": "",
"forceSecretResubmission": true,
"constraints": [
{
"type": "LENGTH",
"minLength": 1,
"maxLength": 100,
"customMessage": "URL has to be between 1 and 100 characters long"
},
{
"type": "PATTERN",
"pattern": "^https://.*[^/]$",
"customMessage": "The URL must start with https:// and must not end with a slash"
}
]
},
"token": {
"displayName": "API token",
"description": "A secret API token for authentication",
"type": "secret",
"nullable": false,
"default": "",
"constraints": [
{
"type": "LENGTH",
"minLength": 5,
"maxLength": 500,
"customMessage": "Token has to be between 5 and 500 characters long"
}
]
}
},
"schemaConstraints": [
{
"type": "UNIQUE",
"uniqueProperties": ["name"],
"customMessage": "A connection with the same name already exists. Provide a different name."
}
],
"constraints": [
{
"type": "SECRET_RESUBMISSION",
"checkAllProperties": false,
"customMessage": "For security reasons, re-enter the token to save the new configuration."
}
]
}
For local development, add a settings/local-mock-data/values.json file with sample connection values. See the local development section of the Store app settings guide for details and the required @dynatrace-sdk/dt-app-plugin-client-app-settings-v2 plugin (minimum version 0.5.1).
2. Build the connection form
The connection form is a React component that you implement with your service-specific fields. The package provides ConnectionSettingFormIntent, which wraps your form and handles the add-on intent lifecycle. It stores credentials through the App Settings API and closes the overlay on confirm or cancel.
The package doesn't bundle @dynatrace-sdk/addons and @dynatrace-sdk/navigation. Install them separately if you haven't already:
npm install @dynatrace-sdk/addons @dynatrace-sdk/navigation
Define your connection form component
Build a form component that renders the fields matching your schema. The validation rules in the form must match the constraints in the schema. Use Strato form components such as TextInput for standard text fields and SecretInput for secret fields. The mode prop is 'CREATE', 'EDIT', or 'VIEW' and tells the form which state it's in. The package doesn't export a type for it, so declare the union in your own props.
With SecretInput, users can change non-secret fields without entering the secret again.
import { FormField, FormFieldMessages, Label, TextInput, SecretInput } from '@dynatrace/strato-components/forms';
import { Flex } from '@dynatrace/strato-components/layouts';
import React, { useEffect, useRef } from 'react';
import { Controller, useFormContext } from 'react-hook-form';
interface ConnectionValue {
name: string;
url: string;
token: string | undefined;
}
interface MyThirdPartyServiceConnectionFormProps {
mode: 'CREATE' | 'EDIT' | 'VIEW';
}
export const MyThirdPartyServiceConnectionForm = ({ mode }: MyThirdPartyServiceConnectionFormProps) => {
const {
control,
trigger,
formState: { dirtyFields, touchedFields },
} = useFormContext<ConnectionValue>();
const readOnly = mode === 'VIEW';
const isEditMode = mode === 'EDIT';
// In edit mode, changing the URL requires the user to enter the token again.
const requiresResubmission = Boolean(dirtyFields.url);
const isTokenTouched = Boolean(touchedFields.token);
// Read the latest values through refs so that `validate` never uses stale state.
const requiresResubmissionRef = useRef(requiresResubmission);
const isTokenTouchedRef = useRef(isTokenTouched);
useEffect(() => {
requiresResubmissionRef.current = requiresResubmission;
isTokenTouchedRef.current = isTokenTouched;
}, [requiresResubmission, isTokenTouched]);
return (
<Flex gap={16} flexDirection="column">
<FormField id="name" required>
<Label>Connection name</Label>
<Controller
control={control}
name="name"
rules={{
required: 'Name is required',
minLength: { value: 1, message: 'Name has to be between 1 and 50 characters long' },
maxLength: { value: 50, message: 'Name has to be between 1 and 50 characters long' },
}}
render={({ field: { ref, ...field }, fieldState: { error } }) => (
<>
<TextInput {...field} readOnly={readOnly} ref={(rf) => ref(rf?.inputRef)} />
<FormFieldMessages>
{error ? <FormFieldMessages.Item variant="error">{error.message}</FormFieldMessages.Item> : null}
</FormFieldMessages>
</>
)}
/>
</FormField>
<FormField id="url" required>
<Label>URL</Label>
<Controller
control={control}
name="url"
rules={{
required: 'URL is required',
maxLength: { value: 100, message: 'URL has to be between 1 and 100 characters long' },
pattern: {
value: /^https:\/\/.*[^/]$/,
message: 'The URL must start with https:// and must not end with a slash',
},
}}
render={({ field: { ref, ...field }, fieldState: { error } }) => (
<>
<TextInput {...field} readOnly={readOnly} ref={(rf) => ref(rf?.inputRef)} />
<FormFieldMessages>
{error ? <FormFieldMessages.Item variant="error">{error.message}</FormFieldMessages.Item> : null}
</FormFieldMessages>
</>
)}
/>
</FormField>
<FormField id="token" required>
<Label>API token</Label>
<Controller
control={control}
name="token"
rules={{
required: 'Token is required',
minLength: { value: 5, message: 'Token has to be between 5 and 500 characters long' },
maxLength: { value: 500, message: 'Token has to be between 5 and 500 characters long' },
validate: () =>
isEditMode && requiresResubmissionRef.current && !isTokenTouchedRef.current
? 'For security reasons, re-enter the token to save the new configuration.'
: undefined,
}}
render={({ field: { ref, ...field }, fieldState: { error, isDirty } }) => (
<>
<SecretInput
{...field}
value={isEditMode && !isDirty ? null : field.value}
readOnly={readOnly}
ref={(rf) => ref(rf?.inputRef)}
onChange={(val) => {
field.onChange(val);
if (error) void trigger(field.name);
}}
/>
<FormFieldMessages>
{error ? (
<FormFieldMessages.Item variant="error">{error.message}</FormFieldMessages.Item>
) : (
<FormFieldMessages.Item variant="hint">Enter your API token.</FormFieldMessages.Item>
)}
</FormFieldMessages>
</>
)}
/>
</FormField>
</Flex>
);
};
3. Show a connections overview in your app
The ConnectionOverview component renders a table of connections with built-in create, edit, and delete actions.
Place it inside a settings widget so users can manage their connections from the app's settings panel.
It renders an inline form for creating and editing connections. Use the MyThirdPartyServiceConnectionForm component from step 2.
import { AppRoot } from '@dynatrace/strato-components/core';
import { ToastContainer } from '@dynatrace/strato-components/notifications';
import { ConnectionOverview } from '@dynatrace/connectors-management';
import { MyThirdPartyServiceConnectionForm } from '../ui/app/components/MyThirdPartyServiceConnectionForm';
import React from 'react';
import * as ReactDom from 'react-dom/client';
import './my-third-party-connection-management.css';
const rootElement = document.getElementById('root');
if (rootElement) {
const root = ReactDom.createRoot(rootElement);
root.render(
<AppRoot>
<ToastContainer />
<ConnectionOverview schemaId="connection" defaultValues={{ url: 'https://example.com' }}>
{({ mode }) => <MyThirdPartyServiceConnectionForm mode={mode} />}
</ConnectionOverview>
</AppRoot>,
);
} else {
console.error('The root element is not defined');
}
For correct styling, add the following CSS file. The settings widget imports it:
*:has(> main) {
display: flex;
flex-direction: column;
height: 100vh;
}
main {
display: flex;
flex-direction: column;
flex: 1;
}
The widget is compiled separately from the rest of your app. To let it import the CSS file, add a type declaration for CSS modules:
declare module '*.css';
Then reference it in the widget's TypeScript config. The App Toolkit creates this file the first time you run dt-app dev or dt-app build:
{
"compilerOptions": {
"allowJs": true,
"strict": true,
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"importHelpers": false,
"jsx": "react",
"skipLibCheck": true,
"lib": ["DOM", "DOM.Iterable", "esnext"],
"module": "ESNext",
"moduleResolution": "bundler",
"target": "ESNext"
},
"include": ["**/*.widget.tsx", "declarations.d.ts"]
}
Run npx dt-app build to check that the widget compiles. The terminal output confirms that the settings widget was built.
4. Register the connection intents in your app manifest
Connection management relies on two reserved add-on intents that the Workflows engine fires when users select Create new connection or Edit connection in the AutomationConnectionPicker. Register both in your app config as add-on intents.
The edit-connection intent requires the dt.settings.object_id property. It identifies the connection to edit. Both intents accept the optional dt.settings.schema property.
Your app also needs the following scopes to read and write connection data through the App Settings API:
{
"environmentUrl": "<Your-Environment-URL>",
"app": {
"id": "<Your-App-ID>",
"name": "<Your-App-Name>",
"version": "0.0.0",
"description": "<Your-App-Description>",
"scopes": [
{
"name": "app-settings:objects:read",
"comment": "To read app settings"
},
{
"name": "app-settings:objects:write",
"comment": "To write app settings"
},
{
"name": "app-settings:objects:admin",
"comment": "To manage app settings"
},
{
"name": "iam:users:read",
"comment": "View Identity & Access Management (IAM) Users"
},
{
"name": "iam:groups:read",
"comment": "View Identity & Access Management (IAM) Groups"
}
],
"intents": {
"create-connection": {
"addonMode": "overlay",
"description": "Create a new My Service connection",
"addonConfig": { "size": { "height": 450 } },
"properties": {
"dt.settings.schema": {
"required": false,
"schema": { "type": "string" }
}
}
},
"edit-connection": {
"addonMode": "overlay",
"description": "Edit an existing My Service connection",
"addonConfig": { "size": { "height": 520 } },
"properties": {
"dt.settings.schema": {
"required": false,
"schema": { "type": "string" }
},
"dt.settings.object_id": {
"required": true,
"schema": { "type": "string" }
}
}
}
},
"settings": {
"my-third-party-connection-management": {
"name": "My third party service connections",
"description": "Authentication details for my third party service",
"schemaIds": ["connection"]
}
}
}
}
Wire up the create and edit intent routes
Register a route for each intent in your app root. ConnectionSettingFormIntent reads the intent payload, saves or updates the connection, and closes the overlay when the user confirms or cancels. You don't need to wire up the add-on lifecycle or the App Settings client yourself.
import { ConnectionSettingFormIntent } from '@dynatrace/connectors-management';
import { resolveAddon } from '@dynatrace-sdk/addons';
import { MyThirdPartyServiceConnectionForm } from '../components/MyThirdPartyServiceConnectionForm';
import React from 'react';
export const CreateConnectionIntent = () => (
<ConnectionSettingFormIntent onClose={resolveAddon} schemaId="connection">
{({ mode }) => <MyThirdPartyServiceConnectionForm mode={mode} />}
</ConnectionSettingFormIntent>
);
For the edit intent, read the connection ID from the intent payload and pass it to ConnectionSettingFormIntent:
import { ConnectionSettingFormIntent } from '@dynatrace/connectors-management';
import { resolveAddon } from '@dynatrace-sdk/addons';
import { getIntent } from '@dynatrace-sdk/navigation';
import { MyThirdPartyServiceConnectionForm } from '../components/MyThirdPartyServiceConnectionForm';
import React from 'react';
export const EditConnectionIntent = () => {
const intent = getIntent();
const objectId: unknown = intent?.getProperty('dt.settings.object_id');
if (typeof objectId !== 'string' || !objectId) {
return null;
}
return (
<ConnectionSettingFormIntent onClose={resolveAddon} schemaId="connection" connectionId={objectId}>
{({ mode }) => <MyThirdPartyServiceConnectionForm mode={mode} />}
</ConnectionSettingFormIntent>
);
};
Add both routes in your app root. The sample uses react-router. Render App inside a BrowserRouter with basename="ui":
import { CreateConnectionIntent } from './intents/CreateConnectionIntent';
import { EditConnectionIntent } from './intents/EditConnectionIntent';
import React from 'react';
import { Route, Routes } from 'react-router';
export const App = () => {
return (
<Routes>
<Route path="/intent/create-connection" element={<CreateConnectionIntent />} />
<Route path="/intent/edit-connection" element={<EditConnectionIntent />} />
</Routes>
);
};
5. Use connections in a workflow action
After you deploy your connector app, users find the connections overview in the Settings app, in the Apps overview. Workflow action developers can let users pick a connection with AutomationConnectionPicker. Selecting Create new connection or Edit connection in the picker triggers your registered intents.
For the full implementation, go to AutomationConnectionPicker.
Troubleshoot connection management
The overview shows "Connections cannot be displayed: owner is missing"
The schema doesn't turn on owner-based access control. Add "ownerBasedAccessControl": true to the schema in settings/schemas/, redeploy the app, and reload the page.
Saving an edited connection fails with a "re-enter the token" message
The url property has forceSecretResubmission: true, so the schema's SECRET_RESUBMISSION constraint requires users to enter the token again after changing the URL. Make sure your form's validation matches this behavior, as in the validate rule in step 2. Users can then save the connection after they re-enter the token.
Set forceSecretResubmission: true only on fields that influence how the secret is used. For details, see Use secrets.
Users see "You'll need some additional permissions to create connections"
The user doesn't have the app-settings:objects:write permission for the connection schema. The dialog lists the missing permission, and users can copy the details and share them with their administrator. Administrators then grant the permission.
Also check that your app config requests the app-settings:objects:read, app-settings:objects:write, and app-settings:objects:admin scopes, as in step 4.
To reproduce this state locally, in the settings/local-mock-data/permissions.json file, set "granted": "false" for app-settings:objects:write. See Use local permissions.
The edit overlay is empty
EditConnectionIntent renders nothing when the intent has no dt.settings.object_id property. Check that the edit-connection intent in your app config declares dt.settings.object_id with "required": true, and that the caller passes the connection ID.
Users see "This connection has not been shared with you"
The edit overlay shows this message when it can't load the connection. Typically, the connection owner hasn't shared the connection with the user. Ask the owner to share it. For details, see Access control.
Access control
By default, users can only see and manage connections they own (ownerBasedAccessControl: true). Administrators can configure additional access control in their Dynatrace environment settings. For details, see Access control for Connectors.
Further reading
- Built-in connectors: ready-made connectors for common services
- Design a UI for workflow actions: build the workflow action widget that uses a connection picker
- Add-on intents: the overlay pattern behind connection forms
- Store app settings: app settings concepts and local development setup