---
schema_version: "1"
id: 7f32855da32e6879a5a9d8aaf635f1799a5c0ee51df5a44a9b25106e4babf16e
title: Connections
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/connector-builder/connections.md
canonical_url: https://docs.mulesoft.com/connector-builder/connections
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a16203d3003aaed9857e5009a2ff9604ba22e11fccf2eef9573b62e455cf3dc5
description: MuleSoft Documentation Site
latest: true
---
---
product: Connector Builder
version: master
---

# Connections

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Learn how to define connections for your connector. Connections enable your connector to communicate
with external systems. Without a connection, your connector can’t perform operations, triggers, or
other components. Connector Builder supports creating connectors that integrate with SaaS
applications that use HTTP-based connectivity.

Each connection uses an authentication type. An authentication type is a specific method or protocol
used to verify and authorize access to the external system. Connector Builder supports these
authentication types for connections.

- **ApiKey**

  ApiKey authentication connects to applications without explicitly defining a user. You must add
  this key to all requests, and the cloud application identifies the origin of the request and
  completes the authorization.

- **Basic**

  Basic authentication enables the user to provide a username and password when logging in to an
  external system.

- **Bearer**

  Bearer authentication sends a header named Authorization with a value of Bearer and a token with
  every request.

- **OAuth2BrowserFlow**

  OAuth2BrowserFlow authentication is the authorization code grant type, which is used to obtain
  both access tokens and refresh tokens and is optimized for confidential clients. Since this is a
  redirection-based flow, the client must be capable of interacting with the resource owner’s
  user-agent (typically a web browser) and capable of receiving incoming requests (via redirection)
  from the authorization server.

- **OAuth2ClientCredentials**

  OAuth2ClientCredentials authentication obtains an access token from a user-defined path.

> [!NOTE] Custom Flow connectors support only the **ApiKey**, **Basic**, and **Bearer**
> authentication types.

You can define connections using either the UI or LinkWeave. Use the UI as your primary approach, as
it significantly reduces manual development effort. Reserve LinkWeave for advanced scenarios that
require custom logic. With Connector Builder, the goal is to focus on reviewing and validating the
generated process, rather than writing custom code.

## Define Connections Using the UI

When you [generate base connectivity](https://docs.mulesoft.com/connector-builder/base-connectivity), if the authentication type specified in
the API specification or by AI assistance is supported by Connector Builder, the authentication type
and a connection for each endpoint are automatically defined for you.

### Use Connection Profiles

Create, edit, and manage reusable connection profiles with secure credential storage.

1.  Open the Connector Builder extension in VS Code or Cursor.

2.  Select **Connection Profiles**.

3.  Click **New Profile**.

4.  Enter the required information.

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Profile Name</strong></p></td><td><p>Enter the name of the connection profile. For example, <code>Salesforce Developer</code>.</p></td></tr><tr><td><p><strong>Description</strong></p></td><td><p>Enter the optional description of the connection profile.</p></td></tr><tr><td><p><strong>Authentication Type</strong></p></td><td><div><div><p>Select the authentication type for the connection profile. Values are:</p></div><div><ul><li><p><code>BEARER</code></p></li><li><p><code>BASIC</code></p></li><li><p><code>OAUTH</code></p></li><li><p><code>APIKEY</code></p></li></ul></div></div></td></tr></tbody></table>

5.  Click **Save**.

There’s also a **Try It** panel that allows you to create or test the connection profile. You can
select the connection profile or add inline credentials to test your connection.

#### List Connection Profiles with MCP Tools

In some cases, you might need a list of your connection profiles. For example, to use the
`uc_manage_operations` MCP tool to
[execute operations](https://docs.mulesoft.com/connector-builder/operations#manage-operations-with-mcp-tools), you need the connection profile
ID, which can be obtained by listing your connection profiles.

1.  Open the Connector Builder extension in Cursor.

2.  Select **Settings** and ensure **Enable Mcp Tools** is enabled.

3.  Open the Cursor chat window (if not already open).

4.  Ask the agent to list connection profiles. For example, enter `List connection profiles`. This
    calls the `uc_list_connection_profiles` MCP tool, which lists the connection profiles.

5.  Enter the required inputs when prompted.

6.  Confirm your inputs. Connector Builder lists the connection profiles.

For more information, see
[MuleSoft DX MCP Server Tool Reference](https://docs.mulesoft.com/mulesoft-mcp-server/reference-mcp-tools).

## Define Connections Using LinkWeave

You can define connections using LinkWeave.

- [Connection Structure](#connection-structure)

- [Authentication Types](#authentication-types)

### Connection Structure

In LinkWeave, connections are functions that transform requests into responses:

```none
(ConnectionRequest) -> ConnectionResponse
```

For HTTP-based connections, this becomes:

```none
(HttpRequester) -> HttpResponse
```

These types form the structure of connections.

- [Connection](#connection): Connection function

- [ConnectionProvider](#connection-provider): Connection creation and configuration

- [HTTPConnection](#http-connection): Specialized connection for HTTP requests

- [HTTPConnectionProvider](#http-connection-provider): HTTP-specific connection provider

#### Connection

```none
Connection<ConnectionRequest <: Object, ConnectionResponse <: Object> =
  (ConnectionRequest) -> ConnectionResponse
```

Parameters:

- `ConnectionRequest`: Object sent to the target system

- `ConnectionResponse`: Object returned from the target system

#### ConnectionProvider

```none
ConnectionProvider<ConnectionType <: Connection, InputType <: Object, AuthenticationType <: Object>
```

Parameters:

- `ConnectionType`: Connection function itself

- `InputType`: Input parameters required to create the connection

- `AuthenticationType`: Authentication schema

`ConnectionProvider` returns an object with these properties:

```none
{
  connect: (InputType) -> ConnectionType,
  authenticationType: AuthenticationType,
  validate?: (ConnectionType) -> ConnectionValidationResult
}
```

Properties:

- `connect`: Creates a connection from input parameters

- `authenticationType`: Defines the authentication schema

- `validate`: (Optional) Tests the connection and returns validation results

#### HTTPConnection

```none
HttpConnection = Connection<HttpRequester, HttpResponse>
```

#### HTTPConnectionProvider

```none
HttpConnectionProvider<InputType <: Object, HttpAuthenticationType> =
  ConnectionProvider<HttpConnection, InputType, HttpAuthenticationType>
```

`HTTPConnectionProvider` also supports an optional `extensions` attribute for customizing connection
behavior. Use extensions to add custom headers, query parameters, or other modifications to
requests.

```none
extensions?: (InputType) -> Array<ConnectionProviderExtensions | ConnectionProviderOAuthExtensions>
```

The definitions for these types are:

```none
type ConnectionProviderExtensions = {
  in: "query" | "header" | "body" | "path",
  name: String,
  value: String
}

type ConnectionProviderOAuthExtensions = {
  inDance: true | false,
} & ConnectionProviderExtensions
```

You can also enhance any authentication type with extensions. This example adds a static header to a
Basic authentication type.

```none
@ConnectionElement()
  var basicAuth = defineBasicHttpConnectionProvider<BasicAuthSchema & { baseUri: String }>((schema) -> {
    username: schema.username,
    password: schema.password
  }, (schema) -> {
    baseUri: schema.baseUri
  }),
  (schema) -> [
                  {in: "header", name:"customHeaderStatic", value: "myValue"}
                ] //This extensions attribute is optional
```

### Authentication Types

You can define the connections for authentication types.

- [ApiKey](#apikey)

- [Basic](#basic)

- [Bearer](#bearer)

- [OAuth2](#oauth2)

#### ApiKey

```none
@ConnectionElement()
  var apiKeyAuth = defineApiKeyHttpConnectionProvider<ApiKeyAuthSchema & { baseUri: String }>((schema) -> {
    apiKey: schema.apiKey
  }, (schema) -> {
    baseUri: schema.baseUri
  }, {
    in: "header",
    name: "X-ApiKey"
  })
```

The APIKey connection is defined and created using `ApiKeyAuthSchema`, which is the input connection
type definition and the connection parameters.

The `defineApiKeyHttpConnectionProvider` function requires these parameters.

- `schemaMapper`

  From an input, `schemaMapper` returns `ApiKeyAuthSchema`.

  ```none
  type ApiKeyAuthSchema = {|
        apiKey: @SemanticTerms(value = ["apiKey"]) String
    |}
  ```

- `connectionProviderSchemaMapper`

  From an input, `connectionProviderSchemaMapper` returns `HttpConnectionProviderSchema`.

  ```none
  type HttpConnectionProviderSchema = {
    baseUri?: String
  }
  ```

- `attributes`

  `attributes` returns `ApiKeyAuthAttributesSchema`.

  ```none
  type ApiKeyAuthAttributesSchema = {
    in: 'header' | 'cookie' | 'query',
    name: String
  }
  ```

> [!NOTE] LinkWeave supports a schema based on a single API key.

#### Basic

```none
@ConnectionElement()
  var basicAuth = defineBasicHttpConnectionProvider<BasicAuthSchema & { baseUri: String }>((schema) -> {
    username: schema.username,
    password: schema.password
  }, (schema) -> {
    baseUri: schema.baseUri
  })
```

The Basic connection is defined and created using `BasicAuthDefinition`, which is the input
connection type definition and the connection parameters.

The `defineBasicHttpConnectionProvider` function requires these parameters.

- `schemaMapper`

  From an input, `schemaMapper` returns `BasicAuthSchema`.

  ```none
  type BasicAuthSchema = {
    username: @SemanticTerms(value = ["username"]) String,
    password: @SemanticTerms(value = ["password"]) String
  }
  ```

- `connectionProviderSchemaMapper`

  From an input, `connectionProviderSchemaMapper` returns `HttpConnectionProviderSchema`.

  ```none
  type HttpConnectionProviderSchema = {
    baseUri?: String
  }
  ```

#### Bearer

```none
@ConnectionElement()
  var bearerAuth = defineBearerHttpConnectionProvider<BearerAuthSchema & { baseUri: String }>((schema) -> {
    token: schema.token
  }, (schema) -> {
    baseUri: schema.baseUri
  })
```

The Bearer connection is defined and created using `BearerAuthSchema`, which is the input connection
type definition and the connection parameters.

The `defineBearerHttpConnectionProvider` function requires these parameters.

- `schemaMapper`

  From an input, `schemaMapper` returns `BearerAuthSchema`.

  ```none
  type BearerAuthSchema = {
    token: @SemanticTerms(value = ["secretToken"]) String
  }
  ```

- `connectionProviderSchemaMapper`

  From an input, `connectionProviderSchemaMapper` returns `HttpConnectionProviderSchema`.

  ```none
  type HttpConnectionProviderSchema = {
    baseUri?: String
  }
  ```

#### OAuth2

```none
@ConnectionElement()
type OAuthAuthDefinition = {
       baseUri: String,
       accessToken: @SemanticTerms(value = ["password"]) String
}

var oAuth: defineOAuth2Connection<OAuthAuthDefinition>(
       (parameter) -> {accessToken: parameter.accessToken},
       (parameter) -> {baseUri: parameter.baseUri},
       {
           grantType: 'authorizationCode',
           authorizationUrl: "http://localhost/authorize",
           tokenUrl: "http://localhost/token",
           scopes: ["test"]
       }
     )
```

The OAuth2 connection is defined and created using `OAuthAuthDefinition`, which is the input
connection type definition and the connection parameters.

The `defineOAuth2Connection` function requires these parameters.

- `schemaMapper`

  From an input, `schemaMapper` returns `OAuth2AuthSchema`.

  ```none
  type OAuth2AuthSchema = {|
    accessToken: @SemanticTerms(value = ["password"]) String
  |}
  ```

- `connectionSchemaMapper`

  From an input, `connectionSchemaMapper` returns `HttpConnectionProviderSchema`.

  ```none
  type HttpConnectionProviderSchema = {|
    baseUri?: String
  |}
  ```

- `attributes`

  `attributes` returns `OAuth2Schema`.

  ```none
  type OAuth2Schema<OAuthGrantType <: AuthorizationCodeGrantType | ClientCredentialsGrantType | PasswordGrantType | ImplicitGrantType> = OAuthGrantType
  ```

OAuth2 supports these grant types.

- `authorizationCode`

- `clientCredentials`

Each grant type has specific configuration requirements. For example, for `authorizationCode`:

```none
type GrantType = 'authorizationCode' | 'clientCredentials' | 'password' | 'implicit'

type CommonOAuth2GrantTypeSchema<GrantType> = {|
  "grantType": GrantType,
  refreshUrl?: String,
  scopes: Array<String>
|}

type AuthorizationCodeGrantType = CommonOAuth2GrantTypeSchema<'authorizationCode'> & {|
  authorizationUrl: String,
  tokenUrl: String
|}
```
