# End an action lock — API reference

> Ends the run behind a lock and keeps the lock for the handler's cooldown.

Source: https://upfour.io/docs/api/runner/end-an-action-lock

[Developers](https://upfour.io/docs/api.md)/[Event stream (up4 CLI)](https://upfour.io/docs/api/runner.md)

Ends the run behind a lock and keeps the lock for the handler's cooldown.

POST https://app.upfour.io/v1/runner/locks/{token}/finish

scope runner.report.write stable [Idempotency-Key supported](https://upfour.io/docs/api/idempotency.md) returns 200

## Parameters

| Field | Type | Description |
| --- | --- | --- |
| `token` required | uuid | path parameter · The token POST /v1/runner/locks returned with the lock. |
| `X-Up4-Runner-ID` required | uuid | header parameter · Stable UUID of the runner. |
| `X-Up4-Runner-Name` required | string length 1–64 | header parameter · Printable runner name. |

## Body

`application/json` optional 1 field

hold_msinteger (required)

How long the lock stays after the run: the handler cooldown, so no machine repeats the action meanwhile. 0 frees it at once.

## Returns

A successful request returns `200` with application/json.

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | RunnerLockFinishView | |
| RunnerLockFinishView · 1 fields FieldTypeDescription `expires_at` string (date-time) When the lock frees. | | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 404 | [not_found](https://upfour.io/docs/api/errors#code-not_found) | The requested resource does not exist or is outside the caller's scope. |
| 503 | [service_unavailable](https://upfour.io/docs/api/errors#code-service_unavailable) | The service or a required dependency is temporarily unavailable. |
| 400 | documented response | A hold_ms below zero or above one day. |
| 404 | documented response | The token is unknown, belongs to another machine or key, or its run was already closed as unknown. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousTake an action lock](https://upfour.io/docs/api/runner/take-an-action-lock.md) [NextReport a handler run](https://upfour.io/docs/api/runner/report-a-handler-run.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/runner/locks/00000000-0000-4000-8000-000000000001/finish" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "hold_ms": 300000
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/runner/locks/00000000-0000-4000-8000-000000000001/finish", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    hold_ms: 300000,
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/runner/locks/00000000-0000-4000-8000-000000000001/finish",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "hold_ms": 300000,
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "hold_ms": 300000
}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/runner/locks/00000000-0000-4000-8000-000000000001/finish", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "hold_ms": 300000
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/runner/locks/00000000-0000-4000-8000-000000000001/finish");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 200

```json
{
  "data": {
    "expires_at": "2026-10-27T09:05:00Z"
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 404

```json
{
  "error": {
    "code": "not_found",
    "message": "The requested resource does not exist or is outside the caller's scope.",
    "request_id": "req_…"
  }
}
```

### 503

```json
{
  "error": {
    "code": "service_unavailable",
    "message": "The service or a required dependency is temporarily unavailable.",
    "request_id": "req_…"
  }
}
```
