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

# Create a new credential

> Store a new credential.

Args:
    body (`CreateCredentialRequest`): Credential payload to store.
    user_id (`str`): Injected authenticated user ID.
    storage (`StorageBase`): Injected storage backend.

Returns:
    `CreateCredentialResponse`: The server-assigned credential identifier.



## OpenAPI

````yaml /versions/2.0.2/en/deploy/openapi.json post /credential/
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.1
servers: []
security: []
paths:
  /credential/:
    post:
      tags:
        - credential
      summary: Create a new credential
      description: |-
        Store a new credential.

        Args:
            body (`CreateCredentialRequest`): Credential payload to store.
            user_id (`str`): Injected authenticated user ID.
            storage (`StorageBase`): Injected storage backend.

        Returns:
            `CreateCredentialResponse`: The server-assigned credential identifier.
      operationId: create_credential_credential__post
      parameters:
        - name: x-user-id
          in: header
          required: true
          schema:
            type: string
            description: >-
              Caller's user ID. Temporary header-based identity; will be
              replaced by JWT auth.
            title: X-User-Id
          description: >-
            Caller's user ID. Temporary header-based identity; will be replaced
            by JWT auth.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCredentialRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCredentialResponse'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateCredentialRequest:
      properties:
        data:
          additionalProperties: true
          type: object
          title: Data
          description: Credential payload (e.g. API keys).
      type: object
      required:
        - data
      title: CreateCredentialRequest
      description: Request body for creating a new credential.
    CreateCredentialResponse:
      properties:
        credential_id:
          type: string
          title: Credential Id
          description: Server-assigned credential identifier.
      type: object
      required:
        - credential_id
      title: CreateCredentialResponse
      description: Response body after creating a credential.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````