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

# Update a trust rule

> Updates a trust rule's condition, audience, service account, or token lifetime.

> [!NOTE]
>
> [Workload identity federation](https://docs.baseten.co/organization/workload-identity.md) is in **Private Preview**.


## OpenAPI

````yaml patch /v1/access/trust_rules/{trust_rule_id}
openapi: 3.1.0
info:
  description: REST API for management of Baseten resources
  title: Baseten management API
  version: 1.0.0
servers:
  - url: https://api.baseten.co
security:
  - BearerAuth: []
paths:
  /v1/access/trust_rules/{trust_rule_id}:
    parameters:
      - $ref: '#/components/parameters/trust_rule_id'
    patch:
      summary: Updates a trust rule
      description: >-
        Updates the fields you send. Changes apply to new exchanges only. The
        identity provider can't change.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAccessTrustRuleRequestV1'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccessTrustRuleV1'
      x-codeSamples:
        - lang: bash
          source: |-
            curl --request PATCH \
            --url https://api.baseten.co/v1/access/trust_rules/{trust_rule_id} \
            --header "Authorization: Bearer $BASETEN_API_KEY" \
            --data '{
              "name": "models-release-deploy"
            }'
        - lang: python
          source: |-
            import requests
            import os
            API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
            url = "https://api.baseten.co/v1/access/trust_rules/{trust_rule_id}"

            headers = {"Authorization": f"Bearer {API_KEY}"}

            response = requests.request(
                "PATCH",
                url,
                headers=headers,
                json={'name': 'models-release-deploy'}
            )

            print(response.text)
components:
  parameters:
    trust_rule_id:
      schema:
        type: string
      name: trust_rule_id
      in: path
      required: true
  schemas:
    UpdateAccessTrustRuleRequestV1:
      additionalProperties: false
      description: Request to update a trust rule. Only the fields sent change.
      properties:
        name:
          anyOf:
            - maxLength: 255
              minLength: 1
              type: string
            - type: 'null'
          default: null
          description: Name, unique in the organization
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Description; null clears it
          title: Description
          x-null-distinct: true
        condition:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            A CEL expression over the token's `claims` that must evaluate to
            true. It must pin a specific `claims.sub` in a top-level `&&`
            clause, plus any provider-required checks. Up to 4,096 characters.
          title: Condition
        audience:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            The token's `aud` must equal this, or contain it when `aud` is a
            list. Up to 1,024 characters.
          title: Audience
        max_access_token_lifetime_seconds:
          anyOf:
            - maximum: 3600
              minimum: 60
              type: integer
            - type: 'null'
          default: null
          description: >-
            Longest lifetime of a token the rule issues, 60 to 3600 seconds.
            Tokens already issued keep their lifetime.
          title: Max Access Token Lifetime Seconds
        service_account_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Moves the rule to another service account. Tokens already issued
            keep the old account until they expire.
          title: Service Account Id
      title: UpdateAccessTrustRuleRequestV1
      type: object
    AccessTrustRuleV1:
      description: Which tokens from an identity provider may act as a service account.
      properties:
        id:
          description: Trust rule ID. Workloads pass it when they exchange a token.
          title: Id
          type: string
        name:
          description: Name, unique in the organization
          title: Name
          type: string
        description:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: Description
          title: Description
        identity_provider_id:
          description: The identity provider whose tokens it accepts
          title: Identity Provider Id
          type: string
        identity_provider_name:
          description: Name of the identity provider
          title: Identity Provider Name
          type: string
        service_account_id:
          description: The service account its tokens act as
          title: Service Account Id
          type: string
        service_account_name:
          description: Name of the service account
          title: Service Account Name
          type: string
        team_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            The service account's team. Null for an organization service
            account.
          title: Team Id
        team_name:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            Name of the service account's team. Null for an organization service
            account.
          title: Team Name
        condition:
          description: >-
            A CEL expression over the token's `claims` that must evaluate to
            true. It must pin a specific `claims.sub` in a top-level `&&`
            clause, plus any provider-required checks. Up to 4,096 characters.
          examples:
            - >-
              claims.repository_owner_id == '12345' &&
              claims.sub.startsWith('repo:acme/models:') && claims.ref ==
              'refs/heads/main'
          title: Condition
          type: string
        audience:
          description: >-
            The token's `aud` must equal this, or contain it when `aud` is a
            list. Up to 1,024 characters.
          title: Audience
          type: string
        max_access_token_lifetime_seconds:
          description: Longest lifetime of a token the rule issues, in seconds
          title: Max Access Token Lifetime Seconds
          type: integer
        last_used_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          default: null
          description: >-
            Last time a request authenticated with a token the rule issued, to
            within an hour. Null until the first.
          title: Last Used At
        created_by:
          description: ID of the user who created the rule
          title: Created By
          type: string
        created_at:
          description: Time the rule was created
          format: date-time
          title: Created At
          type: string
        updated_at:
          description: Time the rule was last updated
          format: date-time
          title: Updated At
          type: string
      required:
        - id
        - name
        - identity_provider_id
        - identity_provider_name
        - service_account_id
        - service_account_name
        - condition
        - audience
        - max_access_token_lifetime_seconds
        - created_by
        - created_at
        - updated_at
      title: AccessTrustRuleV1
      type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Send `Authorization: Bearer <api_key>`. The legacy `Authorization:
        Api-Key <api_key>` scheme is also accepted.

````