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

# Ruota l'API key dell'utente di servizio

> Ruota una API key per un utente di servizio.

Crea una nuova chiave. Per impostazione predefinita revoca la chiave precedente; imposta revoke_current=false
per una rotazione graduale in cui entrambe le chiavi rimangono temporaneamente attive.
Restituisce 404 se la chiave non viene trovata e 400 se la chiave non è attiva.

<div id="permissions">
  ## Autorizzazioni
</div>

Richiede un utente di servizio con l'autorizzazione `ManageAccountServiceUsers` a livello dell'Enterprise.


## OpenAPI

````yaml it/v3-openapi.yaml POST /v3beta1/enterprise/service-users/{service_user_id}/api-keys/{api_key_id}/rotate
openapi: 3.1.0
info:
  description: API Devin v3 con autenticazione utente di servizio e RBAC
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3beta1/enterprise/service-users/{service_user_id}/api-keys/{api_key_id}/rotate:
    post:
      tags:
        - service_user_api_keys
      summary: Ruota l'API key dell'utente di servizio
      description: >-
        Ruota una API key per un utente di servizio.


        Crea una nuova chiave. Per impostazione predefinita revoca la chiave
        precedente; imposta revoke_current=false

        per una rotazione graduale in cui entrambe le chiavi rimangono
        temporaneamente attive.

        Restituisce 404 se la chiave non viene trovata e 400 se la chiave non è
        attiva.
      operationId: >-
        handle_rotate_service_user_api_key_v3beta1_enterprise_service_users__service_user_id__api_keys__api_key_id__rotate_post
      parameters:
        - description: 'ID utente di servizio (prefisso: service-user-)'
          in: path
          name: service_user_id
          required: true
          schema:
            example: service-user-abc123def456
            title: Service User Id
            type: string
        - in: path
          name: api_key_id
          required: true
          schema:
            title: Api Key Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RotateApiKeyRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyWithTokenResponse'
          description: Risposta corretta
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Errore di validazione
components:
  schemas:
    RotateApiKeyRequest:
      properties:
        new_key_expires_at:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Scadenza facoltativa per la nuova key come timestamp UNIX in
            secondi. Null se non è prevista alcuna scadenza.
          title: New Key Expires At
        revoke_current:
          default: true
          description: >-
            Indica se revocare la key attuale. Impostare False per una rotazione
            graduale.
          title: Revoke Current
          type: boolean
      title: RotateApiKeyRequest
      type: object
    ApiKeyWithTokenResponse:
      description: >-
        Modello di risposta condiviso per la creazione/rotazione dell'API key
        (include un token una tantum).
      properties:
        api_key_id:
          title: Api Key Id
          type: string
        api_key_name:
          title: Api Key Name
          type: string
        token:
          description: >-
            Il token API in chiaro. Viene mostrato una sola volta, al momento
            della creazione/rotazione.
          title: Token
          type: string
      required:
        - api_key_id
        - api_key_name
        - token
      title: ApiKeyWithTokenResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        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
  securitySchemes:
    bearerAuth:
      description: 'Credenziale dell''utente del servizio (prefisso: cog_)'
      scheme: bearer
      type: http

````