---
title: تحديث مفتاح API | RunAPI
description: تحديث مفتاح API قياسي موجود واسترداد ملخص استخدامه الحالي.
url: https://runapi.ai/ar/docs/api/management/keys/update.md
canonical: https://runapi.ai/ar/docs/api/management/keys/update
locale: ar
---

> نسخة HTML: https://runapi.ai/ar/docs/api/management/keys/update
> فهرس الموقع للوكلاء: https://runapi.ai/llms.txt

# تحديث مفتاح API

تحديث مفتاح API قياسي موجود واسترداد ملخص استخدامه الحالي.

## نقطة النهاية

PATCH /api/v1/keys/:id

عنوان URL الأساسي: https://runapi.ai

إصدار API: v1

المصادقة: Authorization: Bearer YOUR_MANAGEMENT_API_KEY


التفويض: يتطلب مفتاح 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، مثال: 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/ar/docs/api/management/keys.md)
- [كائن مفتاح API](https://runapi.ai/ar/docs/api/management/keys/object.md)

---

## المزيد من RunAPI

- [الرئيسية](https://runapi.ai/ar/.md)
- [كتالوج النماذج](https://runapi.ai/ar/models.md)
- [الأسعار](https://runapi.ai/ar/pricing.md)
- [مزودو الخدمة](https://runapi.ai/ar/models)
- [التوثيق](https://runapi.ai/ar/docs/guides)
- [حزم SDK](https://runapi.ai/ar/sdk.md)
- [CLI](https://runapi.ai/ar/cli.md)
- [خادم MCP](https://runapi.ai/ar/mcp.md)
- [Claude Code مقابل Cursor](https://runapi.ai/ar/claude-code-vs-cursor.md)
- [إعداد Cursor API](https://runapi.ai/ar/cursor-api-setup.md)
- [RunAPI مقابل OpenRouter](https://runapi.ai/ar/openrouter-alternative.md)
- [المؤسسات](https://runapi.ai/ar/contact.md)
- [اتصل بنا](https://runapi.ai/ar/contact.md)
- [الشروط](https://runapi.ai/ar/terms.md)
- [الخصوصية](https://runapi.ai/ar/privacy.md)
- [فهرس الموقع للوكلاء](https://runapi.ai/llms.txt)

التواصل: contact@runapi.ai

## البيانات المنظمة

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "ar",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/ar",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/ar/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "ar",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/ar",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/aricon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "ar",
    "@type": "TechArticle",
    "headline": "تحديث مفتاح API",
    "description": "تحديث مفتاح API قياسي موجود واسترداد ملخص استخدامه الحالي.",
    "url": "https://runapi.ai/ar/docs/api/management/keys/update",
    "mainEntityOfPage": "https://runapi.ai/ar/docs/api/management/keys/update"
  }
]
```
