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

# Save Agent Draft

> API key permission: Agents (Admin also opens it).



## OpenAPI

````yaml /api-reference/openapi.json put /agents/{agent_id}/draft
openapi: 3.1.0
info:
  title: Neural Factory API
  version: 0.1.0
  description: >-
    The endpoints a program can call with an API key. Exchange the key's secret
    for a token at POST /apikeys/token and send it as a Bearer token.
servers:
  - url: https://api.neuralfactory.ai
    description: SaaS
  - url: https://{apiHost}
    description: 'Enterprise: the API address of your own deployment'
    variables:
      apiHost:
        default: api.example.com
        description: Your deployment's API host
security:
  - bearerAuth: []
tags:
  - name: API keys
  - name: Chat
  - name: Runs
  - name: Agents
  - name: Workflows
  - name: Schedules
  - name: Knowledge bases
  - name: Documents
  - name: Search
  - name: Skills
  - name: Toolkits
  - name: Files
  - name: Interactions
  - name: Usage and billing
  - name: Catalogue
  - name: Browser
  - name: Users
  - name: Groups
  - name: Builds
paths:
  /agents/{agent_id}/draft:
    put:
      tags:
        - Agents
      summary: Save Agent Draft
      description: 'API key permission: Agents (Admin also opens it).'
      operationId: save_agent_draft_agents__agent_id__draft_put
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent Id
        - name: env
          in: query
          required: false
          schema:
            title: Env
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentDraftUpdate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentDraftResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AgentDraftUpdate:
      properties:
        spec:
          $ref: '#/components/schemas/AgentSpec'
        expected_revision:
          anyOf:
            - type: integer
            - type: 'null'
          title: Expected Revision
        design_history_append:
          anyOf:
            - items:
                $ref: >-
                  #/components/schemas/api__agents__builder_models__DesignLogEntry
              type: array
            - type: 'null'
          title: Design History Append
      type: object
      required:
        - spec
      title: AgentDraftUpdate
    AgentDraftResponse:
      properties:
        draft:
          $ref: '#/components/schemas/AgentDraft'
        checks:
          items:
            $ref: '#/components/schemas/Check'
          type: array
          title: Checks
      type: object
      required:
        - draft
      title: AgentDraftResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentSpec:
      properties:
        title:
          type: string
          title: Title
        description:
          type: string
          title: Description
        knowledge_bases:
          items:
            type: string
          type: array
          title: Knowledge Bases
        prompt:
          type: string
          title: Prompt
        tags:
          items:
            type: string
          type: array
          title: Tags
          default: []
        model:
          type: string
          title: Model
        allowed_groups:
          items:
            type: string
          type: array
          title: Allowed Groups
          default: []
        allowed_user_ids:
          items:
            type: string
          type: array
          title: Allowed User Ids
          default: []
        visibility:
          type: string
          title: Visibility
          default: private
        strict_mode:
          type: boolean
          title: Strict Mode
          default: false
        strict_mode_message:
          type: string
          title: Strict Mode Message
          default: ''
        show_citations:
          type: boolean
          title: Show Citations
          default: false
        core_tools:
          items:
            type: string
          type: array
          title: Core Tools
          default:
            - web_search
            - knowledge_search
            - code_execution
            - file_editor
            - browser_automation
            - browser_control
            - image_generation
        toolkits:
          items:
            $ref: '#/components/schemas/ToolkitSelection'
          type: array
          title: Toolkits
          default: []
        workflows:
          items:
            $ref: '#/components/schemas/WorkflowSelection'
          type: array
          title: Workflows
          default: []
        agent_type:
          type: string
          enum:
            - agent
            - subagent
          title: Agent Type
          default: agent
        subagents:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Subagents
        workflow_config:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Workflow Config
        skills:
          items:
            type: string
          type: array
          title: Skills
          default: []
        guardrails:
          $ref: '#/components/schemas/Guardrails'
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        rationale:
          additionalProperties:
            type: string
          type: object
          title: Rationale
      type: object
      required:
        - title
        - description
        - knowledge_bases
        - prompt
        - model
      title: AgentSpec
      description: >-
        An agent as the builder shapes it: the configuration plus guardrails and

        the reasons behind each section. The runtime switches the guardrails
        imply

        are derived here so the document and the guardrails never disagree.
    api__agents__builder_models__DesignLogEntry:
      properties:
        role:
          type: string
          enum:
            - user
            - ai
          title: Role
        content:
          type: string
          maxLength: 20000
          title: Content
        at:
          anyOf:
            - type: string
            - type: 'null'
          title: At
        files:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Files
        kind:
          anyOf:
            - type: string
              const: status
            - type: 'null'
          title: Kind
      type: object
      required:
        - role
        - content
      title: DesignLogEntry
      description: 'One line of the builder transcript: a brief, a reply, or a state note.'
    AgentDraft:
      properties:
        spec:
          $ref: '#/components/schemas/AgentSpec'
        revision:
          type: integer
          title: Revision
        updated_at:
          type: string
          format: date-time
          title: Updated At
        updated_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Updated By
      type: object
      required:
        - spec
        - revision
        - updated_at
      title: AgentDraft
      description: The unpublished working copy of an agent.
    Check:
      properties:
        id:
          type: string
          title: Id
        severity:
          type: string
          enum:
            - warn
            - info
          title: Severity
        title:
          type: string
          title: Title
        detail:
          type: string
          title: Detail
          default: ''
        fix:
          anyOf:
            - $ref: '#/components/schemas/CheckFix'
            - type: 'null'
      type: object
      required:
        - id
        - severity
        - title
      title: Check
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ToolkitSelection:
      properties:
        toolkit_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Toolkit Id
        name:
          type: string
          title: Name
        selectedTools:
          items:
            type: string
          type: array
          title: Selectedtools
          default: []
      type: object
      required:
        - name
      title: ToolkitSelection
    WorkflowSelection:
      properties:
        workflow_id:
          type: string
          title: Workflow Id
        name:
          type: string
          title: Name
        version:
          anyOf:
            - type: string
            - type: 'null'
          title: Version
          default: published
      type: object
      required:
        - workflow_id
        - name
      title: WorkflowSelection
      description: >-
        A deterministic workflow this agent may run as a tool. ``version``
        selects

        which revision to execute ('published' by default).
    Guardrails:
      properties:
        scope:
          type: string
          title: Scope
          default: ''
        cite_sources:
          type: boolean
          title: Cite Sources
          default: true
        hand_off:
          anyOf:
            - type: string
            - type: 'null'
          title: Hand Off
        approval_before:
          anyOf:
            - type: string
            - type: 'null'
          title: Approval Before
        language:
          type: string
          title: Language
          default: match the question
        knowledge_only:
          type: boolean
          title: Knowledge Only
          default: false
      type: object
      title: Guardrails
    CheckFix:
      properties:
        kind:
          type: string
          enum:
            - ask
            - open
            - connect
          title: Kind
        arg:
          type: string
          title: Arg
          default: ''
      type: object
      required:
        - kind
      title: CheckFix
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        The access_token returned by POST /apikeys/token for an API key's
        secret.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.