> ## Documentation Index
> Fetch the complete documentation index at: https://docs.startree.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Simulate access

> Evaluates whether a subject would be allowed to perform an action on a resource, taking every role
assigned to the subject into account. Pass `policyDocumentJson` to test a policy document that is
not saved yet. Policy changes can take up to an hour to propagate, so test here before saving.




## OpenAPI

````yaml api-reference/rbac/openapi.yaml POST /simulate-access
openapi: 3.0.3
info:
  title: StarTree RBAC Manager API
  description: >
    Manage role-based access control (RBAC) in StarTree Cloud: policies, roles,
    the policies attached to each

    role, the subjects (users, groups, domains, service tokens) assigned to each
    role, and service tokens.


    Every request needs an `Authorization: Bearer <token>` header. See

    [Generating an API
    Token](/corecapabilities/security/manage-api-tokens#generating-an-api-token).


    Resources are identified by StarTree Resource Names (SRNs), for example
    `srn2:policy#my-policy` or

    `srn2:role#table-reader`. When an SRN appears in a URL path, encode the `#`
    as `%23`

    (`/policies/srn2:policy%23my-policy`).


    For a guided walkthrough of these endpoints, see

    [Using the RBAC API](/corecapabilities/security/using-rbac-api).
  version: '1.0'
servers:
  - url: '{baseUrl}/api/v1/rbac-manager'
    variables:
      baseUrl:
        default: https://rbac-manager.your-env.startree.cloud
        description: >-
          RBAC Manager URL of your StarTree Cloud environment without a trailing
          slash, e.g. https://rbac-manager.<env>.startree.cloud
security:
  - bearerAuth: []
tags:
  - name: Policies
    description: >-
      Create, list, update, and delete policies. A policy document says which
      actions are allowed or denied on which resources.
  - name: Roles
    description: >-
      Create, list, update, and delete roles. A role groups one or more
      policies.
  - name: Role policies
    description: Attach policies to roles and inspect what a role grants.
  - name: Role assignments
    description: Grant a role to users, groups, email domains, or service tokens.
  - name: Service tokens
    description: >-
      Bearer tokens for programmatic access. A token is unusable until it is
      assigned a role.
  - name: Access simulation
    description: >-
      Check what a subject would be allowed to do, before or after saving a
      policy.
paths:
  /simulate-access:
    post:
      tags:
        - Access simulation
      summary: Simulate access
      description: >
        Evaluates whether a subject would be allowed to perform an action on a
        resource, taking every role

        assigned to the subject into account. Pass `policyDocumentJson` to test
        a policy document that is

        not saved yet. Policy changes can take up to an hour to propagate, so
        test here before saving.
      operationId: simulateAccess
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SimulationInput'
      responses:
        '200':
          description: Simulation result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimulationResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    SimulationInput:
      type: object
      required:
        - subjectTypeToSubject
        - action
        - resourceSrn2String
      properties:
        subjectTypeToSubject:
          type: object
          description: >-
            The subject to simulate, as a map from subject type to subject. Use
            the same subject types as role assignments.
          additionalProperties:
            type: string
          example:
            user-email: jane.doe@example.com
        action:
          type: string
          description: >-
            The action to test, for example `query`. See
            [Actions](/corecapabilities/security/actions).
          example: query
        resourceSrn2String:
          type: string
          description: SRN of the resource to test access to.
          example: srn2:cluster#my-cluster:table#myTable
        policyDocumentJson:
          $ref: '#/components/schemas/PolicyDocumentJson'
        usePrincipal:
          type: boolean
          default: true
          description: >-
            When true (the default), the caller's own roles are evaluated
            together with `subjectTypeToSubject`. Set to false to evaluate only
            the subjects you pass.
    SimulationResult:
      type: object
      properties:
        result:
          type: boolean
          description: True if the action would be allowed.
          example: true
        info:
          type: string
          description: Names of the policies that were loaded for the evaluation.
    PolicyDocumentJson:
      type: string
      description: >
        The policy document as a JSON string (escape the inner quotes). See

        [Custom Policy
        Configuration](/corecapabilities/security/custom-policies) for the
        format.
      example: >-
        {"version":"v1","statements":[{"effect":"allow","actions":["query"],"resources":["srn2:cluster#*:table#myTable"]}]}
    Error:
      type: object
      properties:
        timestamp:
          type: string
          format: date-time
        status:
          type: integer
          example: 404
        error:
          type: string
          example: Not Found
        message:
          type: string
          example: Not Found.
        path:
          type: string
          example: /api/v1/rbac-manager/policies/srn2:policy%23missing
  responses:
    BadRequest:
      description: >-
        The request body is missing a required field or refers to a resource
        that does not exist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The caller's roles do not allow this RBAC operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A StarTree API token or a service token (`st-<accessKey>-<secretKey>`).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.