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

# 创建主密码

> Create a master password under the path account.

<script src="/locale-bridge.js" />


## OpenAPI

````yaml /openapi.zh-cn.json POST /v1/public/accounts/{account_id}/credentials
openapi: 3.1.0
info:
  title: Code API (Public)
  version: 1.0.0
servers:
  - url: https://api.hybridbox.io
security: []
paths:
  /v1/public/accounts/{account_id}/credentials:
    post:
      tags:
        - public-accounts
        - public-credentials
      summary: 创建主密码
      description: Create a master password under the path account.
      operationId: >-
        create_public_credential_v1_public_accounts__account_id__credentials_post
      parameters:
        - in: path
          name: account_id
          required: true
          schema:
            format: uuid
            title: Account Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AccountCredentialCreateRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CredentialCreateResponse'
          description: ''
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: 验证错误
      security:
        - PublicBearerAuth: []
components:
  schemas:
    AccountCredentialCreateRequest:
      additionalProperties: false
      description: 在账户路径作用域下创建主密码的请求。
      properties:
        domain:
          anyOf:
            - type: string
            - type: 'null'
          description: 主密码作用域的域 UUID 或域名
          title: 域
        generate:
          default: false
          description: 生成主密码密钥，而不是提供一个
          title: 生成
          type: boolean
        name:
          description: 主密码显示名称
          maxLength: 100
          minLength: 1
          title: 名称
          type: string
        value:
          anyOf:
            - maxLength: 256
              minLength: 4
              type: string
            - type: 'null'
          description: 未生成时的主密码密钥值
          title: 值
        workspace_id:
          anyOf:
            - format: uuid
              type: string
            - type: 'null'
          description: 主密码的工作区 UUID 作用域
          title: 工作区 Id
      required:
        - name
      title: AccountCredentialCreateRequest
      type: object
    CredentialCreateResponse:
      properties:
        created_at:
          description: 主密码创建时间戳
          title: 创建时间
          type: string
        generated_secret:
          anyOf:
            - type: string
            - type: 'null'
          description: 按请求返回的一次性生成主密码密钥
          title: 生成的密钥
        id:
          description: 主密码 UUID
          format: uuid
          title: ID
          type: string
        name:
          description: 主密码显示名称
          title: 名称
          type: string
        scope_id:
          description: 主密码作用域的资源 UUID
          format: uuid
          title: 范围 Id
          type: string
        scope_type:
          description: 主密码适用的资源作用域类型
          enum:
            - account
            - workspace
            - domain
          title: 范围类型
          type: string
        updated_at:
          description: 主密码最后更新时间戳
          title: 更新时间
          type: string
      required:
        - id
        - name
        - scope_type
        - scope_id
        - created_at
        - updated_at
      title: CredentialCreateResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: 详情
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: 位置
          type: array
        msg:
          title: 消息
          type: string
        type:
          title: 错误类型
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    PublicBearerAuth:
      bearerFormat: JWT or Hybridbox Service account token
      description: >-
        Public API bearer credential sent as `Authorization: Bearer <token>`.
        Use either an OAuth access token or a Hybridbox Service account token.
      scheme: bearer
      type: http

````