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

# Stream Agent Build

> Stream Agent Build with the DialNexa API. Streams build progress as newline-delimited JSON and returns the generated draft configuration without saving or publishing an agent.

Read only

Stream Agent Build uses your workspace API key. Streams build progress as newline-delimited JSON and returns the generated draft configuration without saving or publishing an agent.

## Before you begin

Use a server-side [API key](https://dialnexa.com/docs/api-reference/api-fundamentals.md#authenticate-dialnexa-api-requests) for the intended workspace.

## Stream Agent Build request

The request panel lists supported query parameters and body fields. For a request body, the example below supplies the required fields. Replace sample values with your own inputs.

```bash theme={null}
curl --request POST 'https://api.dialnexa.com/v1/agent-builder/run/stream' \
  --header "Authorization: Bearer $DIALNEXA_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "structured_input": {
    "company_and_offering": {
      "description": "Company and offering",
      "value": "Acme provides appointment scheduling software."
    },
    "target_customer": {
      "description": "Target customer",
      "value": "Small business owners who requested a demo."
    },
    "primary_goal": {
      "description": "Call goal",
      "value": "Arrange a product demo."
    },
    "success_criteria": {
      "description": "Success criteria",
      "value": "Confirm interest and a preferred callback time."
    },
    "information_to_collect": {
      "description": "Information to collect",
      "value": "Name and preferred callback time."
    },
    "objections_and_faqs": {
      "description": "Questions",
      "value": "Explain that the demo is free."
    },
    "agent_tone": {
      "description": "Tone",
      "value": "Friendly, concise, and professional."
    },
    "additional_context": {
      "description": "Context",
      "value": "Do not promise pricing or unavailable appointment slots."
    }
  }
}'
```

## Verify the result

Expect HTTP `200` with `Content-Type: application/x-ndjson`. Parse complete lines as JSON. A `complete` event contains `data`; an `error` event can arrive after HTTP headers have already been sent. There is no success envelope around the stream.

Progress events include `phase_start`, `phase_complete`, `thinking_delta`, and `building_event`. The final result includes `status`, `missingQuestions`, `evaluation`, and `draftAgent`. A completed stream is not proof that an agent was saved.

This operation also accepts the matching `/v1/assistant` path. The request and result contracts are shared. Use one path consistently for your integration.

## Retry safety

This operation does not modify workspace resources. Retry after a transient connection failure.

## Errors and recovery

* `401`: Missing, expired, or invalid API key.
* `400`: The body failed validation, for example `build_attempt` outside `1` to `2` or an unknown `pipeline`. The 400 is a JSON error body, not an NDJSON stream.

## Related endpoints

* [Get Agent Builder Inventory](https://dialnexa.com/docs/api-reference/v1/agent-builder/inventory.md)
* [Build Agent Configuration](https://dialnexa.com/docs/api-reference/v1/agent-builder/run.md)
* [Generate Agent Objectives](https://dialnexa.com/docs/api-reference/v1/agent-builder/generate-objectives.md)
* [Generate Agent Tone](https://dialnexa.com/docs/api-reference/v1/agent-builder/generate-tone.md)
* [API authentication](https://dialnexa.com/docs/api-reference/api-fundamentals.md#authenticate-dialnexa-api-requests)


## OpenAPI

````yaml POST /v1/agent-builder/run/stream
openapi: 3.0.0
info:
  title: DialNexa API
  description: Public `/v1` REST API for the DialNexa voice AI platform.
  version: 1.0.0
servers:
  - url: https://api.dialnexa.com
    description: DialNexa production API
security:
  - bearer: []
tags:
  - name: Agents
  - name: Batch Calls
  - name: Calls
  - name: Knowledge Base
  - name: Languages
  - name: LLMs
  - name: Phone Numbers
  - name: Organization Folders
  - name: Transcribers
  - name: Webhooks
  - name: Voices
  - name: Workflows
  - name: Workflow Leads
  - name: Authentication
  - name: Agent Builder
  - name: Agent Evaluations
paths:
  /v1/agent-builder/run/stream:
    post:
      tags:
        - Agent Builder
      summary: Stream Agent Build
      description: >-
        Streams build progress as newline-delimited JSON and returns the
        generated draft configuration without saving or publishing an agent.
      operationId: streamAgentBuilder
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunAgentBuilder'
            examples:
              request:
                value:
                  structured_input:
                    company_and_offering:
                      description: Company and offering
                      value: Acme provides appointment scheduling software.
                    target_customer:
                      description: Target customer
                      value: Small business owners who requested a demo.
                    primary_goal:
                      description: Call goal
                      value: Arrange a product demo.
                    success_criteria:
                      description: Success criteria
                      value: Confirm interest and a preferred callback time.
                    information_to_collect:
                      description: Information to collect
                      value: Name and preferred callback time.
                    objections_and_faqs:
                      description: Questions
                      value: Explain that the demo is free.
                    agent_tone:
                      description: Tone
                      value: Friendly, concise, and professional.
                    additional_context:
                      description: Context
                      value: Do not promise pricing or unavailable appointment slots.
      responses:
        '200':
          description: NDJSON stream of thinking updates and final result
          content:
            application/x-ndjson:
              schema:
                type: string
                description: >-
                  One JSON object per line. Event types: phase_start,
                  phase_complete, thinking_delta, building_event, complete,
                  error. The complete event contains data with status, events,
                  missingQuestions, evaluation, draftAgent, promptText,
                  welcomeMessage, technicalProfile, and error.
              example: >
                {"type":"phase_start","phase":"thinking"}

                {"type":"thinking_delta","delta":"Reading your
                requirements","label":"Understanding your
                needs","phase":"thinking"}
        '400':
          description: >-
            The body failed validation, for example build_attempt outside 1 to 2
            or an unknown pipeline.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: Invalid body
                  value:
                    statusCode: 400
                    error: true
                    success: false
                    data: []
                    message: >-
                      build_attempt must not be greater than 2, pipeline must be
                      one of the following values: cascaded, s2s
                    errors:
                      - build_attempt must not be greater than 2
                      - >-
                        pipeline must be one of the following values: cascaded,
                        s2s
        '401':
          description: Missing, expired, or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: 401 error
                  value:
                    statusCode: 401
                    error: true
                    success: false
                    data: []
                    message: Invalid API key
                    errors: []
        '500':
          description: The request could not be completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                error:
                  summary: Server error
                  value:
                    statusCode: 500
                    error: true
                    success: false
                    data: []
                    message: Internal server error
                    errors: []
      security:
        - bearer: []
components:
  schemas:
    RunAgentBuilder:
      type: object
      properties:
        structured_input:
          description: >-
            Structured blueprint submission - each field has a description
            (field guidance) and value (user answer)
          allOf:
            - $ref: '#/components/schemas/StructuredBlueprintInput'
        build_attempt:
          type: integer
          description: >-
            Build attempt number (1-2). Validation runs only on attempt 1;
            attempt 2 skips re-validation.
          minimum: 1
          maximum: 2
          default: 1
        pipeline:
          type: string
          description: >-
            Engine for the generated agent. "s2s" builds the realtime pipeline
            on the same single-prompt agent; anything else builds the cascaded
            pipeline.
          enum:
            - cascaded
            - s2s
          default: cascaded
        target_shape:
          type: string
          description: >-
            Kind of agent to build. "cfa" writes a conversation-flow document (a
            step graph), "ivr" writes a touch-tone menu; anything else builds a
            single-prompt agent.
          enum:
            - spa
            - cfa
            - ivr
          default: spa
      required:
        - structured_input
    ErrorResponse:
      type: object
      description: Error body on endpoints without response filtering.
      properties:
        statusCode:
          type: integer
          example: 404
        error:
          type: boolean
          enum:
            - true
        success:
          type: boolean
          enum:
            - false
        data:
          oneOf:
            - type: object
              properties:
                code:
                  type: string
                  description: Machine-readable refusal code.
            - type: array
              items: {}
          description: >-
            For a coded refusal, an object with code and the details listed for
            that code. Otherwise an empty array.
        message:
          type: string
        errors:
          type: array
          items:
            type: string
          description: Validation messages for a 400. Empty for other errors.
        validation_errors:
          type: array
          description: >-
            Present when uploaded rows fail number validation (batch and
            workflow lead uploads): one group per distinct error.
          items:
            type: object
            properties:
              error:
                type: string
              rows:
                type: array
                items:
                  type: integer
                description: Row numbers with this error.
              phone_numbers:
                type: array
                items:
                  type: string
        invalid_row_count:
          type: integer
          description: 'Present with validation_errors: how many rows failed.'
      required:
        - statusCode
        - error
        - success
        - data
        - message
        - errors
    StructuredBlueprintInput:
      type: object
      properties:
        company_and_offering:
          $ref: '#/components/schemas/StructuredBlueprintField'
        target_customer:
          $ref: '#/components/schemas/StructuredBlueprintField'
        primary_goal:
          $ref: '#/components/schemas/StructuredBlueprintField'
        success_criteria:
          $ref: '#/components/schemas/StructuredBlueprintField'
        information_to_collect:
          $ref: '#/components/schemas/StructuredBlueprintField'
        objections_and_faqs:
          $ref: '#/components/schemas/StructuredBlueprintField'
        agent_tone:
          $ref: '#/components/schemas/StructuredBlueprintField'
        additional_context:
          $ref: '#/components/schemas/StructuredBlueprintField'
        validation_clarifications:
          $ref: '#/components/schemas/StructuredBlueprintField'
      required:
        - company_and_offering
        - target_customer
        - primary_goal
        - success_criteria
        - information_to_collect
        - objections_and_faqs
        - agent_tone
        - additional_context
    StructuredBlueprintField:
      type: object
      properties:
        description:
          type: string
          description: User-facing explanation of what this field is asking for
          example: >-
            Share your company name and a short description of your product,
            service, or industry.
        value:
          type: string
          description: User-provided answer for this field
          example: 'Acme Corp: we sell B2B payroll software for mid-market HR teams.'
      required:
        - description
        - value
  securitySchemes:
    bearer:
      scheme: bearer
      type: http

````

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