LOCALHOST
All pages
API reference

Git deploys

Sites that build from a repository: connect a source, start builds, follow logs, roll back, previews.

Every call needs Authorization: Bearer lh_… unless marked No key needed; the example uses $API for https://api.localhost.co.zw and $LH_API_KEY for your key. A * marks a required field.

#

List Builds

sites:read

GET /builds/

Parameters

NameTypeNotes
site * query string
limit query integer default 20

Responses

  • 200 list[BuildOut]
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/builds/?site=<site>" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Create Build

sites:write

POST /builds/

Request body BuildIn

NameTypeNotes
site * string
ref string default ""
tag string default ""

Responses

  • 200 BuildOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/builds/" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "site": "<site>"
  }'
#

List Previews

sites:read

GET /builds/previews

Parameters

NameTypeNotes
site * query string

Responses

  • 200 list[PreviewOut]
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/builds/previews?site=<site>" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Scan Folder

sites:read

POST /builds/scan

What `lh init` sends: a folder's file names and its build files. Runs the same read-only scan a build does
(nothing in it is executed) and answers with the plan and an lh.toml that writes it down.

Request body ScanIn

NameTypeNotes
files * object of string

Responses

  • 200 ScanOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/builds/scan" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "files": {}
  }'
#

Create Git Site

sites:write

POST /builds/sites

Create a site that deploys from a repository; returns its first build.

Request body GitSiteIn

NameTypeNotes
slug * string
repo * string
name string default ""
size string default S
branch string default main
root_dir string default ""
dockerfile_path string default ""
access_token string default ""

Responses

  • 200 BuildOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/builds/sites" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "slug": "<slug>",
    "repo": "<repo>"
  }'
#

Get Build

sites:read

GET /builds/{build_id}

The build with its log from character `since`; pass log_next back to follow it.

Parameters

NameTypeNotes
build_id * in path uuid
since query integer default 0

Responses

  • 200 BuildLogOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/builds/<build_id>" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Get Source

sites:read

GET /builds/sources/{slug}

Parameters

NameTypeNotes
slug * in path string

Responses

  • 200 SourceOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/builds/sources/<slug>" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Put Source

sites:write

PUT /builds/sources/{slug}

Connect (or change) the site's repository. Connecting for the first time starts a build.

Parameters

NameTypeNotes
slug * in path string

Request body SourceIn

NameTypeNotes
repo * string
branch string default main
root_dir string default ""
dockerfile_path string default ""
access_token string default ""
auto_deploy boolean default true
trigger string default branch
tag_pattern string default v*
previews boolean | null

Responses

  • 200 SourceOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X PUT "$API/builds/sources/<slug>" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "repo": "<repo>"
  }'
#

Delete Source

sites:write

DELETE /builds/sources/{slug}

Parameters

NameTypeNotes
slug * in path string

Responses

  • 200 OK
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X DELETE "$API/builds/sources/<slug>" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Cancel Build

sites:write

POST /builds/{build_id}/cancel

Parameters

NameTypeNotes
build_id * in path uuid

Responses

  • 200 BuildOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/builds/<build_id>/cancel" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Rollback

sites:write

POST /builds/{build_id}/rollback

Put this build's version back live; returns the new rollback build.

Parameters

NameTypeNotes
build_id * in path uuid

Responses

  • 200 BuildOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/builds/<build_id>/rollback" \
  -H "Authorization: Bearer $LH_API_KEY"

Shapes

The objects these endpoints send and receive.

BuildIn

NameTypeNotes
site * string
ref string default ""
tag string default ""

BuildLogOut

NameTypeNotes
id * string
site * string
number * integer
status * string
ref * string
branch * string
sha * string
commit_message * string
triggered_by * string
image * string
error * string
created_at * string
finished_at * string | null
rollback_of integer | null
tag string default ""
pr_number integer | null
findings list[object] default []
log * string
log_next * integer
plan object | null

BuildOut

NameTypeNotes
id * string
site * string
number * integer
status * string
ref * string
branch * string
sha * string
commit_message * string
triggered_by * string
image * string
error * string
created_at * string
finished_at * string | null
rollback_of integer | null
tag string default ""
pr_number integer | null
findings list[object] default []

GitSiteIn

NameTypeNotes
slug * string
repo * string
name string default ""
size string default S
branch string default main
root_dir string default ""
dockerfile_path string default ""
access_token string default ""

PreviewOut

NameTypeNotes
site * string
pr_number * integer
branch * string
title * string
url * string
status string | null

ScanIn

NameTypeNotes
files * object of string

ScanOut

NameTypeNotes
plan * object
toml * string
problems list[object] default []

SourceIn

NameTypeNotes
repo * string
branch string default main
root_dir string default ""
dockerfile_path string default ""
access_token string default ""
auto_deploy boolean default true
trigger string default branch
tag_pattern string default v*
previews boolean | null

SourceOut

NameTypeNotes
site * string
provider * string
repo_url * string
branch * string
root_dir * string
dockerfile_path * string
auto_deploy * boolean
trigger * string
tag_pattern * string
previews * boolean
webhook_url * string