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

# Execute function

> Runs the saved draft of a function once with the inputs in the body, without compiling the agent or starting a conversation. The run stops at the function's timeout or 18 seconds, whichever is shorter, and nothing is saved.



## OpenAPI

````yaml /specs-prettified/realtime/openapi.stable.json post /v1/stable/function/{functionID}/execute
openapi: 3.0.0
info:
  title: Realtime
  description: Realtime gateway API service
  version: 1.0.0
  contact: {}
servers:
  - url: https://realtime-api.voiceflow.com
security: []
tags: []
paths:
  /v1/stable/function/{functionID}/execute:
    post:
      tags:
        - Function
      summary: Execute function
      description: Runs the saved draft of a function once with the inputs in the
        body, without compiling the agent or starting a conversation. The run
        stops at the function's timeout or 18 seconds, whichever is shorter, and
        nothing is saved.
      operationId: StableFunctionController_execute
      parameters:
        - name: functionID
          required: true
          in: path
          schema:
            type: string
          x-vf-doc:
            description: The ID of the function to execute.
          description: The ID of the function to execute.
        - name: projectID
          required: true
          in: query
          schema:
            type: string
            description: The ID of the project to operate on.
        - name: environmentAlias
          required: true
          in: query
          schema:
            type: string
            description: The alias of the environment to operate on (e.g. `main`).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StableFunctionExecuteRequest"
      responses:
        "200":
          description: Returns the function's output variables, the exit path it chose,
            and the traces it emitted, with success, latencyMs, and error
            fields.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StableFunctionExecuteResponse"
          x-vf-doc:
            description: Returns the function's output variables, the exit path it chose,
              and the traces it emitted, with success, latencyMs, and error
              fields.
      security:
        - token: []
components:
  schemas:
    StableFunctionExecuteRequest:
      type: object
      properties:
        inputs:
          default: {}
          description: A value for each of the function's input variables, keyed by input
            name. Every declared input needs a value, and a name the function
            does not declare is refused. List them with get_schema.
          type: object
          additionalProperties:
            $ref: "#/components/schemas/ExecuteInputString"
      additionalProperties: false
    ExecuteInputString:
      type: string
      description: "A value sent to a tool for one run, never stored. Plain text.
        {secret_name} inserts a project secret: the server fills in the value
        this environment would use in a conversation, and the value reads
        [secret] wherever it appears in the result. Brace text is a token when
        the text between the braces has no space at either end and holds only
        letters, digits, underscores, inner spaces, ., [, ], $ or -. A token
        that names no project secret, such as {customer_id} or {var name}, is
        refused before the tool runs, because a single run has no conversation
        to read a variable from: pass the value itself. Any other brace text is
        sent as written, so code, JSON and GraphQL such as query { user { id } }
        run as they are. Compact brace text such as {id} still reads as a token:
        write { id } to send it as text. A secret whose name is not letters,
        digits and underscores cannot be referenced. A {secret_name} token is
        filled in only in a top-level string value of inputs. Inside a nested
        object or array it is sent as written, and no secret is filled in."
    StableFunctionExecuteResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the tool ran and reported no error.
        latencyMs:
          type: number
          description: How long the run took, in milliseconds, measured by this API around
            the call.
        error:
          nullable: true
          description: Why the run failed when `success` is false, otherwise null. Secret
            values read `[secret]`.
          type: string
        truncated:
          type: boolean
          description: Whether a returned payload was over 64 KB and was cut to its first
            64 KB of JSON text, which then arrives as a string.
        output:
          nullable: true
          description: What the function returned, on failure too. Null only when
            general-runtime did not answer in time.
          allOf:
            - $ref: "#/components/schemas/StableFunctionExecuteOutput"
      required:
        - success
        - latencyMs
        - error
        - truncated
        - output
    StableFunctionExecuteOutput:
      type: object
      properties:
        outputVars:
          type: object
          additionalProperties: {}
          description: The output variables the function returned, keyed by name. At
            runtime only string, number and boolean values reach a variable.
        path:
          nullable: true
          description: "The exit path the function chose with `next: { path }`, or null
            when it chose none."
          type: string
        traces:
          type: array
          items:
            $ref: "#/components/schemas/StableFunctionExecuteTrace"
          description: The traces the function emitted, in order. A failed run may carry a
            `debug` trace that says why, but not always.
      required:
        - outputVars
        - path
        - traces
    StableFunctionExecuteTrace:
      type: object
      properties:
        type:
          type: string
          description: The trace type, such as `text`, `speak`, `choice`, `cardV2` or
            `debug`.
        payload:
          description: The trace payload as the function emitted it. Secret values read
            `[secret]`.
      required:
        - type
        - payload
  securitySchemes:
    token:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Voiceflow bearer token
````
