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

# Create Target Credential

> Store a credential on a target. Before adding an api_key credential, the API target must already have non-empty api_auth_instructions; update the target with the validation route, HTTP method, request shape, and successful response first.



## OpenAPI

````yaml /openapi.json post /v1/targets/{target_id}/credentials
openapi: 3.1.0
info:
  title: MindFort API
  version: 1.0.0
  description: >-
    The MindFort Public API supports targets, assessments, finding lifecycle and
    analytics, and reports. Public responses use positive field allowlists and
    call informational non-vulnerable results `secured`.
servers:
  - url: https://api.mindfort.app
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/targets/{target_id}/credentials:
    post:
      tags:
        - Credentials
      summary: Create Target Credential
      description: >-
        Store a credential on a target. Before adding an api_key credential, the
        API target must already have non-empty api_auth_instructions; update the
        target with the validation route, HTTP method, request shape, and
        successful response first.
      operationId: createTargetCredential
      parameters:
        - name: target_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TargetCredentialCreateRequest'
      responses:
        '201':
          description: Credential stored
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicTargetCredential'
components:
  schemas:
    TargetCredentialCreateRequest:
      type: object
      required:
        - credential_name
        - credential_type
      properties:
        credential_name:
          type: string
          minLength: 1
          maxLength: 255
        credential_type:
          type: string
          enum:
            - application_login
            - magic_link
            - email_mfa
            - authenticator_2fa
            - sms_mfa
            - sms_login
            - api_key
        username:
          type:
            - string
            - 'null'
          maxLength: 255
        password:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 255
          writeOnly: true
        role:
          type: string
          enum:
            - user
            - admin
            - viewer
            - editor
            - custom
          default: user
        description:
          type:
            - string
            - 'null'
        login_instructions:
          type:
            - string
            - 'null'
        pending_email_id:
          type:
            - string
            - 'null'
          format: uuid
        authenticator_2fa_secret:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 255
          writeOnly: true
        api_key_credential:
          anyOf:
            - $ref: '#/components/schemas/APIKeyCredentialInput'
            - type: 'null'
          writeOnly: true
        sms_country_code:
          type:
            - string
            - 'null'
          pattern: ^[A-Za-z]{2}$
      additionalProperties: false
    PublicTargetCredential:
      type: object
      required:
        - id
        - role
        - api_key_configured
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        credential_name:
          type:
            - string
            - 'null'
        username:
          type:
            - string
            - 'null'
        role:
          type: string
        description:
          type:
            - string
            - 'null'
        login_instructions:
          type:
            - string
            - 'null'
        credential_type:
          type:
            - string
            - 'null'
        agentmail_email:
          type:
            - string
            - 'null'
        authenticator_phone_number:
          type:
            - string
            - 'null'
          description: >-
            System-provisioned phone number for SMS credentials; not a writable
            authenticator input.
        api_key_configured:
          type: boolean
        api_key_placement:
          anyOf:
            - $ref: '#/components/schemas/PublicAPIKeyPlacement'
            - type: 'null'
        api_additional_fields:
          type:
            - object
            - 'null'
          additionalProperties:
            type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      additionalProperties: false
    APIKeyCredentialInput:
      type: object
      writeOnly: true
      required:
        - secret
      properties:
        secret:
          type: string
          minLength: 1
          writeOnly: true
        placement:
          $ref: '#/components/schemas/APIKeyPlacementInput'
        additional_fields:
          type:
            - object
            - 'null'
          additionalProperties:
            type: string
      additionalProperties: false
    PublicAPIKeyPlacement:
      type: object
      required:
        - kind
      properties:
        kind:
          type: string
          enum:
            - bearer
            - header
            - query
            - json_body
        header_name:
          type:
            - string
            - 'null'
        query_param:
          type:
            - string
            - 'null'
        json_field_path:
          type:
            - string
            - 'null'
        bearer_prefix:
          type:
            - string
            - 'null'
        extra_headers:
          type:
            - object
            - 'null'
          additionalProperties:
            type: string
      additionalProperties: false
    APIKeyPlacementInput:
      type: object
      properties:
        kind:
          type: string
          enum:
            - bearer
            - header
            - query
            - json_body
          default: header
        header_name:
          type:
            - string
            - 'null'
        query_param:
          type:
            - string
            - 'null'
        json_field_path:
          type:
            - string
            - 'null'
        bearer_prefix:
          type:
            - string
            - 'null'
        extra_headers:
          type:
            - object
            - 'null'
          additionalProperties:
            type: string
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key generated from the MindFort dashboard. Pass as `Authorization:
        Bearer <your-api-key>`.

````