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

# Update Api Key

> Update an API key's permission flags (currently only can_moderate).

Managing keys requires a real user (JWT) session. ``require_team_owner``
ADMITS a valid same-team API key (a key implies owner-level access), so
``reject_api_key_principal`` below is the SOLE defense that stops a key
from flipping its own can_moderate — do not remove it.



## OpenAPI

````yaml /openapi/mio-openapi.json patch /api/v1/teams/{team_id}/api-keys/{key_id}
openapi: 3.1.0
info:
  description: >-
    Production API reference for Membership.io. Use the authored guides for
    workflows and the generated endpoint pages for exact parameters and schemas.
  title: Membership.io API
  version: 0.1.0
servers:
  - description: Production
    url: https://api.member.dev
security:
  - bearerAuth: []
paths:
  /api/v1/teams/{team_id}/api-keys/{key_id}:
    patch:
      tags:
        - api-keys
      summary: Update Api Key
      description: |-
        Update an API key's permission flags (currently only can_moderate).

        Managing keys requires a real user (JWT) session. ``require_team_owner``
        ADMITS a valid same-team API key (a key implies owner-level access), so
        ``reject_api_key_principal`` below is the SOLE defense that stops a key
        from flipping its own can_moderate — do not remove it.
      operationId: api_keys.patch_api_keys_patch_teams_by_team_id_api_keys_by_key_id
      parameters:
        - in: path
          name: team_id
          required: true
          schema:
            title: Team Id
            type: string
        - in: path
          name: key_id
          required: true
          schema:
            title: Key Id
            type: string
      requestBody:
        content:
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/ApiKeyUpdateRequest'
        required: true
      responses:
        '200':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/JsonApiResponse_ApiKeyAttributes_'
          description: Successful Response
        '422':
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - HTTPBearer: []
components:
  schemas:
    ApiKeyUpdateRequest:
      properties:
        can_moderate:
          title: Can Moderate
          type: boolean
      required:
        - can_moderate
      title: ApiKeyUpdateRequest
      type: object
    JsonApiResponse_ApiKeyAttributes_:
      properties:
        data:
          $ref: '#/components/schemas/JsonApiResource_ApiKeyAttributes_'
        included:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Included
        links:
          anyOf:
            - $ref: '#/components/schemas/JsonApiLinks'
            - type: 'null'
        meta:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Meta
      required:
        - data
      title: JsonApiResponse[ApiKeyAttributes]
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    JsonApiResource_ApiKeyAttributes_:
      properties:
        attributes:
          $ref: '#/components/schemas/ApiKeyAttributes'
        id:
          title: Id
          type: string
        links:
          anyOf:
            - $ref: '#/components/schemas/JsonApiLinks'
            - type: 'null'
        meta:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Meta
        relationships:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Relationships
        type:
          title: Type
          type: string
      required:
        - id
        - type
        - attributes
      title: JsonApiResource[ApiKeyAttributes]
      type: object
    JsonApiLinks:
      properties:
        self:
          anyOf:
            - type: string
            - type: 'null'
          title: Self
      title: JsonApiLinks
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
    ApiKeyAttributes:
      description: |-
        Public attributes for an API key resource.

        Returned on list and retrieve. Never includes secret or key_hash.
      properties:
        can_moderate:
          default: false
          title: Can Moderate
          type: boolean
        created_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Created At
        created_by:
          title: Created By
          type: string
        expires_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Expires At
        key_prefix:
          title: Key Prefix
          type: string
        last_used_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Last Used At
        name:
          title: Name
          type: string
        revoked_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Revoked At
        scopes:
          items:
            type: string
          title: Scopes
          type: array
        updated_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Updated At
      required:
        - name
        - key_prefix
        - scopes
        - created_by
      title: ApiKeyAttributes
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: JWT or mio_sk API key
      description: >-
        Send platform JWTs, contact JWTs, or team API keys as `Authorization:
        Bearer <token>`.
      scheme: bearer
      type: http
    HTTPBearer:
      scheme: bearer
      type: http

````