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

# Replace object access grants



## OpenAPI

````yaml https://app-api.costory.io/docs/openapi.json put /access/{resourceKind}/{resourceId}/grants
openapi: 3.0.0
info:
  title: Costory
  version: '1.0'
  description: API Documentation
servers:
  - url: ''
    description: Production server
security: []
paths:
  /access/{resourceKind}/{resourceId}/grants:
    put:
      tags:
        - Access
      summary: Replace object access grants
      parameters:
        - schema:
            type: string
            enum:
              - dashboard
              - report
              - budget
              - costAlert
          required: true
          name: resourceKind
          in: path
        - schema:
            type: string
            minLength: 1
          required: true
          name: resourceId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                grants:
                  type: array
                  items:
                    oneOf:
                      - type: object
                        properties:
                          principalType:
                            type: string
                            enum:
                              - USER
                          userId:
                            type: string
                            minLength: 1
                          role:
                            type: string
                            enum:
                              - READER
                              - EDITOR
                              - ADMIN
                        required:
                          - principalType
                          - userId
                          - role
                      - type: object
                        properties:
                          principalType:
                            type: string
                            enum:
                              - TEAM
                          teamId:
                            type: string
                            minLength: 1
                          role:
                            type: string
                            enum:
                              - READER
                              - EDITOR
                              - ADMIN
                        required:
                          - principalType
                          - teamId
                          - role
                      - type: object
                        properties:
                          principalType:
                            type: string
                            enum:
                              - ORGANIZATION
                          role:
                            type: string
                            enum:
                              - READER
                              - EDITOR
                              - ADMIN
                        required:
                          - principalType
                          - role
                      - type: object
                        properties:
                          principalType:
                            type: string
                            enum:
                              - CLERK_ADMIN
                          role:
                            type: string
                            enum:
                              - READER
                              - EDITOR
                              - ADMIN
                        required:
                          - principalType
                          - role
                  description: >-
                    Full replacement of direct grants. Omitted principals lose
                    access. Every object must retain a USER, TEAM, or
                    CLERK_ADMIN Admin grant. Each principal may appear once.
              required:
                - grants
      responses:
        '200':
          description: Grants after the replacement
          content:
            application/json:
              schema:
                type: object
                properties:
                  grants:
                    type: array
                    items:
                      oneOf:
                        - type: object
                          properties:
                            id:
                              type: string
                            principalType:
                              type: string
                              enum:
                                - USER
                            role:
                              type: string
                              enum:
                                - READER
                                - EDITOR
                                - ADMIN
                            userId:
                              type: string
                            name:
                              type: string
                            email:
                              type: string
                              nullable: true
                            avatar:
                              type: string
                              nullable: true
                          required:
                            - id
                            - principalType
                            - role
                            - userId
                            - name
                            - email
                            - avatar
                        - type: object
                          properties:
                            id:
                              type: string
                            principalType:
                              type: string
                              enum:
                                - TEAM
                            role:
                              type: string
                              enum:
                                - READER
                                - EDITOR
                                - ADMIN
                            teamId:
                              type: string
                            name:
                              type: string
                          required:
                            - id
                            - principalType
                            - role
                            - teamId
                            - name
                        - type: object
                          properties:
                            id:
                              type: string
                            principalType:
                              type: string
                              enum:
                                - ORGANIZATION
                            role:
                              type: string
                              enum:
                                - READER
                                - EDITOR
                                - ADMIN
                          required:
                            - id
                            - principalType
                            - role
                        - type: object
                          properties:
                            id:
                              type: string
                            principalType:
                              type: string
                              enum:
                                - CLERK_ADMIN
                            role:
                              type: string
                              enum:
                                - READER
                                - EDITOR
                                - ADMIN
                          required:
                            - id
                            - principalType
                            - role
                  callerRole:
                    type: string
                    nullable: true
                    enum:
                      - READER
                      - EDITOR
                      - ADMIN
                      - null
                  capabilities:
                    type: object
                    properties:
                      canView:
                        type: boolean
                      canEdit:
                        type: boolean
                      canManage:
                        type: boolean
                    required:
                      - canView
                      - canEdit
                      - canManage
                  availableRoles:
                    type: array
                    items:
                      type: string
                      enum:
                        - READER
                        - EDITOR
                        - ADMIN
                required:
                  - grants
                  - callerRole
                  - capabilities
                  - availableRoles
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
      security:
        - bearerAuth: []
components:
  schemas:
    BadRequest:
      type: object
      properties:
        error:
          type: string
          description: Error code
        reason:
          type: string
          description: Human-readable reason
        details:
          description: Additional details
        summary:
          type: string
          description: Optional short summary
      required:
        - error
    Unauthorized:
      type: object
      properties:
        error:
          type: string
          description: Unauthorized error message
      required:
        - error
    NotFound:
      type: object
      properties:
        error:
          type: string
          description: Resource not found error code
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT or Clerk ak_* API key
      description: >-
        Send `Authorization: Bearer <credential>` using either a Clerk session
        JWT or a Clerk API key (`ak_*`). API keys may identify a user (`user_*`)
        or organization (`org_*`) principal and are generated in the Clerk
        Dashboard under API keys.

````

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