dbtrail

Access Rules

Manage role-based table and column access rules

Create, list, update, and delete access rules that control which tables and columns each role can see. Requires the access_rules:manage permission (owner or admin role).

Plan availability

Access Rules is available on Pro, Premium, and Enterprise plans.

Endpoints

MethodEndpointPermissionDescription
GET/access-rulesaccess_rules:manageList all rules for the current tenant
POST/access-rulesaccess_rules:manageCreate a rule
PUT/access-rules/{rule_id}access_rules:manageUpdate a rule's columns
DELETE/access-rules/{rule_id}access_rules:manageDelete a rule

List rules

GET /access-rules

Returns all access rules for the current tenant, ordered by role, schema, table, and effect.

Response

[
  {
    "id": "a1b2c3d4-...",
    "role": "analyst",
    "schema_name": "mydb",
    "table_name": "users",
    "columns": ["id", "name", "email"],
    "effect": "allow",
    "warnings": []
  }
]

Create a rule

POST /access-rules

Request body

{
  "role": "analyst",
  "schema_name": "mydb",
  "table_name": "users",
  "columns": ["id", "name", "email"],
  "effect": "allow"
}
FieldTypeRequiredDefaultDescription
rolestringyesTarget role (operator, analyst, or viewer)
schema_namestringyesMySQL schema name
table_namestringyesMySQL table name
columnsarrayno["*"]Column list (see column patterns)
effectstringno"allow""allow" or "deny"

Response (201)

{
  "id": "a1b2c3d4-...",
  "role": "analyst",
  "schema_name": "mydb",
  "table_name": "users",
  "columns": ["email", "id", "name"],
  "effect": "allow",
  "warnings": []
}

Columns are normalized: duplicates are removed, values are sorted alphabetically, and ["*"] is simplified to a single wildcard entry.

Collision warnings

If a conflicting rule already exists (e.g., creating an allow rule when a deny rule exists for the same role and table), the response includes warnings:

{
  "id": "a1b2c3d4-...",
  "role": "analyst",
  "schema_name": "mydb",
  "table_name": "users",
  "columns": ["id", "name", "email"],
  "effect": "allow",
  "warnings": [
    {
      "message": "Conflicting deny rule exists for analyst on mydb.users (columns: [\"ssn\", \"credit_card\"]). Deny rules take priority over allow rules.",
      "conflicting_rule_id": "e5f6g7h8-...",
      "conflicting_effect": "deny"
    }
  ]
}

Errors

StatusReason
409A rule with the same role, schema, table, and effect already exists
422Invalid role, schema/table name, or empty columns list

Update a rule

PUT /access-rules/{rule_id}

Updates the columns for an existing rule. The role, schema, table, and effect are immutable — to change them, delete the rule and create a new one.

Request body

{
  "columns": ["id", "name", "email", "created_at"]
}
FieldTypeRequiredDescription
columnsarrayyesNew column list

Response (200)

Returns the updated rule with the same shape as the create response, including any collision warnings.

Errors

StatusReason
404Rule not found
422Empty columns list

Delete a rule

DELETE /access-rules/{rule_id}

Deletes an access rule. Returns 204 No Content on success.

Errors

StatusReason
404Rule not found

Schemas

AccessRuleResponse

FieldTypeDescription
idstringRule UUID
rolestringTarget role
schema_namestringMySQL schema name
table_namestringMySQL table name
columnsarrayColumn list
effectstring"allow" or "deny"
warningsarrayCollision warnings (empty if none)

CollisionWarning

FieldTypeDescription
messagestringHuman-readable description of the conflict
conflicting_rule_idstringUUID of the conflicting rule
conflicting_effectstringEffect of the conflicting rule ("allow" or "deny")

On this page