Skip to main content

Evaluate Access

Check whether a subject is allowed to perform an action on a resource.

POST /policy-srv/v1/evaluate

This is the primary endpoint your application calls to make authorization decisions.

Request

Headers

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Body

{
"subject": {
"id": "user-123",
"type": "user",
"attributes": {
"department": "engineering"
},
"roles": ["editor"]
},
"resource": {
"type": "document",
"id": "doc-456",
"attributes": {
"classification": "internal"
}
},
"action": "read",
"context": {
"ip_address": "192.168.1.1"
}
}

Fields

FieldTypeRequiredDescription
subject.idstringYesUnique identifier of the subject
subject.typestringYesType of subject (e.g., user, service)
subject.attributesobjectNoKey-value attributes for the subject
subject.rolesstring[]NoRoles assigned to the subject
resource.typestringYesResource type (must match a defined resource type)
resource.idstringYesUnique identifier of the resource
resource.attributesobjectNoKey-value attributes for the resource
actionstringYesThe action being requested (e.g., read, write, delete)
contextobjectNoAdditional context for policy evaluation
Minimal request

At minimum, you need subject.id, subject.type, resource.type, resource.id, and action:

{
"subject": { "id": "user-123", "type": "user" },
"resource": { "type": "document", "id": "doc-456" },
"action": "read"
}

Response

Access allowed

{
"allowed": true,
"reason": "Policy 'editors-can-read-write' grants access",
"policy_id": "550e8400-e29b-41d4-a716-446655440000",
"access_path": "role"
}

Access denied

{
"allowed": false,
"reason": "No matching policy found"
}

Fields

FieldTypeDescription
allowedbooleanWhether access is granted
reasonstringHuman-readable explanation
policy_idstringID of the matching policy (if allowed)
access_pathstringHow access was granted: "direct", "role", or "group"

Error responses

StatusDescription
400Invalid request body
401Missing or invalid API key
500Internal evaluation error

Example

curl -X POST https://api.authzx.com/policy-srv/v1/evaluate \
-H "Authorization: Bearer ak_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"subject": { "id": "user-123", "type": "user" },
"resource": { "type": "document", "id": "doc-456" },
"action": "read"
}'

Performance

The evaluate endpoint is designed for low-latency, high-throughput use:

  • Policies are cached for fast evaluation
  • In-memory policy engine
  • Typical response time: < 30ms