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

# Sync Policy State

> Required permission: `policy-state.sync`.



## OpenAPI

````yaml /lib/api-spec/openapi.yaml post /api/v1/policy-state/sync
openapi: 3.1.0
info:
  title: airmux Control Plane API
  description: >
    Manage airmux organizations, workspaces, management keys, provider
    credentials, and data-plane synchronization.


    Organization and workspace targets are part of each URL. Successful
    responses wrap their result in

    `{"data": ...}`. Authenticate with a control-plane management key or a
    browser session as documented by

    each operation. Inference keys authenticate model requests at the data plane
    and are not accepted here.
  version: 0.1.0
servers: []
security: []
tags:
  - name: Auth
    description: Sign in human users, manage browser sessions, and authorize the CLI
    x-displayName: Authentication
  - name: Enrollment
    description: List a user's organizations and create their personal organization
  - name: Instance Organizations
    description: List and create organizations on this airmux instance
    x-displayName: Organizations
  - name: Instance Users
    description: Manage human users and service accounts across the instance
    x-displayName: Users
  - name: Instance Management Keys
    description: >-
      List management keys across the instance, issue instance-scoped
      credentials, and revoke keys
    x-displayName: Management Keys
  - name: Instance Model Catalog
    description: Manage the providers and models available through this airmux instance
    x-displayName: Model Catalog
  - name: Instance Provider Credentials
    description: Manage provider API keys available across the airmux instance
    x-displayName: Provider Credentials
  - name: Data Plane Instances
    description: Inspect connected data-plane instances
    x-displayName: Data Planes
  - name: Instance Activity
    description: Inspect recent audited changes across the instance
    x-displayName: Activity
  - name: OSS
    description: Bootstrap a new self-hosted airmux deployment
    x-displayName: Self-hosting
  - name: Organization Settings
    description: View, update, and delete one organization
    x-displayName: Settings
  - name: Organization Members
    description: Manage organization membership and organization roles
    x-displayName: Members
  - name: Organization Service Accounts
    description: >-
      Create and delete organization-managed machine principals and their
      initial management credentials
    x-displayName: Service Accounts
  - name: Organization Invitations
    description: Invite human users to an organization and optionally one workspace
    x-displayName: Invitations
  - name: Organization Workspaces
    description: List and create workspaces within an organization
    x-displayName: Workspaces
  - name: Organization Management Keys
    description: >-
      List management keys within an organization, issue organization-scoped
      credentials, and revoke keys
    x-displayName: Management Keys
  - name: Organization Provider Credentials
    description: Manage provider API keys available across an organization
    x-displayName: Provider Credentials
  - name: Organization Usage Events
    description: Inspect usage events across an organization
    x-displayName: Usage Events
  - name: Organization Reports
    description: Explore usage and requests across an organization or one workspace
    x-displayName: Reports
  - name: Organization Activity
    description: Inspect recent audited changes in an organization
    x-displayName: Activity
  - name: Organization Model Catalog
    description: Inspect the provider and model catalog available to an organization
    x-displayName: Model Catalog
  - name: Workspace Settings
    description: View, update, and delete one workspace
    x-displayName: Settings
  - name: Workspace Policies
    description: Manage workspace inference restrictions and fallbacks
    x-displayName: Policies
  - name: Workspace Members
    description: Manage workspace membership and workspace roles
    x-displayName: Members
  - name: Workspace Management Keys
    description: List and issue management keys scoped to a workspace and revoke keys
    x-displayName: Management Keys
  - name: Workspace Playground
    description: Create and end short-lived browser sessions for playground model requests
    x-displayName: Playground
  - name: Workspace Inference Keys
    description: Issue and revoke credentials for model requests to a workspace
    x-displayName: Inference Keys
  - name: Workspace Provider Credentials
    description: Manage provider API keys available to one workspace
    x-displayName: Provider Credentials
  - name: Workspace Usage Events
    description: Inspect usage events for one workspace
    x-displayName: Usage Events
  - name: Workspace Model Catalog
    description: Inspect the provider and model catalog available to a workspace
    x-displayName: Model Catalog
  - name: Data Plane API
    description: Poll bundles, ingest usage events, and record data-plane heartbeats
    x-displayName: Synchronization
paths:
  /api/v1/policy-state/sync:
    post:
      tags:
        - Data Plane API
      summary: Sync Policy State
      description: 'Required permission: `policy-state.sync`.'
      operationId: sync_policy_state
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PolicyStateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Envelope_PolicyState_'
        '401':
          description: Authentication failed
        '403':
          description: The credential does not have the required permission
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - ManagementKey: []
        - SessionCookie: []
components:
  schemas:
    PolicyStateRequest:
      properties:
        org_ids:
          items:
            type: string
            format: uuid
          type: array
          maxItems: 1000
          minItems: 1
          title: Org Ids
          description: Organizations whose current budget state is requested
      additionalProperties: false
      type: object
      required:
        - org_ids
      title: PolicyStateRequest
    Envelope_PolicyState_:
      properties:
        data:
          $ref: '#/components/schemas/PolicyState'
      type: object
      required:
        - data
      title: Envelope[PolicyState]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PolicyState:
      properties:
        computed_at:
          type: string
          format: date-time
          title: Computed At
        organizations:
          items:
            $ref: '#/components/schemas/OrgPolicyState'
          type: array
          title: Organizations
      additionalProperties: false
      type: object
      required:
        - computed_at
        - organizations
      title: PolicyState
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    OrgPolicyState:
      properties:
        org_id:
          type: string
          format: uuid
          title: Org Id
        budgets:
          items:
            $ref: '#/components/schemas/BudgetState'
          type: array
          title: Budgets
      additionalProperties: false
      type: object
      required:
        - org_id
        - budgets
      title: OrgPolicyState
    BudgetState:
      properties:
        policy_id:
          type: string
          format: uuid
          title: Policy Id
        rule_index:
          type: integer
          exclusiveMaximum: 100
          minimum: 0
          title: Rule Index
        workspace_id:
          type: string
          format: uuid
          title: Workspace Id
        target:
          oneOf:
            - $ref: '#/components/schemas/WorkspaceTarget'
            - $ref: '#/components/schemas/SelectedUsers'
            - $ref: '#/components/schemas/SelectedKeys'
          title: Target
          discriminator:
            propertyName: kind
            mapping:
              selected_keys:
                $ref: '#/components/schemas/SelectedKeys'
              selected_users:
                $ref: '#/components/schemas/SelectedUsers'
              workspace:
                $ref: '#/components/schemas/WorkspaceTarget'
        match:
          oneOf:
            - $ref: '#/components/schemas/AllRequests'
            - $ref: '#/components/schemas/RequestMatch-Output'
          title: Match
          discriminator:
            propertyName: kind
            mapping:
              all_requests:
                $ref: '#/components/schemas/AllRequests'
              request:
                $ref: '#/components/schemas/RequestMatch-Output'
        aggregation:
          type: string
          enum:
            - shared
            - per_key
          title: Aggregation
        amount_usd:
          type: string
          pattern: ^\d+(?:\.\d+)?$
          title: Amount Usd
        period:
          type: string
          enum:
            - day
            - month
          title: Period
        window_start:
          type: string
          format: date-time
          title: Window Start
        window_end:
          type: string
          format: date-time
          title: Window End
        exhausted_buckets:
          items:
            oneOf:
              - $ref: '#/components/schemas/SharedBudgetBucket'
              - $ref: '#/components/schemas/KeyBudgetBucket'
            discriminator:
              propertyName: kind
              mapping:
                key:
                  $ref: '#/components/schemas/KeyBudgetBucket'
                shared:
                  $ref: '#/components/schemas/SharedBudgetBucket'
          type: array
          title: Exhausted Buckets
      additionalProperties: false
      type: object
      required:
        - policy_id
        - rule_index
        - workspace_id
        - target
        - match
        - aggregation
        - amount_usd
        - period
        - window_start
        - window_end
        - exhausted_buckets
      title: BudgetState
    WorkspaceTarget:
      properties:
        kind:
          type: string
          const: workspace
          title: Kind
      additionalProperties: false
      type: object
      required:
        - kind
      title: WorkspaceTarget
    SelectedUsers:
      properties:
        kind:
          type: string
          const: selected_users
          title: Kind
        user_ids:
          items:
            type: string
            format: uuid
          type: array
          maxItems: 1000
          minItems: 1
          title: User Ids
      additionalProperties: false
      type: object
      required:
        - kind
        - user_ids
      title: SelectedUsers
    SelectedKeys:
      properties:
        kind:
          type: string
          const: selected_keys
          title: Kind
        key_ids:
          items:
            type: string
            maxLength: 255
            minLength: 1
          type: array
          maxItems: 1000
          minItems: 1
          title: Key Ids
      additionalProperties: false
      type: object
      required:
        - kind
        - key_ids
      title: SelectedKeys
    AllRequests:
      properties:
        kind:
          type: string
          const: all_requests
          title: Kind
      additionalProperties: false
      type: object
      required:
        - kind
      title: AllRequests
    RequestMatch-Output:
      properties:
        kind:
          type: string
          const: request
          title: Kind
        models:
          items:
            type: string
            maxLength: 255
            minLength: 1
          type: array
          maxItems: 1000
          title: Models
          default: []
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream
        capabilities:
          items:
            type: string
            enum:
              - tools
              - reasoning
              - structured_output
          type: array
          maxItems: 3
          title: Capabilities
          default: []
      additionalProperties: false
      type: object
      required:
        - kind
        - models
        - stream
        - capabilities
      title: RequestMatch
    SharedBudgetBucket:
      properties:
        kind:
          type: string
          const: shared
          title: Kind
          default: shared
      additionalProperties: false
      type: object
      required:
        - kind
      title: SharedBudgetBucket
    KeyBudgetBucket:
      properties:
        kind:
          type: string
          const: key
          title: Kind
          default: key
        key_id:
          type: string
          maxLength: 255
          minLength: 1
          title: Key Id
      additionalProperties: false
      type: object
      required:
        - kind
        - key_id
      title: KeyBudgetBucket
  securitySchemes:
    ManagementKey:
      type: http
      description: >-
        A control-plane management key using the `sk-cp-` prefix. Inference keys
        are not accepted by control-plane endpoints.
      scheme: bearer
    SessionCookie:
      type: apiKey
      in: cookie
      name: airmux_session
      description: >-
        Browser session cookie returned by login or signup. Browser requests
        must also send `X-Requested-With`.

````