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

# Create Policy Assignment

> Bind an access-shaping rule to a role.



## OpenAPI

````yaml POST /orgs/{org_id}/k2/{kb_id}/policies/{policy_id}/assignments
openapi: 3.1.0
info:
  title: Timbal Platform API
  description: Public API documentation for the Timbal platform
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.timbal.ai
    description: Production
  - url: https://api.dev.timbal.ai
    description: Development
security: []
tags:
  - name: ace
    description: Action Control Engine (ACE) operations
  - name: analytics
    description: Org and project analytics
  - name: billing
    description: Subscriptions, usage, and payment-related operations
  - name: content
    description: Re-sign stored content URLs
  - name: files
    description: File operations
  - name: iam
    description: IAM — actions, roles, users, and authorization introspection
  - name: k2
    description: Knowledge Bases v2 operations
  - name: orgs
    description: Organization operations
  - name: projects
    description: Project operations
  - name: runs
    description: Execution operations
  - name: templates
    description: Public project template catalog
  - name: users
    description: Authenticated user profile
paths:
  /orgs/{org_id}/k2/{kb_id}/policies/{policy_id}/assignments:
    post:
      tags:
        - k2
      description: Bind an access-shaping rule to a role.
      operationId: create
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
        - name: policy_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateK2PolicyAssignmentRequest'
        required: true
      responses:
        '201':
          description: Assignment created or re-attached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/K2PolicyAssignment'
        '400':
          description: Invalid binding body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '404':
          description: Policy or role not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      security:
        - bearer_auth: []
components:
  schemas:
    CreateK2PolicyAssignmentRequest:
      type: object
      required:
        - role_id
      properties:
        combine_mode:
          $ref: '#/components/schemas/K2PolicyCombineMode'
        enabled:
          type: boolean
        priority:
          type: integer
          format: int32
        role_id:
          type: string
        valid_from:
          type:
            - string
            - 'null'
          format: date-time
        valid_until:
          type:
            - string
            - 'null'
          format: date-time
    K2PolicyAssignment:
      type: object
      required:
        - id
        - policy_id
        - role_id
        - enabled
        - priority
        - combine_mode
        - granted_at
        - created_at
        - updated_at
      properties:
        combine_mode:
          $ref: '#/components/schemas/K2PolicyCombineMode'
        created_at:
          type: string
          format: date-time
        enabled:
          type: boolean
        granted_at:
          type: string
          format: date-time
        granted_by:
          type:
            - string
            - 'null'
        id:
          type: string
        policy_id:
          type: string
        priority:
          type: integer
          format: int32
        revoked_at:
          type:
            - string
            - 'null'
          format: date-time
        revoked_by:
          type:
            - string
            - 'null'
        role_id:
          type: string
        updated_at:
          type: string
          format: date-time
        valid_from:
          type:
            - string
            - 'null'
          format: date-time
        valid_until:
          type:
            - string
            - 'null'
          format: date-time
    ErrorMessage:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Machine-readable error code (e.g. `ALREADY_EXISTS`, `BAD_REQUEST`).
        message:
          type: string
          description: Human-readable description.
    K2PolicyCombineMode:
      type: string
      description: Postgres-RLS-style combination semantic for a policy binding.
      enum:
        - restrictive
        - permissive
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: >-
        Timbal API key. Obtain your API key from the Timbal platform settings.
        See [Authentication](/api-reference/authentication) for more
        information.

````