---
title: "Lock"
description: "Hold a key around a nested body so overlapping runs wait or skip."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/utility/lock"
---
# Lock

> Hold a key around a nested body so overlapping runs wait or skip.

<block-meta block="Yes" channels="Any" folder="basic/utility" group="Utility" groupTo="/build/workflows/blocks/utility" icon="i-lucide-key-round" pipe="Value" scope="Any" tool="No" type="utl.lock">



</block-meta>

**Lock** holds a key for one nested body, then releases it. Use it when several steps must not overlap for the same record — read a row, call an API, then update. A single [Table Update](https://docs.vettero.com/build/workflows/blocks/table/update) **Only if** filter is enough when the race is one write.

**Body** is a **new callback scope**. Connect it to a [Lambda](https://docs.vettero.com/build/workflows/blocks/module/lambda) block. The lock stays held while that body runs, including when the body fails, and is released before the run continues or fails. A crashed run releases the key when **Hold** expires.

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Key
      </strong>
    </td>
    
    <td>
      Shared name, usually a row id. Runs that use the same key in the same workspace share one lock
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        When busy
      </strong>
    </td>
    
    <td>
      <strong>
        Skip
      </strong>
      
       — do not run the body. <strong>
        Wait
      </strong>
      
       — poll until the key is free or <strong>
        Wait
      </strong>
      
       seconds elapse
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Wait (seconds)
      </strong>
    </td>
    
    <td>
      Shown for Wait. How long to poll (0–300)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Hold (seconds)
      </strong>
    </td>
    
    <td>
      How long the key stays taken if the run stops without releasing (1–300). Refreshed while the body runs
    </td>
  </tr>
</tbody>
</table>

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after the lock is released, or immediately when the body does not run
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Body
      </strong>
    </td>
    
    <td>
      <strong>
        New callback scope
      </strong>
      
       — runs only when the lock is acquired. Connect to <a href="https://docs.vettero.com/build/workflows/blocks/module/lambda">
        Lambda
      </a>
    </td>
  </tr>
</tbody>
</table>

## Pipe schema

The next block on **Out** reads this on the data pipe (`pipe.value`). The value is an object:

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        acquired
      </code>
    </td>
    
    <td>
      boolean
    </td>
    
    <td>
      <strong>
        False
      </strong>
      
       when the key was busy and the body did not run. The run does not fail
    </td>
  </tr>
</tbody>
</table>

## Use case

- Keep two event runs from updating the same order: key the lock with the order id, **Wait**, and do the read and write inside **Body**.
- **Skip** when a second run should leave the first one to finish, then branch on `acquired`.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
