Skip to main content
POST
http://localhost:3000
/
resource-policies
/
batch
curl -X POST 'https://api.example.com/resource-policies/batch' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '[
    {
      "scopeId": "scope_org",
      "name": "Finance Read Access",
      "target": {
        "kind": "collection",
        "collectionId": "collection_finance_docs"
      },
      "actions": ["read"],
      "effect": "allow",
      "subjectCondition": {
        "==": [{"var": "subject.meta.department"}, "finance"]
      }
    },
    {
      "scopeId": "scope_org",
      "name": "Block Archived",
      "target": {
        "kind": "collection",
        "collectionId": "collection_archived"
      },
      "actions": ["*"],
      "effect": "deny",
      "priority": 100
    }
  ]'
[
  {
    "id": "policy_0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5b",
    "scopeId": "scope_org",
    "name": "Finance Read Access",
    "target": {
      "kind": "collection",
      "collectionId": "collection_finance_docs"
    },
    "actions": ["read"],
    "effect": "allow",
    "subjectCondition": {
      "==": [{"var": "subject.meta.department"}, "finance"]
    },
    "createdAt": "2024-01-15T10:30:00Z"
  },
  {
    "id": "policy_0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5c",
    "scopeId": "scope_org",
    "name": "Block Archived",
    "target": {
      "kind": "collection",
      "collectionId": "collection_archived"
    },
    "actions": ["*"],
    "effect": "deny",
    "priority": 100,
    "createdAt": "2024-01-15T10:30:00Z"
  }
]

Request Body

Array of resource policy objects to create.
[].id
string
Optional client-provided ID. Format: policy_{uuidv7}
[].scopeId
string
required
ID of the scope where policy is defined
[].name
string
required
Display name for the policy
[].target
object
required
Resource or collection to target
[].actions
array
required
Actions this policy applies to
[].effect
string
required
Policy effect: allow or deny
[].priority
number
default:"0"
Higher priority policies are evaluated first
[].subjectCondition
object
JSON Logic condition to match the actor
[].contextCondition
object
JSON Logic condition to match request context

Response

Returns an array of created resource policy objects.
curl -X POST 'https://api.example.com/resource-policies/batch' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '[
    {
      "scopeId": "scope_org",
      "name": "Finance Read Access",
      "target": {
        "kind": "collection",
        "collectionId": "collection_finance_docs"
      },
      "actions": ["read"],
      "effect": "allow",
      "subjectCondition": {
        "==": [{"var": "subject.meta.department"}, "finance"]
      }
    },
    {
      "scopeId": "scope_org",
      "name": "Block Archived",
      "target": {
        "kind": "collection",
        "collectionId": "collection_archived"
      },
      "actions": ["*"],
      "effect": "deny",
      "priority": 100
    }
  ]'
[
  {
    "id": "policy_0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5b",
    "scopeId": "scope_org",
    "name": "Finance Read Access",
    "target": {
      "kind": "collection",
      "collectionId": "collection_finance_docs"
    },
    "actions": ["read"],
    "effect": "allow",
    "subjectCondition": {
      "==": [{"var": "subject.meta.department"}, "finance"]
    },
    "createdAt": "2024-01-15T10:30:00Z"
  },
  {
    "id": "policy_0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5c",
    "scopeId": "scope_org",
    "name": "Block Archived",
    "target": {
      "kind": "collection",
      "collectionId": "collection_archived"
    },
    "actions": ["*"],
    "effect": "deny",
    "priority": 100,
    "createdAt": "2024-01-15T10:30:00Z"
  }
]