For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://modelgates.ai/docs/_mcp/server.

Update an API key

PATCH https://modelgates.ai/api/v1/keys/ Content-Type: application/json

Update an existing API key. Management key required.

Reference: https://modelgates.ai/docs/api/api-reference/api-keys/update-keys

OpenAPI Specification

yaml
openapi: 3.1.0info:  title: ModelGates API  version: 1.0.0paths:  /keys/:    patch:      operationId: update-keys      summary: Update an API key      description: >-        Update an existing API key. [Management        key](/docs/guides/overview/auth/management-api-keys) required.      tags:        - subpackage_apiKeys      parameters:        - name: hash          in: path          description: The hash identifier of the API key to update          required: true          schema:            type: string        - name: Authorization          in: header          description: API key as bearer token in Authorization header          required: true          schema:            type: string      responses:        '200':          description: API key updated successfully          content:            application/json:              schema:                $ref: '#/components/schemas/API Keys_updateKeys_Response_200'        '400':          description: Bad Request - Invalid request parameters or malformed input          content:            application/json:              schema:                $ref: '#/components/schemas/BadRequestResponse'        '401':          description: Unauthorized - Authentication required or invalid credentials          content:            application/json:              schema:                $ref: '#/components/schemas/UnauthorizedResponse'        '404':          description: Not Found - Resource does not exist          content:            application/json:              schema:                $ref: '#/components/schemas/NotFoundResponse'        '429':          description: Too Many Requests - Rate limit exceeded          content:            application/json:              schema:                $ref: '#/components/schemas/TooManyRequestsResponse'        '500':          description: Internal Server Error - Unexpected server error          content:            application/json:              schema:                $ref: '#/components/schemas/InternalServerResponse'      requestBody:        content:          application/json:            schema:              type: object              properties:                disabled:                  type: boolean                  description: Whether to disable the API key                include_byok_in_limit:                  type: boolean                  description: Whether to include BYOK usage in the limit                limit:                  type:                    - number                    - 'null'                  format: double                  description: New spending limit for the API key in USD                limit_reset:                  oneOf:                    - $ref: >-                        #/components/schemas/KeysHashPatchRequestBodyContentApplicationJsonSchemaLimitReset                    - type: 'null'                  description: >-                    New limit reset type for the API key (daily, weekly,                    monthly, or null for no reset). Resets happen automatically                    at midnight UTC, and weeks are Monday through Sunday.                name:                  type: string                  description: New name for the API keyservers:  - url: https://modelgates.ai/api/v1components:  schemas:    KeysHashPatchRequestBodyContentApplicationJsonSchemaLimitReset:      type: string      enum:        - daily        - weekly        - monthly      description: >-        New limit reset type for the API key (daily, weekly, monthly, or null        for no reset). Resets happen automatically at midnight UTC, and weeks        are Monday through Sunday.      title: KeysHashPatchRequestBodyContentApplicationJsonSchemaLimitReset    KeysHashPatchResponsesContentApplicationJsonSchemaData:      type: object      properties:        byok_usage:          type: number          format: double          description: Total external BYOK usage (in USD) for the API key        byok_usage_daily:          type: number          format: double          description: External BYOK usage (in USD) for the current UTC day        byok_usage_monthly:          type: number          format: double          description: External BYOK usage (in USD) for current UTC month        byok_usage_weekly:          type: number          format: double          description: >-            External BYOK usage (in USD) for the current UTC week            (Monday-Sunday)        created_at:          type: string          description: ISO 8601 timestamp of when the API key was created        creator_user_id:          type:            - string            - 'null'          description: >-            The user ID of the key creator. For organization-owned keys, this is            the member who created the key. For individual users, this is the            user's own ID.        disabled:          type: boolean          description: Whether the API key is disabled        expires_at:          type:            - string            - 'null'          format: date-time          description: >-            ISO 8601 UTC timestamp when the API key expires, or null if no            expiration        hash:          type: string          description: Unique hash identifier for the API key        include_byok_in_limit:          type: boolean          description: Whether to include external BYOK usage in the credit limit        label:          type: string          description: Human-readable label for the API key        limit:          type:            - number            - 'null'          format: double          description: Spending limit for the API key in USD        limit_remaining:          type:            - number            - 'null'          format: double          description: Remaining spending limit in USD        limit_reset:          type:            - string            - 'null'          description: Type of limit reset for the API key        name:          type: string          description: Name of the API key        updated_at:          type:            - string            - 'null'          description: ISO 8601 timestamp of when the API key was last updated        usage:          type: number          format: double          description: Total ModelGates credit usage (in USD) for the API key        usage_daily:          type: number          format: double          description: ModelGates credit usage (in USD) for the current UTC day        usage_monthly:          type: number          format: double          description: ModelGates credit usage (in USD) for the current UTC month        usage_weekly:          type: number          format: double          description: >-            ModelGates credit usage (in USD) for the current UTC week            (Monday-Sunday)        workspace_id:          type: string          description: The workspace ID this API key belongs to.      required:        - byok_usage        - byok_usage_daily        - byok_usage_monthly        - byok_usage_weekly        - created_at        - creator_user_id        - disabled        - hash        - include_byok_in_limit        - label        - limit        - limit_remaining        - limit_reset        - name        - updated_at        - usage        - usage_daily        - usage_monthly        - usage_weekly        - workspace_id      description: The updated API key information      title: KeysHashPatchResponsesContentApplicationJsonSchemaData    API Keys_updateKeys_Response_200:      type: object      properties:        data:          $ref: >-            #/components/schemas/KeysHashPatchResponsesContentApplicationJsonSchemaData          description: The updated API key information      required:        - data      title: API Keys_updateKeys_Response_200    BadRequestResponseErrorData:      type: object      properties:        code:          type: integer        message:          type: string        metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type      required:        - code        - message      description: Error data for BadRequestResponse      title: BadRequestResponseErrorData    BadRequestResponse:      type: object      properties:        error:          $ref: '#/components/schemas/BadRequestResponseErrorData'        modelgates_metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type        user_id:          type:            - string            - 'null'      required:        - error      description: Bad Request - Invalid request parameters or malformed input      title: BadRequestResponse    UnauthorizedResponseErrorData:      type: object      properties:        code:          type: integer        message:          type: string        metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type      required:        - code        - message      description: Error data for UnauthorizedResponse      title: UnauthorizedResponseErrorData    UnauthorizedResponse:      type: object      properties:        error:          $ref: '#/components/schemas/UnauthorizedResponseErrorData'        modelgates_metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type        user_id:          type:            - string            - 'null'      required:        - error      description: Unauthorized - Authentication required or invalid credentials      title: UnauthorizedResponse    NotFoundResponseErrorData:      type: object      properties:        code:          type: integer        message:          type: string        metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type      required:        - code        - message      description: Error data for NotFoundResponse      title: NotFoundResponseErrorData    NotFoundResponse:      type: object      properties:        error:          $ref: '#/components/schemas/NotFoundResponseErrorData'        modelgates_metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type        user_id:          type:            - string            - 'null'      required:        - error      description: Not Found - Resource does not exist      title: NotFoundResponse    TooManyRequestsResponseErrorData:      type: object      properties:        code:          type: integer        message:          type: string        metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type      required:        - code        - message      description: Error data for TooManyRequestsResponse      title: TooManyRequestsResponseErrorData    TooManyRequestsResponse:      type: object      properties:        error:          $ref: '#/components/schemas/TooManyRequestsResponseErrorData'        modelgates_metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type        user_id:          type:            - string            - 'null'      required:        - error      description: Too Many Requests - Rate limit exceeded      title: TooManyRequestsResponse    InternalServerResponseErrorData:      type: object      properties:        code:          type: integer        message:          type: string        metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type      required:        - code        - message      description: Error data for InternalServerResponse      title: InternalServerResponseErrorData    InternalServerResponse:      type: object      properties:        error:          $ref: '#/components/schemas/InternalServerResponseErrorData'        modelgates_metadata:          type:            - object            - 'null'          additionalProperties:            description: Any type        user_id:          type:            - string            - 'null'      required:        - error      description: Internal Server Error - Unexpected server error      title: InternalServerResponse  securitySchemes:    apiKey:      type: http      scheme: bearer      description: API key as bearer token in Authorization header

SDK Code Examples

python
import requests url = "https://modelgates.ai/api/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943" payload = {    "disabled": False,    "include_byok_in_limit": True,    "limit": 75,    "limit_reset": "daily",    "name": "Updated API Key Name"}headers = {    "Authorization": "Bearer <token>",    "Content-Type": "application/json"} response = requests.patch(url, json=payload, headers=headers) print(response.json())