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

# Create a credential

> Registers a credential. The secret is stored securely and never persisted in CNAP directly.



## OpenAPI

````yaml /openapi.json post /v1/credentials
openapi: 3.1.0
info:
  title: CNAP API
  version: 1.0.0
  description: >-
    Public API for managing CNAP workspaces, clusters, templates, products, and
    deployments.


    Authenticate with a Personal Access Token via the `Authorization: Bearer
    cnap_pat_...` header.


    Workspace-scoped endpoints require the `X-Workspace-Id` header.
servers:
  - url: https://api.cnap.tech
    description: Production
security: []
paths:
  /v1/credentials:
    post:
      tags:
        - Credentials
      summary: Create a credential
      description: >-
        Registers a credential. The secret is stored securely and never
        persisted in CNAP directly.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCredential'
      responses:
        '201':
          description: Credential created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedCredential'
        '401':
          description: Unauthorized
        '403':
          description: X-Workspace-Id required
      security:
        - BearerAuth: []
components:
  schemas:
    CreateCredential:
      anyOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - cloud
            name:
              type: string
              minLength: 1
              maxLength: 100
            provider:
              type: string
              enum:
                - hcloud
            api_token:
              type: string
              minLength: 1
              description: Cloud provider API token
          required:
            - type
            - name
            - provider
            - api_token
    CreatedCredential:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - cloud
            - registry
            - cloudflare
      required:
        - id
        - type
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Personal Access Token (cnap_pat_...) or OAuth2 JWT. Create tokens at
        https://cnap.tech/account/tokens

````