> ## 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.

# Run a workflow using workflow id



## OpenAPI

````yaml api-reference/openapi-spec.json post /apis/request/workflow/run
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/run:
    post:
      tags:
        - Workflow APIs
      summary: Run a workflow using workflow id
      operationId: ExternalApisController_runWorkflow
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunWorkflowReq'
      responses:
        '200':
          description: Success Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunAutonomousWorkflowRes'
      security:
        - apiKey: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --request POST \
            --url https://api.nfig.ai/apis/request/run/workflows \
            --header 'api-key: <api-key>' \
            --header 'content-type: application/json' \
            --data '{
              "workflowId": "<workflowId>"
            }'
        - lang: python
          label: Python
          source: |-
            import requests

            url = "https://api.nfig.ai/apis/request/run/workflows"
            headers = {
                "api-key": "<api-key>",
                "content-type": "application/json"
            }
            payload = {
                "workflowId": "<workflowId>"
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: |-
            const url = 'https://api.nfig.ai/apis/request/run/workflows';
            const headers = {
                'api-key': '<api-key>',
                'content-type': 'application/json'
            };
            const payload = {
                workflowId: '<workflowId>'
            };

            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/run/workflows";
            $headers = array(
                "api-key: <api-key>",
                "content-type: application/json"
            );
            $payload = array(
                "workflowId" => "<workflowId>"
            );

            $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/run/workflows"
                payload := map[string]string{
                    "workflowId": "<workflowId>",
                }
                
                jsonPayload, _ := json.Marshal(payload)
                req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))
                req.Header.Set("api-key", "<api-key>")
                req.Header.Set("content-type", "application/json")
                
                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 WorkflowRequest {
                public static void main(String[] args) {
                    try {
                        URL url = new URL("https://api.nfig.ai/apis/request/run/workflows");
                        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                        conn.setRequestMethod("POST");
                        conn.setRequestProperty("api-key", "<api-key>");
                        conn.setRequestProperty("content-type", "application/json");
                        conn.setDoOutput(true);

                        String jsonInput = "{\"workflowId\":\"<workflowId>\"}";
                        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:
    RunWorkflowReq:
      type: object
      properties:
        workflowId:
          type: string
          description: workflow id for initiating a run
        proxy:
          type: boolean
          description: Turn on proxy for workflow session
          default: false
        variables:
          type: object
          additionalProperties:
            type: string
          description: An object with dynamic keys and values
          example:
            var1: <value>
            var2: <value>
      required:
        - workflowId
    RunAutonomousWorkflowRes:
      type: object
      properties:
        sessionId:
          type: string
          description: Workflow session id
        previewUrl:
          type: string
          description: Live preview url for the workflow session
      required:
        - sessionId
        - previewUrl
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: api-key

````