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

# List Edges

> List edges for a workflow with keyset cursor pagination.

Optionally filter by source or target block ID. Sorted by `updated_at`
descending with `id` as the tiebreaker. Pass `after` for the next
page, `before` for the previous page — mutually exclusive.

List edges in a workflow's current draft. Optionally filter to edges incident to a specific block by passing `source_block` or `target_block`.

Returns the canonical `{ "data": [...], "list_metadata": { "before": null, "after": null } }` pagination envelope shared with all Retab list endpoints. Cursor pagination is not yet implemented for this endpoint — `list_metadata` is always `{ before: null, after: null }`.

Use this endpoint with [List Blocks](/api-reference/workflows/blocks/list) when you need to reconstruct a workflow graph.

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

  client = Retab()

  # All edges
  edges = client.workflows.edges.list("wf_abc123xyz")

  # Outgoing edges of one block
  outgoing = client.workflows.edges.list(
      "wf_abc123xyz",
      source_block="extract-1",
  )

  # Incoming edges of one block
  incoming = client.workflows.edges.list(
      "wf_abc123xyz",
      target_block="extract-1",
  )

  for edge in edges.data:
      print(f"{edge.source_block}/{edge.source_handle} -> {edge.target_block}/{edge.target_handle}")
  ```

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

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

  const edges = await client.workflows.edges.list({ workflowId: "wf_abc123xyz" });

  const outgoing = await client.workflows.edges.list({ workflowId: "wf_abc123xyz", 
    sourceBlock: "extract-1",
   });

  const incoming = await client.workflows.edges.list({ workflowId: "wf_abc123xyz", 
    targetBlock: "extract-1",
   });
  ```

  ```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)
  	}

  	// All edges
  	edges, err := client.Workflows.Edges.List(ctx, &retab.WorkflowEdgesListParams{
  		WorkflowID: "wf_abc123xyz",
  	})
  	if err != nil {
  		log.Fatal(err)
  	}

  	// Outgoing edges of one block
  	outgoing, err := client.Workflows.Edges.List(ctx, &retab.WorkflowEdgesListParams{
  		WorkflowID:   "wf_abc123xyz",
  		SourceBlock:  ptr("extract-1"),
  	})
  	if err != nil {
  		log.Fatal(err)
  	}

  	// Incoming edges of one block
  	incoming, err := client.Workflows.Edges.List(ctx, &retab.WorkflowEdgesListParams{
  		WorkflowID:   "wf_abc123xyz",
  		TargetBlock:  ptr("extract-1"),
  	})
  	if err != nil {
  		log.Fatal(err)
  	}

  	for _, edge := range edges.Data {
  		fmt.Printf("%s/%v -> %s/%v\n", edge.SourceBlock, edge.SourceHandle, edge.TargetBlock, edge.TargetHandle)
  	}
  	_, _ = outgoing, incoming
  }
  ```

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

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

  # All edges
  edges = client.workflows.edges.list(workflow_id: 'wf_abc123xyz')

  # Outgoing edges of one block
  outgoing = client.workflows.edges.list(
    workflow_id: 'wf_abc123xyz',
    source_block: 'extract-1',
  )

  # Incoming edges of one block
  incoming = client.workflows.edges.list(
    workflow_id: 'wf_abc123xyz',
    target_block: 'extract-1',
  )

  edges.data.each do |edge|
    puts "#{edge.source_block}/#{edge.source_handle} -> #{edge.target_block}/#{edge.target_handle}"
  end
  ```

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

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

      // All edges
      let edges = client
          .workflows().edges()
          .list(ListParams::new("wf_abc123xyz"))
          .await?;

      // Outgoing edges of one block
      let _outgoing = client
          .workflows().edges()
          .list(ListParams {
              source_block: Some("extract-1".into()),
              ..ListParams::new("wf_abc123xyz")
          })
          .await?;

      // Incoming edges of one block
      let _incoming = client
          .workflows().edges()
          .list(ListParams {
              target_block: Some("extract-1".into()),
              ..ListParams::new("wf_abc123xyz")
          })
          .await?;

      for edge in &edges.data {
          println!(
              "{}/{} -> {}/{}",
              edge.source_block,
              edge.source_handle.as_deref().unwrap_or(""),
              edge.target_block,
              edge.target_handle.as_deref().unwrap_or(""),
          );
      }
      Ok(())
  }
  ```

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

  use Retab\Client;

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

  $result = $client->workflows()->edges()->list(
      workflowId: '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.Edges.ListAsync(new WorkflowEdgesListOptions());
  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().edges().list("wf_abc123", null, null, null, null, 10L);
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  # All edges
  curl -X 'GET' \
    'https://api.retab.com/v1/workflows/edges?workflow_id=wf_abc123xyz' \
    -H 'Authorization: Bearer <your-api-key>'

  # Filter by source block
  curl -X 'GET' \
    'https://api.retab.com/v1/workflows/edges?workflow_id=wf_abc123xyz&source_block=extract-1' \
    -H 'Authorization: Bearer <your-api-key>'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": [
      {
        "id": "edge-1",
        "workflow_id": "wf_abc123xyz",
        "source_block": "start-1",
        "target_block": "extract-1",
        "source_handle": "output-file-0",
        "target_handle": "input-file-0",
        "updated_at": "2026-04-30T17:00:00Z"
      }
    ],
    "list_metadata": {
      "before": null,
      "after": null
    }
  }
  ```

  ```json 404 theme={null}
  {
    "detail": "Workflow not found"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /v1/workflows/edges
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/workflows/edges:
    get:
      tags:
        - Workflows
        - Workflow Edges
      summary: List Edges
      description: |-
        List edges for a workflow with keyset cursor pagination.

        Optionally filter by source or target block ID. Sorted by `updated_at`
        descending with `id` as the tiebreaker. Pass `after` for the next
        page, `before` for the previous page — mutually exclusive.
      operationId: list_edges
      parameters:
        - in: query
          name: workflow_id
          required: true
          schema:
            type: string
            title: Workflow Id
        - in: query
          name: source_block
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by source block ID
            title: Source Block
          required: false
          description: Filter by source block ID
        - in: query
          name: target_block
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by target block ID
            title: Target Block
          required: false
          description: Filter by target block ID
        - in: query
          name: before
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Edge id cursor: return the page before this id (mutually exclusive
              with `after`).
            title: Before
          required: false
          description: >-
            Edge id cursor: return the page before this id (mutually exclusive
            with `after`).
        - in: query
          name: after
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Edge id cursor: return the page after this id (mutually exclusive
              with `before`).
            title: After
          required: false
          description: >-
            Edge id cursor: return the page after this id (mutually exclusive
            with `before`).
        - in: query
          name: limit
          schema:
            type: integer
            maximum: 200
            minimum: 1
            description: Maximum number of edges to return per page (1-200).
            default: 100
            title: Limit
          required: false
          description: Maximum number of edges to return per page (1-200).
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowEdgeList'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    WorkflowEdgeList:
      description: >-
        A page of `WorkflowEdge` resources. `data` holds the items and
        `list_metadata` carries the `before`/`after` cursors; pass `after` to
        fetch the next page.
      properties:
        data:
          items:
            $ref: '#/components/schemas/WorkflowEdge'
          type: array
          title: Data
        list_metadata:
          $ref: '#/components/schemas/ListMetadata'
      type: object
      required:
        - data
        - list_metadata
      title: WorkflowEdgeList
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    WorkflowEdge:
      properties:
        id:
          type: string
          title: Id
        workflow_id:
          type: string
          title: Workflow Id
          description: Foreign key to workflow
        source_block:
          type: string
          title: Source Block
          description: ID of the source block
        target_block:
          type: string
          title: Target Block
          description: ID of the target block
        source_handle:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Handle
          description: Output handle on source block
        target_handle:
          anyOf:
            - type: string
            - type: 'null'
          title: Target Handle
          description: Input handle on target block
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - source_block
        - target_block
        - updated_at
        - workflow_id
      title: WorkflowEdge
      description: Public live workflow edge object.
    ListMetadata:
      properties:
        before:
          anyOf:
            - type: string
            - type: 'null'
          title: Before
        after:
          anyOf:
            - type: string
            - type: 'null'
          title: After
      type: object
      required:
        - after
        - before
      title: ListMetadata
      description: Boundary resource IDs for page navigation.
    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

````