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

# Execute an individual step



## OpenAPI

````yaml api-reference/openapi-spec.json post /apis/request/workflow/step/run/{id}
openapi: 3.0.0
info:
  title: nFig Agent Backend
  description: nFig Agent Backend
  version: '1.0'
  contact: {}
servers:
  - url: https://api.nfig.ai
    description: Production server
security:
  - bearer: []
tags:
  - name: nFig
    description: ''
paths:
  /apis/request/workflow/step/run/{id}:
    post:
      tags:
        - Workflow Step Mode APIs
      summary: Execute an individual step
      operationId: ExternalApisController_createWorkflowStepRun
      parameters:
        - name: id
          required: true
          in: path
          description: Unique identifier for each workflow session
          example: 92a7a42a-ee05-8abb-e0ed250d6c79
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StepRunReq'
      responses:
        '200':
          description: Create a workflow step run
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunStepWorkflowRes'
      security:
        - apiKey: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --request POST \
            --url https://api.nfig.ai/apis/request/workflow/step/run/<id> \
            --header 'Content-Type: application/json' \
            --header 'api-key: <api-key>' \
            --data '{
             "step": "<step>",
             "type": "<stepType>",
             "schema": {
             "<openapi-schema>"
             }
            }'
        - lang: python
          label: Python
          source: |-
            import requests

            url = "https://api.nfig.ai/apis/request/workflow/step/run/<id>"
            headers = {
             "Content-Type": "application/json",
             "api-key": "<api-key>"
            }
            payload = {
             "step": "<step>",
             "type": "<stepType>",
             "schema": {
             # Add your OpenAPI schema here
             # "<openapi-schema>"
             }
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: >-
            const url =
            'https://api.nfig.ai/apis/request/workflow/step/run/<id>';

            const headers = {
             'Content-Type': 'application/json',
             'api-key': '<api-key>'
            };

            const payload = {
             step: '<step>',
             type: '<stepType>',
             schema: {
             // "<openapi-schema>"
             }
            };


            fetch(url, {
             method: 'POST',
             headers: headers,
             body: JSON.stringify(payload)
            })

            .then(response => response.json())

            .then(data => console.log(data))

            .catch(error => console.error('Error:', error));
        - lang: php
          label: PHP
          source: |-
            <?php
            $url = "https://api.nfig.ai/apis/request/workflow/step/run/<id>";
            $headers = array(
             "Content-Type: application/json",
             "api-key: <api-key>"
            );
            $payload = array(
             "step" => "<step>",
             "type" => "<stepType>",
             "schema" => array(
             // Add your OpenAPI schema here
             // "<openapi-schema>"
             )
            );

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);
            echo $response;
            ?>
        - lang: go
          label: Go
          source: |-
            package main

            import (
             "bytes"
             "encoding/json"
             "fmt"
             "net/http"
            )

            func main() {
             url := "https://api.nfig.ai/apis/request/workflow/step/run/<id>"
             payload := map[string]interface{}{
             "step": "<step>",
             "type": "<stepType>",
             "schema": map[string]interface{}{
             // Add your OpenAPI schema here
             // "<openapi-schema>"
             },
             }
             
             jsonPayload, _ := json.Marshal(payload)
             req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))
             req.Header.Set("Content-Type", "application/json")
             req.Header.Set("api-key", "<api-key>")
             
             client := &http.Client{}
             resp, err := client.Do(req)
             if err != nil {
             panic(err)
             }
             defer resp.Body.Close()
             
             var result map[string]interface{}
             json.NewDecoder(resp.Body).Decode(&result)
             fmt.Println(result)
            }
        - lang: java
          label: Java
          source: |-
            import java.io.OutputStream;
            import java.net.HttpURLConnection;
            import java.net.URL;
            import java.nio.charset.StandardCharsets;

            public class WorkflowStepRun {
             public static void main(String[] args) {
             try {
             URL url = new URL("https://api.nfig.ai/apis/request/workflow/step/run/<id>");
             HttpURLConnection conn = (HttpURLConnection) url.openConnection();
             conn.setRequestMethod("POST");
             conn.setRequestProperty("Content-Type", "application/json");
             conn.setRequestProperty("api-key", "<api-key>");
             conn.setDoOutput(true);
             
             String jsonInput = String.format("""
             {
             "step": "%s",
             "type": "%s",
             "schema": {
             %s
             }
             }
             """,
             "<step>",
             "<stepType>",
             "<openapi-schema>"
             );
             
             try(OutputStream os = conn.getOutputStream()) {
             byte[] input = jsonInput.getBytes(StandardCharsets.UTF_8);
             os.write(input, 0, input.length);
             }
             
             int responseCode = conn.getResponseCode();
             System.out.println("Response Code: " + responseCode);
             conn.disconnect();
             } catch(Exception e) {
             e.printStackTrace();
             }
             }
            }
components:
  schemas:
    StepRunReq:
      type: object
      properties:
        step:
          type: string
          description: Step to be executted
          example: Go to amazon.com
        type:
          type: string
          enum:
            - ACT
            - ASK
          description: Whether it is an ASK or ACT method
          example: ACT
        schema:
          type: object
          description: open ai compatable schema for structured output
      required:
        - step
        - type
        - currentDom
        - currentPageURL
    RunStepWorkflowRes:
      type: object
      properties:
        stepId:
          type: string
          description: Workflow executed step id
        jobTaskId:
          type: string
          description: Workflow session job id
      required:
        - stepId
        - jobTaskId
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: api-key

````