Skip to main content

Overview

The Connections API (also called App Connections) allows you to manage authentication credentials for third-party integrations. Connections store OAuth tokens, API keys, and other authentication data needed to interact with external services.

Base Endpoint

GET    /api/v1/app-connections
POST   /api/v1/app-connections
POST   /api/v1/app-connections/:id
DELETE /api/v1/app-connections/:id
GET    /api/v1/app-connections/owners
POST   /api/v1/app-connections/replace

List Connections

Retrieve a paginated list of app connections.
curl https://cloud.activepieces.com/api/v1/app-connections?projectId=project_123 \
  -H "Authorization: Bearer sk-your-api-key"

Query Parameters

pieceName
string
Filter by piece (integration) name, e.g., @activepieces/piece-slack
displayName
string
Search connections by display name (partial match)
status
array
Filter by connection status: ACTIVE, MISSING, ERROR
scope
enum
Filter by scope: PROJECT, PLATFORM
limit
number
default:"10"
Number of connections to return (1-100)
cursor
string
Pagination cursor from previous response

Response

data
array
Array of app connection objects (without sensitive data)
Response Example
{
  "data": [
    {
      "id": "conn_abc123",
      "externalId": "ext_slack_main",
      "displayName": "Company Slack",
      "type": "OAUTH2",
      "pieceName": "@activepieces/piece-slack",
      "pieceVersion": "0.10.0",
      "projectIds": ["project_123"],
      "platformId": "platform_456",
      "scope": "PROJECT",
      "status": "ACTIVE",
      "ownerId": "user_789",
      "owner": {
        "email": "user@company.com",
        "firstName": "John",
        "lastName": "Doe"
      },
      "metadata": null,
      "flowIds": ["flow_xyz"],
      "preSelectForNewProjects": false,
      "created": "2024-01-10T10:00:00.000Z",
      "updated": "2024-01-15T14:30:00.000Z"
    }
  ],
  "next": null,
  "previous": null
}

Create/Update Connection (Upsert)

Create a new connection or update an existing one based on externalId.
curl -X POST https://cloud.activepieces.com/api/v1/app-connections \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "My Slack Workspace",
    "pieceName": "@activepieces/piece-slack",
    "pieceVersion": "0.10.0",
    "type": "SECRET_TEXT",
    "externalId": "ext_slack_main",
    "value": {
      "type": "SECRET_TEXT",
      "secret_text": "xoxb-your-slack-token"
    }
  }'

Request Body

displayName
string
required
Human-readable name for the connection
pieceName
string
required
Name of the piece (integration), e.g., @activepieces/piece-slack
pieceVersion
string
required
Version of the piece
type
enum
required
Authentication type: OAUTH2, SECRET_TEXT, BASIC_AUTH, CUSTOM_AUTH, NO_AUTH
externalId
string
External identifier. If a connection with this externalId exists, it will be updated instead of creating a new one
value
object
required
Authentication credentials (format depends on type)
metadata
object
Custom metadata to store with the connection

Connection Value Formats

For API keys, tokens, and other secret strings.
{
  "type": "SECRET_TEXT",
  "value": {
    "type": "SECRET_TEXT",
    "secret_text": "your-api-key-here"
  }
}

Response

Returns the created/updated connection object (without sensitive values). Status code 201 for creation.
Security Note:
  • Sensitive values (tokens, passwords) are encrypted before storage
  • List and get endpoints never return sensitive credential data
  • Only the connection owner can update credentials

Update Connection Metadata

Update the display name and metadata of a connection without changing credentials.
curl -X POST https://cloud.activepieces.com/api/v1/app-connections/conn_abc123 \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "Updated Slack Connection",
    "metadata": {
      "environment": "production",
      "team": "marketing"
    }
  }'

Path Parameters

id
string
required
The connection ID

Request Body

displayName
string
New display name
metadata
object
Updated metadata

Response

Returns the updated connection object.

Delete Connection

Permanently delete a connection.
curl -X DELETE https://cloud.activepieces.com/api/v1/app-connections/conn_abc123 \
  -H "Authorization: Bearer sk-your-api-key"

Path Parameters

id
string
required
The connection ID to delete

Response

Returns 204 No Content on successful deletion.
Deleting a connection that is being used in active flows will cause those flows to fail. Check flowIds before deletion.

List Connection Owners

Get a list of users who own connections in the project.
curl https://cloud.activepieces.com/api/v1/app-connections/owners \
  -H "Authorization: Bearer sk-your-api-key"

Response

{
  "data": [
    {
      "firstName": "John",
      "lastName": "Doe",
      "email": "john.doe@example.com"
    },
    {
      "firstName": "Jane",
      "lastName": "Smith",
      "email": "jane.smith@example.com"
    }
  ],
  "next": null,
  "previous": null
}

Replace Connection

Replace one connection with another across all flows in the project.
curl -X POST https://cloud.activepieces.com/api/v1/app-connections/replace \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "sourceAppConnectionId": "conn_old123",
    "targetAppConnectionId": "conn_new456"
  }'

Request Body

sourceAppConnectionId
string
required
ID of the connection to replace
targetAppConnectionId
string
required
ID of the replacement connection

Response

Returns 204 No Content on success.
Use Cases for Replace:
  • Rotating credentials across all flows
  • Migrating to a different account
  • Consolidating duplicate connections

Connection Types

OAuth2 Types

You provide your own OAuth2 app credentials (client ID/secret). Full control over the OAuth flow and refresh logic.Best for: Custom integrations, white-labeled solutions
Uses platform-level OAuth credentials configured by the platform admin. Users just authorize, credentials are managed centrally.Best for: Multi-tenant platforms, managed SaaS
Uses Activepieces’ OAuth credentials (Cloud edition only). Simplest setup, no OAuth app registration needed.Best for: Quick setup, testing, small deployments

Other Types

  • SECRET_TEXT - API keys, bearer tokens, webhook secrets
  • BASIC_AUTH - Username/password combinations
  • CUSTOM_AUTH - Flexible key-value pairs for custom auth schemes
  • NO_AUTH - For public APIs or internal services

Connection Status

StatusDescription
ACTIVEConnection is valid and working
MISSINGConnection has been deleted but is still referenced
ERRORConnection has authentication errors (e.g., expired OAuth token)
Activepieces automatically monitors OAuth2 connections and attempts to refresh expired tokens. If refresh fails, the status changes to ERROR.

Connection Scope

Project-Scoped Connections

{
  "scope": "PROJECT",
  "projectIds": ["project_123"]
}
  • Available only in specified projects
  • Managed by project members
  • Most common for team-specific integrations

Platform-Scoped Connections (Global)

{
  "scope": "PLATFORM",
  "projectIds": ["project_123", "project_456", "project_789"],
  "preSelectForNewProjects": true
}
  • Managed by platform admins
  • Can be shared across multiple projects
  • Useful for company-wide integrations
  • Can be pre-selected for new projects

OAuth2 Flow

For OAuth2 connections, the typical flow is:
  1. Initiate OAuth: Redirect user to provider’s authorization URL
  2. User Authorizes: User grants permissions
  3. Receive Callback: OAuth provider redirects to your callback URL with authorization code
  4. Exchange Code: Exchange authorization code for access token
  5. Store Connection: Create connection via API with tokens
Example OAuth2 Handler
// After receiving OAuth callback
const tokenResponse = await fetch('https://oauth.provider.com/token', {
  method: 'POST',
  body: new URLSearchParams({
    grant_type: 'authorization_code',
    code: authorizationCode,
    client_id: clientId,
    client_secret: clientSecret,
    redirect_uri: redirectUri
  })
});

const tokens = await tokenResponse.json();

// Create connection in Activepieces
await fetch('https://cloud.activepieces.com/api/v1/app-connections', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    displayName: 'My OAuth App',
    pieceName: '@activepieces/piece-example',
    pieceVersion: '1.0.0',
    type: 'OAUTH2',
    value: {
      type: 'OAUTH2',
      client_id: clientId,
      client_secret: clientSecret,
      access_token: tokens.access_token,
      refresh_token: tokens.refresh_token,
      token_type: 'Bearer',
      expires_in: tokens.expires_in,
      claimed_at: Date.now(),
      scope: tokens.scope,
      token_url: 'https://oauth.provider.com/token',
      redirect_url: redirectUri,
      grant_type: 'AUTHORIZATION_CODE',
      data: {}
    }
  })
});

Error Responses

Connection Not Found (404)

{
  "statusCode": 404,
  "code": "ENTITY_NOT_FOUND",
  "params": {
    "entityType": "app_connection",
    "entityId": "conn_abc123",
    "message": "Connection not found"
  }
}

Connection In Use (400)

{
  "statusCode": 400,
  "code": "VALIDATION",
  "params": {
    "message": "Connection is used in 3 active flows. Please remove it from flows first."
  }
}

Best Practices

  • Use externalId for idempotent upserts
  • Rotate credentials regularly using replace endpoint
  • Store metadata about credential source and expiration
  • Monitor connection status and handle ERROR states
  • Store refresh tokens securely
  • Activepieces handles token refresh automatically
  • Set appropriate OAuth scopes (least privilege)
  • Monitor expires_in and claimed_at for token health
  • Use PROJECT scope for tenant-specific connections
  • Use PLATFORM scope for shared company integrations
  • Leverage preSelectForNewProjects for default connections
  • Use metadata to track tenant ownership
  • Never log or expose connection values
  • Use HTTPS for all API calls
  • Implement proper access controls
  • Audit connection creation and deletion

Code Examples

import axios from 'axios';

const client = axios.create({
  baseURL: 'https://cloud.activepieces.com/api/v1',
  headers: {
    'Authorization': `Bearer ${process.env.ACTIVEPIECES_API_KEY}`
  }
});

// Create a Secret Text connection
const connection = await client.post('/app-connections', {
  displayName: 'Slack Bot Token',
  pieceName: '@activepieces/piece-slack',
  pieceVersion: '0.10.0',
  type: 'SECRET_TEXT',
  externalId: 'ext_slack_bot',
  value: {
    type: 'SECRET_TEXT',
    secret_text: process.env.SLACK_BOT_TOKEN
  },
  metadata: {
    environment: 'production',
    workspace: 'company'
  }
});

console.log('Created connection:', connection.data.id);

// List all Slack connections
const { data } = await client.get('/app-connections', {
  params: {
    pieceName: '@activepieces/piece-slack',
    status: ['ACTIVE']
  }
});

console.log(`Found ${data.data.length} active Slack connections`);

Flows API

Flows that use these connections

Projects API

Manage connection scope and project access