Authentication Layers
Authentication in the Alloy Automation API operates at three distinct levels:- Platform Authentication: Your application authenticates with Alloy Automation using an API key
- User Context: Each request specifies which user’s credentials to use
- Connector Credentials: Alloy Automation uses stored credentials to authenticate with third-party platforms
Platform Authentication
API Key
All requests to the Connectivity API require an API key passed via theAuthorization
header using Bearer token format.
- Never expose your API key in client-side code - Always make API calls from your backend
- Store API keys in environment variables or secure secret management systems
- Rotate API keys periodically
- Use different API keys for development, staging, and production environments
Required Headers
Every API request must include these headers:Header | Value | Description |
---|---|---|
Authorization | Bearer YOUR_API_KEY | Authenticates your application with Alloy Automation |
x-api-version | {API_VERSION} | Specifies the API version to use |
Content-Type | application/json | Required for POST/PUT requests |
User Context Authentication
User ID Header
Operations that execute actions or manage credentials require specifying which user’s context to operate within. This is done via thex-alloy-userid
header.
When User ID Is Required
Thex-alloy-userid
header is required for:
- Executing actions (
POST /connectors/{connectorId}/actions/{actionId}/execute
) - Creating credentials (
POST /users/{userId}/credentials
) - Listing user-specific credentials (
GET /users/{userId}/credentials
)
- Listing connectors (
GET /connectors
) - Getting connector metadata (
GET /connectors/{connectorId}
) - Getting action schemas (
GET /connectors/{connectorId}/actions/{actionId}
) - Creating users (
POST /users
)
Connector Credentials
Overview
Connector credentials are the authentication tokens or API keys that Alloy Automation uses to communicate with third-party platforms on behalf of your users. These credentials are stored securely by Alloy Automation and referenced by acredentialId
.
Credential Types
Alloy Automation supports multiple authentication patterns:OAuth 2.0
Used by most modern SaaS platforms (HubSpot, Salesforce, Notion, etc.). Alloy Automation handles the complete OAuth flow including token refresh. Flow:- Initiate OAuth: Request an authorization URL
- User Authenticates: Redirect user to the authorization URL
- Token Exchange: Alloy Automation automatically exchanges the authorization code for access/refresh tokens
- Credential Created: Credential is attached to the user and ready for use
API Keys
Some platforms use API keys or custom authentication schemes. For these, you pass the authentication data directly.Discovering Required Credentials
Before creating credentials, discover what authentication data a connector requires:- Determine the authentication type
- Identify required fields
- Build dynamic credential collection forms
- Validate input before submission
Using Credentials
Once a credential is created and attached to a user, reference it when executing actions:Credential Lifecycle
Automatic Token Refresh: For OAuth credentials, Alloy Automation automatically refreshes access tokens when they expire. You don’t need to handle token refresh logic. Credential Invalidation: Credentials become invalid when:- User revokes access in the third-party platform
- OAuth tokens are manually revoked
- API keys are rotated or deleted
Security Architecture
What You Store
You are responsible for securely storing:- Your Alloy Automation API key - Authenticates your application
- User-to-Credential mappings - Which of your users have access to which Alloy Automation
credentialId
values - User context - Your own user authentication and session management
What Alloy Automation Stores
Alloy Automation securely stores:- OAuth access and refresh tokens - Encrypted at rest
- API keys and secrets - Encrypted at rest
- Credential metadata - Connector type, creation date, last used, etc.
Recommended Architecture
Key Principles:- API keys never touch the frontend - All Alloy Automation API calls from your backend
- Credential IDs are safe to store - They’re useless without your API key
- User context is your responsibility - Ensure users can only access their own credentials
- OAuth flows can initiate from frontend - But final credential storage happens server-side
Authentication Errors
Common Error Scenarios
Invalid API Key
Missing API Version Header
x-api-version: {API_VERSION}
header in all requests.
Invalid User ID
x-alloy-userid
header is correct.
Invalid Credential ID
Testing Authentication
Verify Platform Access
Test your API key by listing available connectors:Test User Context
Create a test user and verify it was created:Test Credential Flow
Use a sandbox account (HubSpot developer account, Notion personal workspace) to test the complete credential flow without affecting production data.Next Steps
- Learn about Users and how to manage end-user contexts
- Explore Credentials in depth
- Start Executing Actions with stored credentials
- Review Security Best Practices