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

# Create data source credential

> Browser session authentication; RBAC permission `credentials.write`. Creates the org-scoped credential the metrics and log data sources reference by credential_name; the secret is stored in Vault and never echoed.



## OpenAPI

````yaml https://platform.ankra.app/openapi.json post /org/credentials/datasource
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://platform.ankra.app
security: []
paths:
  /org/credentials/datasource:
    post:
      tags:
        - Data Source Credentials API
      summary: Create data source credential
      description: >-
        Browser session authentication; RBAC permission `credentials.write`.
        Creates the org-scoped credential the metrics and log data sources
        reference by credential_name; the secret is stored in Vault and never
        echoed.
      operationId: create_datasource_credential_browser
      parameters:
        - description: Must match the ankra_csrf browser cookie.
          in: header
          name: X-Ankra-CSRF
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DataSourceCredentialCreateRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataSourceCredentialCreateResponse'
          description: Successful response
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: Invalid request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: Unauthenticated
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: Permission or CSRF check failed
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: Resource not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Request validation failed
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractDetailError'
          description: Provider or internal failure
      security:
        - SessionCookie: []
components:
  schemas:
    DataSourceCredentialCreateRequest:
      example:
        auth_scheme: basic
        name: infra-opensearch
        password: <secret>
        username: logs-reader
      properties:
        auth_scheme:
          description: >-
            bearer or api_key for token credentials (defaults to bearer); basic
            for username/password credentials (the default when username and
            password are sent).
          type: string
        name:
          type: string
        password:
          type: string
          writeOnly: true
        token:
          type: string
          writeOnly: true
        username:
          type: string
      required:
        - name
      type: object
    DataSourceCredentialCreateResponse:
      example:
        errors: []
        id: 00000000-0000-0000-0000-000000000001
        name: infra-opensearch
        success: true
      properties:
        errors:
          items:
            additionalProperties: true
            properties: {}
            type: object
          type: array
        id:
          format: uuid
          type: string
        name:
          type: string
        success:
          type: boolean
      required:
        - success
        - id
        - name
        - errors
      type: object
    ContractDetailError:
      example:
        detail: Cluster not found
      properties:
        detail:
          oneOf:
            - type: string
            - additionalProperties: true
              properties: {}
              type: object
      required:
        - detail
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    SessionCookie:
      description: Browser session. Mutations also require X-Ankra-CSRF.
      in: cookie
      name: ankra_session
      type: apiKey

````