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

# Create Credential

> Use this endpoint to add a credential programmatically via the API. This endpoint should be used primarily for non-OAuth blocks. If you are using custom OAuth with an OAuth block and you have the OAuth tokens already, you can add them to Alloy with this endpoint. Please reference [this](/embedded/headless-mode) section of our docs for a complete tutorial on when and how to use this endpoint.



## OpenAPI

````yaml post /headless/credentials
openapi: 3.0.1
info:
  title: Embedded 2025-09
  version: '5.0'
servers:
  - url: https://production.runalloy.com
security: []
paths:
  /headless/credentials:
    post:
      summary: Create Credential
      description: >-
        Use this endpoint to add a credential programmatically via the API. This
        endpoint should be used primarily for non-OAuth blocks. If you are using
        custom OAuth with an OAuth block and you have the OAuth tokens already,
        you can add them to Alloy with this endpoint. Please reference
        [this](/embedded/headless-mode) section of our docs for a complete
        tutorial on when and how to use this endpoint.
      operationId: create-a-credential
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
            default: bearer YOUR_API_KEY
        - $ref: '#/components/parameters/xApiVersion'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - credential
                - userId
              properties:
                credential:
                  type: object
                  description: The data for the credential you want to create.
                  properties:
                    type:
                      type: string
                      description: Connector name, e.g., "netsuite".
                    data:
                      type: object
                      description: Connector authentication required parameters.
                      properties:
                        realm:
                          type: string
                        consumerKey:
                          type: string
                        tokenId:
                          type: string
                        tokenSecret:
                          type: string
                userId:
                  type: string
                  description: The id of the currently logged in user
            examples:
              Request Example:
                value:
                  userId: string
                  credential:
                    type: netsuite
                    data:
                      realm: XXX
                      consumerKey: XXX
                      tokenId: XXX
                      tokenSecret: XXX
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    success: true
                    credentialId: 63252d14cc29df15cc481a76
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                    default: true
                  credentialId:
                    type: string
                    example: 63252d14cc29df15cc481a76
      deprecated: false
      security: []
components:
  parameters:
    xApiVersion:
      name: x-api-version
      in: header
      required: true
      description: The version of the API to use. The current API version is **2025-09**.
      schema:
        type: string
        default: 2025-09

````