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

# Validate Block Config

> Validate an assembled block config without mutating the workflow draft.

Dry-run an assembled block config against the target block without mutating the
workflow draft.

Use this before pushing a locally edited block config bundle when you want the
backend to apply the same validation policy used by block updates.

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

  client = Retab()

  result = client.workflows.blocks.create_block_validate_config(
      "extract-1",
      config={
          "model": "retab-small",
          "json_schema": {"type": "object", "properties": {}},
      },
      config_mode="replace",
  )
  print(result)
  ```

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

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

  const result = await client.workflows.blocks.create_block_validate_config(
    "extract-1",
    {
      model: "retab-small",
      json_schema: { type: "object", properties: {} },
    },
    "replace",
  );
  console.log(result);
  ```

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

  import (
  	"context"
  	"fmt"
  	"log"

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

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

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

  	mode := retab.UpdateWorkflowBlockRequestConfigModeReplace
  	result, err := client.Workflows.Blocks.CreateBlockValidateConfig(ctx, "extract-1", &retab.WorkflowBlocksCreateBlockValidateConfigParams{
  		Config: map[string]interface{}{
  			"model":       "retab-small",
  			"json_schema": map[string]interface{}{"type": "object", "properties": map[string]interface{}{}},
  		},
  		ConfigMode: &mode,
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(*result)
  }
  ```

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

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

  result = client.workflows.blocks.create_block_validate_config(
    block_id: 'extract-1',
    config: {
      'model' => 'retab-small',
      'json_schema' => { 'type' => 'object', 'properties' => {} },
    },
    config_mode: 'replace',
  )
  puts result
  ```

  ```rust Rust theme={null}
  use std::collections::HashMap;

  use retab::models::ValidateWorkflowBlockConfigRequest;
  use retab::resources::workflow_blocks::CreateBlockValidateConfigParams;
  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 mut config = HashMap::new();
      config.insert("model".to_string(), serde_json::json!("retab-small"));
      config.insert(
          "json_schema".to_string(),
          serde_json::json!({ "type": "object", "properties": {} }),
      );

      let result = client
          .workflows()
          .blocks()
          .create_block_validate_config(
              "extract-1",
              CreateBlockValidateConfigParams::new(ValidateWorkflowBlockConfigRequest::new(config)),
          )
          .await?;
      println!("{:?}", result);
      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()->createBlockValidateConfig(
      blockId: 'extract-1',
      config: [
          'model' => 'retab-small',
          'json_schema' => ['type' => 'object', 'properties' => (object) []],
      ],
  );
  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.CreateBlockValidateConfigAsync(
      "extract-1",
      new WorkflowBlocksCreateBlockValidateConfigOptions
      {
          Config = new Dictionary<string, object>
          {
              ["model"] = "retab-small",
              ["json_schema"] = new Dictionary<string, object>
              {
                  ["type"] = "object",
                  ["properties"] = new Dictionary<string, object>(),
              },
          },
          ConfigMode = UpdateWorkflowBlockRequestConfigMode.Replace,
      });
  Console.WriteLine(result);
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;
  import com.retab.types.ValidateWorkflowBlockConfigRequestConfigMode;
  import java.util.LinkedHashMap;
  import java.util.Map;

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

      Map<String, Object> config = new LinkedHashMap<>();
      config.put("model", "retab-small");
      config.put("json_schema", Map.of("type", "object", "properties", Map.of()));

      var result = client.workflows().blocks().createBlockValidateConfig(
          "extract-1",
          null,
          config,
          ValidateWorkflowBlockConfigRequestConfigMode.REPLACE);
      System.out.println(result);
    }
  }
  ```

  ```bash cURL theme={null}
  curl --request POST \
    'https://api.retab.com/v1/workflows/blocks/extract-1/validate-config' \
    --header "Authorization: Bearer $RETAB_API_KEY" \
    --header 'Content-Type: application/json' \
    --data '{
      "config": {
        "model": "retab-small",
        "json_schema": {"type": "object", "properties": {}}
      },
      "config_mode": "replace"
    }'
  ```
</RequestExample>


## OpenAPI

````yaml POST /v1/workflows/blocks/{block_id}/validate-config
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/workflows/blocks/{block_id}/validate-config:
    post:
      tags:
        - Workflows
        - Workflow Blocks
      summary: Validate Block Config
      description: Validate an assembled block config without mutating the workflow draft.
      operationId: validate_block_config
      parameters:
        - in: path
          name: block_id
          required: true
          schema:
            type: string
            title: Block Id
        - in: query
          name: workflow_id
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Workflow ID to disambiguate legacy duplicate block IDs. Omit for
              normal server-generated block IDs.
            title: Workflow Id
          required: false
          description: >-
            Workflow ID to disambiguate legacy duplicate block IDs. Omit for
            normal server-generated block IDs.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ValidateWorkflowBlockConfigRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidateWorkflowBlockConfigResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ValidateWorkflowBlockConfigRequest:
      properties:
        config:
          additionalProperties: true
          type: object
          title: Config
          description: Assembled block config to validate.
        config_mode:
          anyOf:
            - type: string
              enum:
                - merge
                - replace
            - type: 'null'
          title: Config Mode
          description: >-
            How to apply the config before validation. 'replace' validates the
            config as the full block config; 'merge' validates the result of
            merging it into the existing block config.
          default: replace
      type: object
      required:
        - config
      title: ValidateWorkflowBlockConfigRequest
      description: Dry-run validation for an assembled workflow block config.
    ValidateWorkflowBlockConfigResponse:
      properties:
        ok:
          type: boolean
          title: Ok
          default: true
        workflow_id:
          type: string
          title: Workflow Id
        block_id:
          type: string
          title: Block Id
        block_type:
          type: string
          title: Block Type
        config_hash:
          type: string
          title: Config Hash
      type: object
      required:
        - block_id
        - block_type
        - config_hash
        - workflow_id
      title: ValidateWorkflowBlockConfigResponse
    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

````