---
title: Aggiorna una Chiave API | RunAPI
description: Aggiorna una Chiave API Standard esistente e recupera il riepilogo dell'utilizzo
  corrente.
url: https://runapi.ai/it/docs/api/management/keys/update.md
canonical: https://runapi.ai/it/docs/api/management/keys/update
locale: it
---

> Versione HTML: https://runapi.ai/it/docs/api/management/keys/update
> Indice del sito per gli agenti: https://runapi.ai/llms.txt

# Aggiorna una Chiave API

Aggiorna una Chiave API Standard esistente e recupera il riepilogo dell'utilizzo corrente.

## Endpoint

PATCH /api/v1/keys/:id

URL di base: https://runapi.ai

Versione API: v1

Autenticazione: Authorization: Bearer YOUR_MANAGEMENT_API_KEY


Autorizzazione: Richiede una Chiave API di gestione con ruolo account-admin e consente solo le chiavi di proprietà del suo utente.

## Richiesta

Invia i valori solo nella posizione di richiesta elencata.

### Corpo JSON

```json
{
  "allowed_models": {
    "description": "Allowlist dei modelli sostitutiva; null o un array vuoto la azzera.",
    "required": false,
    "type": "array | null"
  },
  "credit_limit_cents": {
    "description": "Limite di spesa in centesimi USD; null annulla il limite e l'intervallo di reset.",
    "required": false,
    "type": "integer | null"
  },
  "credit_limit_reset_interval": {
    "description": "Cadenza di reset per il limite di spesa.",
    "enum": [
      "daily",
      "weekly",
      "monthly"
    ],
    "required": false,
    "type": "string | null"
  },
  "credit_limit_windows": {
    "description": "Limiti di spesa progressivi sostitutivi con chiave 1h, 1d o 7d; un oggetto vuoto elimina tutti i limiti progressivi.",
    "required": false,
    "type": "object"
  },
  "enabled": {
    "description": "Se le richieste che utilizzano questa chiave vengono accettate.",
    "required": false,
    "type": "boolean"
  },
  "name": {
    "description": "Nome descrittivo sostitutivo per la Chiave API.",
    "required": false,
    "type": "string"
  }
}
```

### Parametri del percorso

```json
{
  "id": {
    "description": "ID prefisso della chiave API, ad esempio token_123.",
    "required": true,
    "type": "string"
  }
}
```

## Risposta di successo

HTTP 200 - PATCH /api/v1/keys/:id

```json
{
  "allowed_models": [
    "gpt-5.4"
  ],
  "created_at": "2026-07-27T10:00:00.000Z",
  "credit_limit_cents": 1000,
  "credit_limit_reset_interval": "daily",
  "credit_limit_windows": {},
  "credit_usage_cents_by_model": {
    "gpt-5.4": 250
  },
  "credit_usage_cents_this_month": 250,
  "credit_usage_cents_this_week": 100,
  "credit_usage_cents_today": 25,
  "credit_usage_cents_total": 250,
  "enabled": true,
  "guardrail_id": "guardrail_123",
  "id": "token_123",
  "last_used_at": null,
  "masked_token": "runapi_abc...wxyz",
  "name": "Production primary"
}
```

## Risposta di errore (401)

HTTP 401

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Authentication required"
}
```

## Risposta di errore (403)

HTTP 403

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Management API key required"
}
```

## Risposta di errore (403)

HTTP 403

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Account admin required"
}
```

## Risposta di errore (400)

HTTP 400

### Schema della risposta

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Messaggio di errore leggibile.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Riepilogo di convalida leggibile dall'utente.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Messaggi di convalida con chiave per campo della richiesta pubblica, con un array di stringhe leggibili dall'utente per ogni campo.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### Esempio di risposta

```json
{
  "error": "page must be an integer"
}
```

## Risposta di errore (404)

HTTP 404

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Resource not found"
}
```

## Risposta di errore (422)

HTTP 422

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Riepilogo di convalida leggibile dall'utente.",
      "type": "string"
    },
    "errors": {
      "additionalProperties": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "description": "Messaggi di convalida con chiave per campo della richiesta pubblica, con un array di stringhe leggibili dall'utente per ogni campo.",
      "type": "object"
    }
  },
  "required": [
    "error",
    "errors"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Validation failed",
  "errors": {
    "base": [
      "Validation failed"
    ]
  }
}
```

## Esempio cURL



### curl

```curl
curl -X PATCH https://runapi.ai/api/v1/keys/token_123 \
  -H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Production primary","enabled":true,"credit_limit_windows":{}}'
```

## Riferimento correlato

- [Chiavi API](https://runapi.ai/it/docs/api/management/keys.md)
- [Oggetto Chiave API](https://runapi.ai/it/docs/api/management/keys/object.md)

---

## Altre risorse di RunAPI

- [Home](https://runapi.ai/it/.md)
- [Catalogo dei modelli](https://runapi.ai/it/models.md)
- [Prezzi](https://runapi.ai/it/pricing.md)
- [Fornitori](https://runapi.ai/it/models)
- [Documentazione](https://runapi.ai/it/docs/guides)
- [SDK](https://runapi.ai/it/sdk.md)
- [CLI](https://runapi.ai/it/cli.md)
- [MCP Server](https://runapi.ai/it/mcp.md)
- [Claude Code vs Cursor](https://runapi.ai/it/claude-code-vs-cursor.md)
- [Configurazione Cursor API](https://runapi.ai/it/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/it/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/it/contact.md)
- [Contatti](https://runapi.ai/it/contact.md)
- [Termini](https://runapi.ai/it/terms.md)
- [Privacy](https://runapi.ai/it/privacy.md)
- [Indice del sito per gli agenti](https://runapi.ai/llms.txt)

Contatti: contact@runapi.ai

## Dati strutturati

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/it",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/it/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/it",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/iticon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "TechArticle",
    "headline": "Aggiorna una Chiave API",
    "description": "Aggiorna una Chiave API Standard esistente e recupera il riepilogo dell'utilizzo corrente.",
    "url": "https://runapi.ai/it/docs/api/management/keys/update",
    "mainEntityOfPage": "https://runapi.ai/it/docs/api/management/keys/update"
  }
]
```
