Skip to main content
The Schema API monitors schema changes and detects drift in your data assets. Use it to track column additions, removals, type changes, and trigger on-demand schema checks.

Endpoints

MethodEndpointDescription
GET/api/v1/sdk/schema/summaryGet schema drift summary
GET/api/v1/sdk/schema/changesList recent schema changes
POST/api/v1/sdk/schema/{id}/refreshTrigger schema check

Get Schema Summary

GET /api/v1/sdk/schema/summary
Returns aggregate schema drift statistics.
curl -H "Authorization: Bearer aa_live_xxx" \
  "https://api.anomalyarmor.ai/api/v1/sdk/schema/summary"

Response

{
  "data": {
    "total_assets": 245,
    "assets_with_changes": 12,
    "changes_last_24h": 5,
    "changes_last_7d": 23,
    "by_change_type": {
      "column_added": 15,
      "column_removed": 3,
      "column_type_changed": 8,
      "column_renamed": 2
    }
  }
}

List Schema Changes

GET /api/v1/sdk/schema/changes

Query Parameters

ParameterTypeDefaultDescription
asset_idstring-Filter by asset qualified name
change_typestring-Filter by change type
sincedatetime-Changes since timestamp
limitinteger50Max results
offsetinteger0Results to skip
curl -H "Authorization: Bearer aa_live_xxx" \
  "https://api.anomalyarmor.ai/api/v1/sdk/schema/changes?change_type=column_removed"

Response

{
  "data": [
    {
      "id": "change_123",
      "asset_id": "550e8400-e29b-41d4-a716-446655440000",
      "qualified_name": "snowflake.prod.warehouse.orders",
      "change_type": "column_added",
      "column_name": "discount_code",
      "details": {
        "new_type": "VARCHAR(50)",
        "nullable": true
      },
      "detected_at": "2024-12-04T09:15:00Z",
      "previous_schema_hash": "abc123",
      "current_schema_hash": "def456"
    }
  ],
  "pagination": {
    "total": 23,
    "limit": 50,
    "offset": 0,
    "has_more": false
  }
}

Trigger Schema Check

POST /api/v1/sdk/schema/{id}/refresh
Requires read-write or admin scope.

Query Parameters

ParameterTypeDefaultDescription
waitbooleanfalseWait for check to complete
curl -X POST -H "Authorization: Bearer aa_live_xxx" \
  "https://api.anomalyarmor.ai/api/v1/sdk/schema/snowflake.prod.warehouse.orders/refresh?wait=true"

Response

{
  "data": {
    "job_id": "job_xyz789",
    "status": "completed",
    "asset_id": "snowflake.prod.warehouse.orders",
    "result": {
      "changes_detected": true,
      "changes": [
        {
          "change_type": "column_added",
          "column_name": "discount_code",
          "details": {"new_type": "VARCHAR(50)"}
        }
      ]
    }
  }
}

Change Types

TypeDescription
column_addedNew column added to table
column_removedColumn removed from table
column_type_changedColumn data type changed
column_renamedColumn name changed
table_createdNew table created
table_droppedTable dropped

Use Case: Post-Deploy Schema Check

Trigger a schema check after deploying dbt models:
from anomalyarmor import Client

client = Client()

def verify_schema_after_deploy(models: list[str]):
    """Run schema check after dbt deployment."""
    for model in models:
        print(f"Checking schema: {model}")
        result = client.schema.refresh(model, wait=True)

        if result.changes_detected:
            print(f"  Schema changes detected:")
            for change in result.changes:
                print(f"    - {change.change_type}: {change.column_name}")
        else:
            print(f"  No schema changes")

# After dbt run
verify_schema_after_deploy([
    "snowflake.prod.mart.orders_mart",
    "snowflake.prod.mart.customers_mart",
])