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

# Export Workflow Spec

> Export draft workflow state as canonical declarative YAML.

Export the current draft workflow as canonical declarative YAML.

Exports use `apiVersion: workflows.retab.com/v1alpha2` and include raw explicit handles on every non-synthetic edge.

<RequestExample>
  ```python Python theme={null}
  from retab import Retab

  client = Retab()

  exported = client.workflows.spec.get("wf_abc123")

  print(exported.yaml_definition)
  ```

  ```typescript TypeScript theme={null}
  import { Retab } from "@retab/node";

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

  const exported = await client.workflows.spec.get("wf_abc123");

  console.log(exported.yamlDefinition);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	retab "github.com/retab-dev/retab/clients/go"
  )

  func ptr[T any](v T) *T { return &v }

  func main() {
  	ctx := context.Background()

  	client, err := retab.NewClient("")
  	if err != nil {
  		log.Fatal(err)
  	}

  	exported, err := client.Workflows.Spec.Get(ctx, "wf_abc123")
  	if err != nil {
  		log.Fatal(err)
  	}

  	fmt.Println(exported.YamlDefinition)
  }
  ```

  ```ruby Ruby theme={null}
  require 'retab'

  client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])

  exported = client.workflows.spec.get(workflow_id: 'wf_abc123')

  puts exported.yaml_definition
  ```

  ```rust Rust theme={null}
  use retab::Retab;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Retab::new(std::env::var("RETAB_API_KEY")?);

      let exported = client.workflows().spec().get("wf_abc123").await?;

      println!("{}", exported.yaml_definition);
      Ok(())
  }
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Retab\Client;

  $client = new Client(apiKey: getenv('RETAB_API_KEY'));

  $result = $client->workflows()->spec()->get('wf_abc123');
  print_r($result);
  ```

  ```csharp C# theme={null}
  using Retab;
  using RetabClient = Retab.Retab;

  var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
  var client = new RetabClient(apiKey);

  var result = await client.Workflows.Spec.GetAsync("wf_abc123");
  Console.WriteLine(result);
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;

  public final class Example {
    public static void main(String[] args) throws Exception {
      RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

      var result = client.workflows().spec().get("wf_abc123");
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  curl -X 'GET' \
    'https://api.retab.com/v1/workflows/wf_abc123/spec' \
    -H 'Authorization: Bearer <your-api-key>'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "workflow_id": "wf_abc123",
    "yaml_definition": "apiVersion: workflows.retab.com/v1alpha2\nkind: Workflow\nmetadata:\n  id: wf_abc123\n  name: Invoice Workflow\nspec:\n  blocks:\n    start_document-node:\n      type: start_document\n      label: Input Document\n  edges: []\n"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /v1/workflows/{workflow_id}/spec
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/workflows/{workflow_id}/spec:
    get:
      tags:
        - Workflows
      summary: Export Workflow Spec
      description: Export draft workflow state as canonical declarative YAML.
      operationId: export_workflow_spec
      parameters:
        - in: path
          name: workflow_id
          required: true
          schema:
            type: string
            title: Workflow Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeclarativeExportResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    DeclarativeExportResponse:
      properties:
        workflow_id:
          type: string
          title: Workflow Id
        yaml_definition:
          type: string
          title: Yaml Definition
      type: object
      required:
        - workflow_id
        - yaml_definition
      title: DeclarativeExportResponse
      description: A workflow exported as its YAML definition.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    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
          default: null
        ctx:
          type: object
          title: Context
          default: {}
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````