Skip to content
API Now! is currently in closed beta. We are constantly updating these guides as we release updates!

Match Resource Owner

The Match Resource Owner (matchResourceOwner) access rule restricts API operations based on direct resource ownership. It ensures that users can only access or modify records that belong to them (or their own user account record).


  • Direct Ownership Verification: The engine evaluates whether the authenticated caller’s User ID matches the owner field of the resource.
  • Automatic Collection Scoping (FETCH): On list and search queries, the engine automatically injects a WHERE owner_id = :userId clause into the database query so users only retrieve their own records.
  • Pre-Execution Detail Checks (PRE_FETCH): On read, update, and delete actions, the engine checks ownership before executing the operation.
  • Inherited vs. Direct Ownership: Match Resource Owner handles direct ownership (a direct link to User or the User entity itself). If ownership is inherited through a parent or ancestor entity (e.g. a comment owned via an article), use Match Relational Resource Owner instead.
PropertySpecification
Rule TypematchResourceOwner
Supported StrategiesAll strategies (RBAC, OrganizationRBAC, EnterpriseRBAC)
Allowed Placement LevelsExposed Entity Level (exposure), Action Level (action) (Not allowed at global API Model Level)
Execution PhasesFETCH (list, search), PRE_FETCH (read, update, delete, link, unlink)

When you add Match Resource Owner to an Access Scenario, the platform automatically resolves how ownership is verified based on the entity:

1. Direct Association to User (ResourceOwnerIdentifier)

Section titled “1. Direct Association to User (ResourceOwnerIdentifier)”

For standard resource entities (e.g. Article, Project, Invoice, TimeLog):

  • The resource entity must have a direct association pointing to the User entity.
  • This association must be annotated with the ResourceOwnerIdentifier semantic module in your Data Domain.
  • The platform automatically detects this annotated association to resolve the owner foreign key column (e.g. author_id, user_id, client_id).
  • Collection Queries (list, search) in FETCH Phase: Automatically injects WHERE <owner_id> = :current_user_id into the SQL query so callers only receive their own records.
  • Single-Record Actions (read, update, delete) in PRE_FETCH Phase: Executes a targeted database check ensuring the requested record ID belongs to :current_user_id before executing the action.

2. The User Entity Itself (Self-Profile Actions)

Section titled “2. The User Entity Itself (Self-Profile Actions)”

When the rule is applied directly to the User entity (e.g., GET /users/:id or PATCH /users/:id):

  • The platform automatically recognizes that the resource being operated on is the user record itself.
  • Ownership is evaluated in-memory by verifying that the route parameter matches the authenticated caller’s User ID (String(params.id) === String(currentUser.id)).

create Actions Do Not Use Match Resource Owner

Match Resource Owner cannot be used on create (POST) actions because the record does not exist in the database prior to execution.

How creation is handled instead:

  1. Gate the create action using Allow Authenticated or Match User Role.
  2. Tag the owner foreign key in your Data Domain with the ResourceOwnerIdentifier semantic module.
  3. The platform will automatically populate the owner foreign key with the authenticated user’s ID upon creation. Any values submitted in the POST request body for this foreign key are ignored—the authenticated user from the session is always assigned as the owner to prevent spoofing.

  • User Entity Endpoints: The entity must be annotated with the User semantic module.
  • Resource Entity Endpoints: The target entity must have an association pointing to the User entity, annotated with the ResourceOwnerIdentifier semantic module.

Pattern 1: User Self-Profile Management (target: 'user-entity')

Section titled “Pattern 1: User Self-Profile Management (target: 'user-entity')”

Allow users to view and update only their own profile:

graph LR
    subgraph "User Entity Actions (/users/:id)"
        Read["GET /:id (Read)"] -->|Allow Authenticated| LoggedIn["Any Logged-in User"]
        Update["PATCH /:id (Update)"] -->|Match Resource Owner: user-entity| Self["Owner Only (Self)"]
        Delete["DELETE /:id (Delete)"] -->|Match User Role: admin| Admin["Admins Only"]
    end

Pattern 2: Creator-Owned Content with Admin Override (target: 'association')

Section titled “Pattern 2: Creator-Owned Content with Admin Override (target: 'association')”

Allow users to manage their own content while giving administrators full management override:

Article.update Scenarios:
├── Scenario 1 (Admin Override):
│ └── Match User Role: ['admin'] <- Evaluated 1st: Admins can edit any article
└── Scenario 2 (Author Self-Management):
├── Allow Authenticated <- Evaluated 2nd: Must be logged in
└── Match Resource Owner (author) <- Must be the article's direct author

Caller StateEndpoint ConfigurationResulting HTTP Status
Anonymous (No token)Endpoint requires Match Resource Owner401 Unauthorized
Caller is Resource OwnerUser’s ID matches the resource’s owner foreign key (or user PK)200 OK / 204 No Content
Caller is NOT Resource OwnerUser’s ID does not match the resource owner403 Forbidden
Resource Does Not ExistID provided in path does not exist in database404 Not Found