Apps & API Keys
Integrate third-party tools and services with OAuth-based app grants and API keys.
Apps & API Keys
Go to Apps in the Developer section to manage apps and API keys.
API Keys
API keys provide programmatic access to workspace data. Use them for scripts, integrations, or external services that need to read or write data.
Creating an API Key
- Go to Apps → API Keys tab
- Click Create API Key
- Configure:
| Field | Purpose |
|---|---|
| Name | Descriptive name (e.g., "Zapier Integration") |
| Expiration | How long the key is valid (1-365 days) |
| Scopes | What the key can access |
- Click Create
- Copy the key immediately - it won't be shown again
Using API Keys
Include the key in the Authorization header:
bash
Revoking Keys
Click the revoke button next to any key to immediately invalidate it. Revoked keys cannot be restored.
Webhook Secret
The Apps page also shows your Webhook Secret for verifying incoming webhook payloads. See Webhooks for details.
Apps (OAuth)
Gravity Rail Apps allow third-party tools and services to integrate with Gravity Rail workspaces using OAuth.
Key Concepts
Member-Based Grants
In Gravity Rail, Apps don't store long-lived access tokens. Instead:
- Members grant permissions to applications within their workspaces (AppGrants)
- Tokens are generated dynamically when needed
- Two-layer encryption protects sensitive data
- Shared grants allow workspace-wide access (admin only)
Client Credentials
Each Application has:
- Client ID: A public identifier for your application (format:
gr_app_xxxxx) - Client Secret: A base64url-encoded 16-byte key for decrypting tokens (only shown once)
- Encrypted Tokens: Dynamically generated tokens with member context
Available Scopes
Scopes define permissions for things Workspace members can do with the app:
Account Scopes
account:read- Read account informationaccount:write- Update account informationaccount:create- Create new accounts (dangerous)
Workspace Scopes
workspace:read- Read workspace information and settingsworkspace:write- Update workspace settingsworkspace:delete- Delete workspaces (dangerous)
Member Scopes
members:read- Read member informationmembers:write- Update member informationmembers:admin- Full member management (dangerous)
Task Scopes
task:read- Read task configurationstask:write- Create and update taskstask:delete- Delete taskstask:execute- Execute tasks and manage assignments
Data Scopes
data:read- Read data types and recordsdata:write- Create and update data recordsdata:delete- Delete data recordsdata:admin- Full data management including schema changes (dangerous)
Chat Scopes
chats:read- Read chat messages and historychats:write- Send messages and create chatschats:admin- Manage all chats
Agent Scopes
assistants:read- Read agent configurationsassistants:write- Create and update agentsassistants:admin- Full agent management
Workflow Scopes
workflows:read- Read workflow configurationsworkflows:write- Create and update workflowsworkflows:delete- Delete workflows
Site Scopes
sites:read- Read site configurations and pagessites:write- Create and update sites and pagessites:publish- Publish sites and manage domains
Export Scopes
export:read- Export workspace dataexport:read-all- Export all workspace data including sensitive information (dangerous)
Admin Scope
admin:superuser- Full system administration (dangerous)
Creating an App
Via the Web Interface
- Navigate to Settings → Apps
- If you haven't already, create a "Builder" profile from the "Builder Profiles" tab
- Click Create App
- Fill in the application details:
- Name: A descriptive name for your application
- Description: Optional description of what the application does
- Workspace Restrictions: Optionally limit the app to specific workspaces
- Builder Profile: Select the builder profile you'd like to associate with the app
- Click Create Application
- Important: Copy and securely store the client secret - it will only be shown once!
Application Settings
When creating or editing an application, you can configure:
- Name and Description: Identify your application
- Workspace Restrictions: Limit the application to specific workspace UUIDs
- Active Status: Enable or disable the application
Note: Scopes are NOT configured at the application level. They are specified when members create grants.
How Apps Work
1. Member Authorization
Workspace members grant permissions to Apps by creating AppGrants:
- Personal grants: Accessible only by the member who created them
- Shared grants: Workspace-wide access (requires admin permissions)
2. Token Generation
When an Application needs access:
- Gravity Rail generates an encrypted token containing member context
- The token uses two-layer encryption:
- Inner layer: API token encrypted with system secret (opaque to OAuth app)
- Outer layer: Wrapper encrypted with client secret (decryptable by OAuth app)
- Token format:
gr_app_<client_id>:<encrypted_payload>
3. Using Encrypted Tokens
Apps decrypt the outer layer to access the API token:
python
Managing Apps
Viewing Apps
- Go to Settings → Apps
- View all your applications in the data table
- See status and creation details
Viewing Credentials
- Click the Key icon next to an application
- View the Client ID (always visible)
- Client Secret is only shown once during creation
Editing Apps
- Click the Edit icon next to an application
- Update name, description, or status
- Add or remove workspace restrictions
- Click Save Changes
Regenerating Client Secret
If your client secret is compromised:
- Click the Refresh icon next to the application
- A new client secret will be generated
- Copy and store the new secret securely
- Update your integrations with the new secret
- The old secret immediately becomes invalid
Deleting Apps
- Click the Delete icon next to an application
- Confirm the deletion
- All associated AppGrants will be invalidated
- Any integrations using this application will stop working
Member Grants (AppGrants)
Creating Grants
Members create grants to authorize Apps in their workspaces:
- The application requests specific scopes
- The member reviews and approves permissions
- An AppGrant is created with the approved scopes
- Tokens can now be generated for this grant
Shared Grants
Workspace administrators can create shared grants:
- Provide workspace-wide access to all members
- Only one shared grant per application per workspace
- Requires
manage_workspacepermission - Useful for common tools used by entire teams
Revoking Grants
Members can revoke grants at any time:
- Navigate to workspace settings
- View active AppGrants
- Revoke specific grants
- Tokens for revoked grants immediately become invalid
Best Practices
Security
- Never expose client secrets in client-side code or public repositories
- Store credentials securely using environment variables or secret management systems
- Rotate secrets regularly especially if there's any suspicion of compromise
- Request minimum required scopes when creating grants
- Monitor grant usage for suspicious activity
- Use HTTPS only when making API requests
- Handle token expiry gracefully (tokens are short-lived)
Implementation
- Understand two-layer encryption for proper token handling
- Decrypt tokens correctly using the client secret
- Handle grant revocation gracefully in your application
- Log authentication events for debugging and auditing
- Respect member permissions and scope limitations
Organization
- Use descriptive names for applications to identify their purpose
- Document integration details including which systems use which applications
- Separate applications by environment (development, staging, production)
- Restrict workspace access when applications only need specific workspace access
- Regularly audit your Apps and remove unused ones
MCP Server Integration
The Gravity Rail MCP (Model Context Protocol) server supports OAuth authentication:
bash
Integration Examples
Python (OAuth Application)
python
JavaScript/TypeScript (OAuth Application)
typescript
Troubleshooting
Decryption Failed
Problem: Cannot decrypt the token's outer layer
Solutions:
- Verify the client secret is correct (base64url-encoded 16-byte key)
- Ensure proper base64url decoding (may need padding)
- Check you're using the correct encryption algorithm (A128GCM)
Grant Not Found
Problem: Token generation fails with grant not found
Solutions:
- Verify the member has created an AppGrant for your application
- Check the grant hasn't been revoked
- Ensure the requested scopes match the granted scopes
- For shared grants, verify the creator had admin permissions
Token Expired
Problem: Getting 401 Unauthorized errors
Solutions:
- Tokens are short-lived (5 minutes for MCP)
- Request new tokens as needed
- Don't cache tokens for extended periods
Workspace Access Denied
Problem: Getting 403 Forbidden for workspace operations
Solutions:
- Check if the application has workspace restrictions
- Verify the member has access to the workspace
- Ensure the AppGrant is for the correct workspace
- Check scope permissions match the operation
Key Differences from Traditional OAuth
- No Token Exchange: No
/tokenendpoint - tokens generated via AppGrants - Member-Based: Permissions granted by workspace members, not accounts
- Two-Layer Encryption: Nested encryption for enhanced security
- Dynamic Generation: Tokens created on-demand, not stored
- Grant-Level Scopes: Scopes defined when creating grants, not applications
Support
For additional help with Apps, contact support for assistance with specific issues.
Related Resources
Template Variables
Personalize messages and notifications with dynamic variables like member names and form data.
Toolkits
Create custom tools and integrate external services for your AI workflows.
Healthcare MCP Integration Examples
Healthcare-specific examples for connecting EHR systems, scheduling, lab results, pharmacy, and clinical decision support via MCP and custom toolkits.
All Guides
Browse all available guides