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

> List blocks for a workflow with keyset cursor pagination.

Sorted by `updated_at` descending with `id` as the tiebreaker. Pass
`after` (the previous response's `list_metadata.after`) for the next
page, `before` for the previous page. They are mutually exclusive; the
400 cleanly tells the caller which to drop.

List every authored block in a workflow's current draft.

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 Edges](/api-reference/workflows/edges/list) when you need to reconstruct a workflow graph.

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

  client = Retab()

  blocks = client.workflows.blocks.list("wf_abc123xyz")

  for block in blocks.data:
      print(f"{block.id} ({block.type}): {block.label}")
  ```

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

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

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

  for (const block of blocks.data) {
    console.log(`${block.id} (${block.type}): ${block.label}`);
  }
  ```

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

  	blocks, err := client.Workflows.Blocks.List(ctx, &retab.WorkflowBlocksListParams{
  		WorkflowID: "wf_abc123xyz",
  	})
  	if err != nil {
  		log.Fatal(err)
  	}

  	for _, block := range blocks.Data {
  		fmt.Printf("%s (%s): %v\n", block.ID, block.Type, block.Label)
  	}
  }
  ```

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

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

  blocks = client.workflows.blocks.list(workflow_id: 'wf_abc123xyz')

  blocks.data.each do |block|
    puts "#{block.id} (#{block.type}): #{block.label}"
  end
  ```

  ```rust Rust theme={null}
  use retab::resources::workflow_blocks::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")?);

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

      for block in &blocks.data {
          println!(
              "{} ({}): {}",
              block.id,
              block.type_,
              block.label.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()->blocks()->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.Blocks.ListAsync(new WorkflowBlocksListOptions());
  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().blocks().list("wf_abc123", null, null, 10L);
      System.out.println(result);
    }
  }
  ```

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "data": [
      {
        "id": "start-1",
        "workflow_id": "wf_abc123xyz",
        "type": "start_document",
        "label": "Invoice Input",
        "position_x": 0,
        "position_y": 0,
        "width": 240,
        "height": 120,
        "config": null,
        "parent_id": null,
        "updated_at": "2026-04-30T17:00:00Z"
      },
      {
        "id": "extract-1",
        "workflow_id": "wf_abc123xyz",
        "type": "extract",
        "label": "Extract Invoice Fields",
        "position_x": 320,
        "position_y": 0,
        "width": 240,
        "height": 120,
        "config": {
          "model": "gpt-5",
          "json_schema": {
            "type": "object",
            "properties": {
              "invoice_number": { "type": "string" },
              "total": { "type": "number" }
            }
          }
        },
        "parent_id": null,
        "updated_at": "2026-05-01T14:30:00Z"
      }
    ],
    "list_metadata": {
      "before": null,
      "after": null
    }
  }
  ```

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


## OpenAPI

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

        Sorted by `updated_at` descending with `id` as the tiebreaker. Pass
        `after` (the previous response's `list_metadata.after`) for the next
        page, `before` for the previous page. They are mutually exclusive; the
        400 cleanly tells the caller which to drop.
      operationId: list_blocks
      parameters:
        - in: query
          name: workflow_id
          required: true
          schema:
            type: string
            title: Workflow Id
        - in: query
          name: before
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Block id cursor: return the page before this id (mutually
              exclusive with `after`).
            title: Before
          required: false
          description: >-
            Block id cursor: return the page before this id (mutually exclusive
            with `after`).
        - in: query
          name: after
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Block id cursor: return the page after this id (mutually exclusive
              with `before`).
            title: After
          required: false
          description: >-
            Block 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 blocks to return per page (1-200).
            default: 100
            title: Limit
          required: false
          description: Maximum number of blocks to return per page (1-200).
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowBlockList'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    WorkflowBlockList:
      description: >-
        A page of `WorkflowBlock` 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/WorkflowBlock'
          type: array
          title: Data
        list_metadata:
          $ref: '#/components/schemas/ListMetadata'
      type: object
      required:
        - data
        - list_metadata
      title: WorkflowBlockList
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    WorkflowBlock:
      properties:
        id:
          type: string
          title: Id
        workflow_id:
          type: string
          title: Workflow Id
          description: Foreign key to workflow
        type:
          type: string
          enum:
            - start_document
            - start_json
            - note
            - parse
            - edit
            - extract
            - split
            - classifier
            - conditional
            - api_call
            - function
            - while_loop
            - for_each
            - merge_dicts
            - while_loop_sentinel_start
            - while_loop_sentinel_end
            - for_each_sentinel_start
            - for_each_sentinel_end
          title: Type
          description: Block type (extract, parse, classifier, etc.)
        label:
          type: string
          title: Label
          description: Display label for the block
          default: ''
        position_x:
          type: number
          title: Position X
          description: X position on canvas
          default: 0
        position_y:
          type: number
          title: Position Y
          description: Y position on canvas
          default: 0
        width:
          anyOf:
            - type: number
            - type: 'null'
          title: Width
          description: Block width for resizable blocks
        height:
          anyOf:
            - type: number
            - type: 'null'
          title: Height
          description: Block height for resizable blocks
        config:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Config
          description: Block-specific configuration
        parent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Parent Id
          description: ID of parent container (while_loop, for_each)
        declarative_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Declarative Path
          description: Canonical declarative block path used to reconcile imported specs.
        declarative_source_block_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Declarative Source Block Id
          description: Authored declarative block id before import-time id regeneration.
        updated_at:
          type: string
          format: date-time
          title: Updated At
        resolved_schemas:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Resolved Schemas
          description: Schemas resolved for this block from the workflow graph.
      type: object
      required:
        - id
        - type
        - updated_at
        - workflow_id
      title: WorkflowBlock
      description: Public live workflow block 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

````