---
title: APIキーを更新 | RunAPI
description: 既存のStandard APIキーを更新し、現在の使用状況サマリーを取得します。
url: https://runapi.ai/ja/docs/api/management/keys/update.md
canonical: https://runapi.ai/ja/docs/api/management/keys/update
locale: ja
---

> HTML 版: https://runapi.ai/ja/docs/api/management/keys/update
> エージェント向けサイトインデックス: https://runapi.ai/llms.txt

# APIキーを更新

既存のStandard APIキーを更新し、現在の使用状況サマリーを取得します。

## エンドポイント

PATCH /api/v1/keys/:id

ベースURL: https://runapi.ai

API バージョン: v1

認証: Authorization: Bearer YOUR_MANAGEMENT_API_KEY


Authorization: アカウント管理者の Management API キーが必要で、そのユーザーが所有するキーのみ操作できます。

## リクエスト

指定されたリクエストの場所にのみ値を送信してください。

### JSON ボディ

```json
{
  "allowed_models": {
    "description": "置き換え用のモデル許可リスト。null または空配列を指定するとクリアされます。",
    "required": false,
    "type": "array | null"
  },
  "credit_limit_cents": {
    "description": "支出上限（USD単位のセント）。nullに設定すると上限とリセット間隔がクリアされます。",
    "required": false,
    "type": "integer | null"
  },
  "credit_limit_reset_interval": {
    "description": "支出上限のリセット周期。",
    "enum": [
      "daily",
      "weekly",
      "monthly"
    ],
    "required": false,
    "type": "string | null"
  },
  "credit_limit_windows": {
    "description": "1h、1d、または 7d をキーとするローリング支出上限の置き換え。空のオブジェクトはすべてのローリング上限をクリアします。",
    "required": false,
    "type": "object"
  },
  "enabled": {
    "description": "このキーを使用したリクエストが受け付けられるかどうか。",
    "required": false,
    "type": "boolean"
  },
  "name": {
    "description": "API キーの置き換え用フレンドリーネーム。",
    "required": false,
    "type": "string"
  }
}
```

### パスパラメータ

```json
{
  "id": {
    "description": "API キーのプレフィックス ID（例：token_123）。",
    "required": true,
    "type": "string"
  }
}
```

## 成功レスポンス

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"
}
```

## エラーレスポンス (401)

HTTP 401

### レスポンススキーマ

```json
{
  "properties": {
    "error": {
      "description": "人が読めるエラーメッセージ。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### レスポンス例

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

## エラーレスポンス (403)

HTTP 403

### レスポンススキーマ

```json
{
  "properties": {
    "error": {
      "description": "人が読めるエラーメッセージ。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### レスポンス例

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

## エラーレスポンス (403)

HTTP 403

### レスポンススキーマ

```json
{
  "properties": {
    "error": {
      "description": "人が読めるエラーメッセージ。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### レスポンス例

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

## エラーレスポンス (400)

HTTP 400

### レスポンススキーマ

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "人が読めるエラーメッセージ。",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "人間が読める形式のバリデーションサマリー。",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "公開リクエストフィールドをキーとするバリデーションメッセージ。各フィールドに対して人間が読める文字列の配列が含まれます。",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### レスポンス例

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

## エラーレスポンス (404)

HTTP 404

### レスポンススキーマ

```json
{
  "properties": {
    "error": {
      "description": "人が読めるエラーメッセージ。",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### レスポンス例

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

## エラーレスポンス (422)

HTTP 422

### レスポンススキーマ

```json
{
  "properties": {
    "error": {
      "description": "人間が読める形式のバリデーションサマリー。",
      "type": "string"
    },
    "errors": {
      "additionalProperties": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "description": "公開リクエストフィールドをキーとするバリデーションメッセージ。各フィールドに対して人間が読める文字列の配列が含まれます。",
      "type": "object"
    }
  },
  "required": [
    "error",
    "errors"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### レスポンス例

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

## 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":{}}'
```

## 関連リファレンス

- [API キー](https://runapi.ai/ja/docs/api/management/keys.md)
- [API キーオブジェクト](https://runapi.ai/ja/docs/api/management/keys/object.md)

---

## RunAPI のその他の情報

- [ホーム](https://runapi.ai/ja/.md)
- [モデルカタログ](https://runapi.ai/ja/models.md)
- [料金](https://runapi.ai/ja/pricing.md)
- [プロバイダー](https://runapi.ai/ja/models)
- [ドキュメント](https://runapi.ai/ja/docs/guides)
- [SDK](https://runapi.ai/ja/sdk.md)
- [CLI](https://runapi.ai/ja/cli.md)
- [MCP Server](https://runapi.ai/ja/mcp.md)
- [Claude Code と Cursor](https://runapi.ai/ja/claude-code-vs-cursor.md)
- [Cursor API セットアップ](https://runapi.ai/ja/cursor-api-setup.md)
- [RunAPI と OpenRouter の比較](https://runapi.ai/ja/openrouter-alternative.md)
- [エンタープライズ](https://runapi.ai/ja/contact.md)
- [お問い合わせ](https://runapi.ai/ja/contact.md)
- [利用規約](https://runapi.ai/ja/terms.md)
- [プライバシー](https://runapi.ai/ja/privacy.md)
- [エージェント向けサイトインデックス](https://runapi.ai/llms.txt)

お問い合わせ: contact@runapi.ai

## 構造化データ

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "ja",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/ja",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/ja/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "ja",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/ja",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/jaicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "ja",
    "@type": "TechArticle",
    "headline": "APIキーを更新",
    "description": "既存のStandard APIキーを更新し、現在の使用状況サマリーを取得します。",
    "url": "https://runapi.ai/ja/docs/api/management/keys/update",
    "mainEntityOfPage": "https://runapi.ai/ja/docs/api/management/keys/update"
  }
]
```
