Guides

Authentication

Secure programmatic access to Metroflow with API keys for scripts and CI, or OAuth service accounts for long-running integrations. Every REST request uses Bearer token authentication unless calling the unauthenticated health endpoint.

Overview

Metroflow supports two primary authentication modes for the REST API. Both resolve to a Bearer token presented on each request.

Scripts & CI

API keys

Static tokens prefixed with mf_live_ or mf_test_. Created per user or service principal in workspace Settings. Ideal for curl, GitHub Actions, and Airflow operators.

Integrations

OAuth service accounts

Client-credentials flow for server-to-server apps. Short-lived access tokens (1 hour) issued from a client ID and secret. Best for ETL platforms and embedded analytics backends.

Workspace UI login (email/password or SSO) is separate from API authentication. Browser sessions use HTTP-only cookies; API clients always use Bearer tokens.

API keys

API keys are long-lived secrets scoped to a workspace and role. They inherit the permissions of the user or service account that created them.

API keys are shown once at creation. Store them in a secrets manager; Metroflow only stores a salted hash.

Never embed keys in client-side code. API keys grant full access to workspace metadata. Use them only in server-side processes, CI secrets, or orchestration vaults.

OAuth & service accounts

For integrations that cannot store a static key, register an OAuth client in Settings → API → Service accounts. Metroflow implements the OAuth 2.0 client credentials grant.

  1. Create a service account

    Assign a role (analyst, engineer, or admin) and note the client_id and client_secret.

  2. Exchange credentials for an access token

    POST to the token endpoint. Access tokens expire in 3600 seconds; refresh by requesting a new token before expiry.

    token exchange
    $curl -s -X POST "https://your-metroflow-host/oauth/token" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -d "grant_type=client_credentials" \
    -d "client_id=sa_4f8c2a1b9e7d" \
    -d "client_secret=$CLIENT_SECRET" \
    -d "scope=read write"
    { "access_token": "eyJhbG...", "token_type": "Bearer", "expires_in": 3600 }
  3. Use the access token as a Bearer token

    Identical header format to API keys. No refresh token is issued; request a new access token when expires_in elapses.

Creating tokens

Workspace admins and users with the api:manage permission can create tokens from the UI.

  1. Open workspace Settings

    Sign in to the workspace at https://your-metroflow-host (or http://localhost:4200 locally).

  2. Navigate to Settings → API

    The API panel lists active tokens, service accounts, and audit logs for token usage.

  3. Click Create API token

    Name the token (e.g. github-actions-lineage), choose scope and optional expiry, then confirm.

  4. Copy the token immediately

    The full secret is displayed once. Paste it into your secrets manager before closing the dialog.

    example token
    mf_live_7f3a9c2e1b4d8a6f0e5c3b9a2d7f1e4

Naming convention: Prefix token names with the environment and consumer, e.g. prod-airflow-sync, staging-dbt-ci, so audit logs remain readable.

Bearer header format

All authenticated API requests must include the Authorization header. The scheme is always Bearer followed by a single space and the token value.

HeaderValueNotes
Authorization Bearer <token> Required on all endpoints except GET /health
Content-Type application/json Required for POST/PATCH bodies
X-Request-Id UUID (optional) Correlate logs; echoed in response headers
header
Authorization: Bearer mf_live_7f3a9c2e1b4d8a6f0e5c3b9a2d7f1e4

Malformed headers (missing Bearer, extra quotes, or newline characters) return 401 unauthorized with error code invalid_auth_header.

Request examples

Verify your token with a catalog query. Replace the host and token with your deployment values.

Health check (no auth)

shell
$curl -s "https://your-metroflow-host/api/v1/health" | jq .status
"ok"

Authenticated catalog request

shell
$export METROFLOW_TOKEN="mf_live_7f3a9c2e1b4d8a6f0e5c3b9a2d7f1e4"
$curl -s -G "https://your-metroflow-host/api/v1/catalog/assets" \
-H "Authorization: Bearer $METROFLOW_TOKEN" \
--data-urlencode "type=model" \
--data-urlencode "limit=5" | jq '.data[].name'
"fct_revenue"
"dim_customers"
"stg_orders"

Agent query with context

shell
$curl -s -X POST "https://your-metroflow-host/api/v1/agents/query" \
-H "Authorization: Bearer $METROFLOW_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query":"List certified finance metrics","context":{"tags":["finance"]}}' \
| jq '.answer'

Trigger connector sync

shell
$curl -s -X POST "https://your-metroflow-host/api/v1/connectors/conn_dbt_cloud_prod/sync" \
-H "Authorization: Bearer $METROFLOW_TOKEN" \
-H "Content-Type: application/json" | jq '.sync_id'
"sync_7b2e9f4a"

See the full endpoint reference in the REST API guide.

Token rotation best practices

Rotate credentials on a schedule and immediately after any suspected compromise. Metroflow supports overlapping tokens so rotation does not cause downtime.

  1. Create a new token before revoking the old one

    Issue the replacement in Settings → API, deploy it to your secrets manager, and validate with a read-only endpoint.

  2. Update all consumers

    Roll out the new secret to CI variables, Airflow connections, and Kubernetes secrets. Use distinct tokens per consumer to narrow blast radius.

  3. Revoke the previous token

    Revocation is immediate; outstanding requests with the old token receive 401. Audit logs record the revoking user and timestamp.

  4. Enforce expiry policies

    Admins can require maximum token TTL (e.g. 90 days) at the workspace level. Expired tokens cannot be renewed; create a new token instead.

EnvironmentRecommended rotationNotes
ProductionEvery 90 daysAutomate via secrets manager rotation hooks
CI / ephemeralPer pipeline or weeklyScope to read unless sync triggers are needed
After personnel changeImmediateRevoke all tokens owned by departing users

Incident response: Use Settings → API → Revoke all to invalidate every workspace token in one action. Re-issue tokens individually after root cause is contained.

Self-hosted OIDC

Self-hosted Metroflow deployments can delegate workspace UI login to an OpenID Connect provider (Okta, Azure AD, Google Workspace, or any OIDC-compliant IdP). API authentication remains Bearer-based; OIDC governs browser sessions only.

Configure OIDC in your .env or Helm values:

environment
METROFLOW_OIDC_ENABLED=true
METROFLOW_OIDC_ISSUER=https://login.acme.com/oauth2/default
METROFLOW_OIDC_CLIENT_ID=0oa8yz3example
METROFLOW_OIDC_CLIENT_SECRET=${OIDC_CLIENT_SECRET}
METROFLOW_OIDC_SCOPES=openid profile email groups
METROFLOW_OIDC_GROUP_CLAIM=groups

Map IdP groups to Metroflow roles in Settings → Access → SSO mappings. Users who authenticate via OIDC can still create API tokens from the workspace UI once logged in.

Air-gapped deployments: Disable OIDC and rely on local accounts plus API keys. LDAP/SAML bridge configurations are documented in the Deployment guide.

Security checklist

Before exposing the API beyond your VPC, confirm these controls are in place.

Metadata sensitivity: API responses include schema names, owners, and lineage, not row data. Treat tokens with the same care as warehouse credentials because they expose your full data topology.

Failed auth lockout: After 20 consecutive 401 attempts from one IP within 5 minutes, Metroflow temporarily blocks that source. Use exponential backoff in retry loops.

Next

REST API reference

Full endpoint catalog with parameters, examples, and error codes.

API reference →
Integrations

Connectors

Wire sources and trigger syncs from CI after authenticating.

Connectors guide →