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

# Update Policy

> Replace a policy's name and configuration. Both `name` and `config` are required; the configuration you send replaces the existing one in full. Changes apply to new inference requests immediately. Requires an API key with write manage permissions.

Replace a policy's name and configuration. Both `name` and `config` are required; the configuration you send replaces the existing one in full. Changes apply to new inference requests immediately.


## OpenAPI

````yaml PATCH /v1/manage/policy/{policy_id}
openapi: 3.0.3
info:
  title: Requesty Management API
  description: >-
    Requesty Management API for API key management, groups, members, and
    organization settings.
  version: 1.0.0
servers:
  - url: https://api-v2.requesty.ai
    description: Management API endpoint
security:
  - BearerAuth: []
paths:
  /v1/manage/policy/{policy_id}:
    servers:
      - url: https://api-v2.requesty.ai
        description: Management API endpoint
    patch:
      summary: Update policy
      description: >-
        Replace a policy's name and configuration. Both `name` and `config` are
        required; the configuration you send replaces the existing one in full.
        Changes apply to new inference requests immediately. Requires an API key
        with write manage permissions.
      operationId: updatePolicy
      parameters:
        - name: policy_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: The policy ID
          example: 123e4567-e89b-12d3-a456-426614174000
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePolicyRequest'
      responses:
        '200':
          description: Policy updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolicyResponse'
        '400':
          description: >-
            Bad request - invalid policy ID, missing name or config, unsupported
            scope, or invalid policy configuration.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or invalid Authorization header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - API key does not have write manage permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - policy does not exist in the organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    UpdatePolicyRequest:
      type: object
      required:
        - name
        - config
        - scope
      properties:
        name:
          type: string
          description: New policy name
          example: production-chat
        config:
          $ref: '#/components/schemas/PolicyConfig'
        scope:
          type: string
          enum:
            - POLICY_SCOPE_ORGANIZATION
          description: >-
            Policy scope. The Management API only accepts
            `POLICY_SCOPE_ORGANIZATION`.
          example: POLICY_SCOPE_ORGANIZATION
    PolicyResponse:
      type: object
      properties:
        policy:
          $ref: '#/components/schemas/PolicyObject'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - origin
            - message
          properties:
            origin:
              type: string
              enum:
                - router
                - provider
              description: >-
                Whether the error originated from Requesty's router or an
                upstream provider.
            message:
              type: string
              description: Human-readable error description.
    PolicyConfig:
      type: object
      description: >-
        Policy strategy and model chain. Set exactly one of `fallback`,
        `load_balance`, or `latency`, with at least one model.
      properties:
        fallback:
          type: object
          description: Try models in order, moving to the next when a request fails
          properties:
            models:
              type: array
              items:
                $ref: '#/components/schemas/PolicyFallbackModel'
        load_balance:
          type: object
          description: Distribute requests across models by weight
          properties:
            models:
              type: array
              items:
                $ref: '#/components/schemas/PolicyLoadBalanceModel'
        latency:
          type: object
          description: Route each request to the model with the lowest observed latency
          properties:
            models:
              type: array
              items:
                $ref: '#/components/schemas/PolicyLatencyModel'
    PolicyObject:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The policy ID
        name:
          type: string
          description: The policy name
        config:
          $ref: '#/components/schemas/PolicyConfig'
        organization_id:
          type: string
          description: The organization ID that owns this policy
        author_id:
          type: string
          description: The user ID that created the policy
        scope:
          type: string
          enum:
            - POLICY_SCOPE_ORGANIZATION
          description: >-
            Policy scope. The Management API only accepts
            `POLICY_SCOPE_ORGANIZATION`.
          example: POLICY_SCOPE_ORGANIZATION
    PolicyFallbackModel:
      type: object
      required:
        - model
        - key
        - retries
      properties:
        model:
          type: string
          description: Model identifier in `provider/model` form
          example: openai/gpt-4o
        key:
          type: string
          enum:
            - POLICY_KEY_BYOK_ONLY
            - POLICY_KEY_NON_BYOK_ONLY
            - POLICY_KEY_REQUESTY_FIRST
            - POLICY_KEY_BYOK_FIRST
          description: >-
            Which credentials to use for this model: `POLICY_KEY_BYOK_ONLY` uses
            only your own provider key, `POLICY_KEY_NON_BYOK_ONLY` uses only
            Requesty's key, `POLICY_KEY_REQUESTY_FIRST` and
            `POLICY_KEY_BYOK_FIRST` try one and fall back to the other.
          example: POLICY_KEY_REQUESTY_FIRST
        retries:
          type: integer
          description: >-
            Number of attempts for this model before moving to the next one in
            the chain. Must be at least 1.
          example: 2
          minimum: 1
    PolicyLoadBalanceModel:
      type: object
      required:
        - model
        - key
        - weight
      properties:
        model:
          type: string
          description: Model identifier in `provider/model` form
          example: openai/gpt-4o
        key:
          type: string
          enum:
            - POLICY_KEY_BYOK_ONLY
            - POLICY_KEY_NON_BYOK_ONLY
            - POLICY_KEY_REQUESTY_FIRST
            - POLICY_KEY_BYOK_FIRST
          description: >-
            Which credentials to use for this model: `POLICY_KEY_BYOK_ONLY` uses
            only your own provider key, `POLICY_KEY_NON_BYOK_ONLY` uses only
            Requesty's key, `POLICY_KEY_REQUESTY_FIRST` and
            `POLICY_KEY_BYOK_FIRST` try one and fall back to the other.
          example: POLICY_KEY_REQUESTY_FIRST
        weight:
          type: integer
          description: >-
            Relative share of traffic sent to this model. Must be greater than
            0.
          example: 1
          minimum: 1
    PolicyLatencyModel:
      type: object
      required:
        - model
        - key
      properties:
        model:
          type: string
          description: Model identifier in `provider/model` form
          example: openai/gpt-4o
        key:
          type: string
          enum:
            - POLICY_KEY_BYOK_ONLY
            - POLICY_KEY_NON_BYOK_ONLY
            - POLICY_KEY_REQUESTY_FIRST
            - POLICY_KEY_BYOK_FIRST
          description: >-
            Which credentials to use for this model: `POLICY_KEY_BYOK_ONLY` uses
            only your own provider key, `POLICY_KEY_NON_BYOK_ONLY` uses only
            Requesty's key, `POLICY_KEY_REQUESTY_FIRST` and
            `POLICY_KEY_BYOK_FIRST` try one and fall back to the other.
          example: POLICY_KEY_REQUESTY_FIRST
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````