Documentation

API Reference

haas-lab exposes a REST API for programmatic firmware testing. Every request carries a Personal Access Token.

Your token

Sign in and you come back here to create a token in one click; every example below then uses it.

curl

Authentication

Every request carries a Personal Access Token (PAT) in the Authorization header. Create one at the top of this page and every example here uses it; the curl examples read it from PAT.

bash
# Once per terminal:
export PAT=pat_...

# Every request then sends the header
#   Authorization: Bearer $PAT

Run firmware on a board

Upload a .bin (max 4 MB) and it is queued for the next free board matching the profile. The response carries the job id, and while the job is QUEUED it also carries queuePosition, so you know how many are ahead of you without polling for it.

bash
curl -X POST \
  -H "Authorization: Bearer $PAT" \
  -F firmware=@blink.bin \
  -F profile_key=esp32c3-mini-v1 \
  https://haas-lab.com/api/v1/jobs

List your jobs

Returns your jobs newest first, 20 to a page. The response's meta carries page, pageSize, total and totalPages; there is no parameter that changes the page size.

bash
curl \
  -H "Authorization: Bearer $PAT" \
  "https://haas-lab.com/api/v1/jobs?page=1"

Get job status

Poll for job status. Status progresses: QUEUED → FLASHING → RUNNING → COMPLETED.

bash
curl \
  -H "Authorization: Bearer $PAT" \
  https://haas-lab.com/api/v1/jobs/<job-id>

Stream live serial output

Connect to the SSE stream for a running job. Each event contains one line of serial output.

bash
curl -N \
  -H "Authorization: Bearer $PAT" \
  -H "Accept: text/event-stream" \
  https://haas-lab.com/api/v1/jobs/<job-id>/stream

Send input to a running job

Write to the board's serial console while the job is FLASHING or RUNNING; input to a queued job is refused, not held. Send text, which goes as its UTF-8 bytes, or bytes, base64 of exactly what to send. The bytes reach the board's port unchanged, but the console on the board may alter them before the program reads them: ESP-IDF's stdin turns a carriage return (0x0D) into a newline, and MicroPython takes 0x03 as Ctrl-C. So encode binary (base64 or hex) and decode it on the board. A program submitted as C source reads it from stdin, which waits for input as in standard C; set O_NONBLOCK to poll. A prebuilt image must install ESP-IDF's USB-serial-JTAG driver itself to read it. Input sent while the board is still being flashed, before the bench opens its port, is dropped, so send once the program is running. The board holds 4,096 bytes the program has not read yet and drops the rest, so send larger data in pieces and have the program acknowledge each. At most 4,096 bytes a send; the reply says how many were accepted. The token needs the submit scope.

bash
curl -X POST \
  -H "Authorization: Bearer $PAT" \
  -H "Content-Type: application/json" \
  -d '{"text":"print(1)\r\n"}' \
  https://haas-lab.com/api/jobs/$JOB_ID/input

# Raw bytes, base64 encoded: a file of at most 4,096 bytes
# (split -b 4096 a larger one and send the pieces in order)
curl -X POST \
  -H "Authorization: Bearer $PAT" \
  -H "Content-Type: application/json" \
  -d "{\"bytes\":\"$(base64 -w0 piece.bin)\"}" \
  https://haas-lab.com/api/jobs/$JOB_ID/input

Get archived serial log

After a job completes, retrieve the full serial log as plain text.

bash
curl \
  -H "Authorization: Bearer $PAT" \
  https://haas-lab.com/api/v1/jobs/<job-id>/serial

Roadmap: validate a restricted module

Not a way to run anything yet. This checks a .wasm module (max 128 KiB) against the sandbox policy and returns the verdict; queueing a module on hardware opens once the trusted runtime is provisioned. Native jobs above, a .bin or C source through submit_source, are the way to reach a board today.

bash
curl -X POST \
  -H "Authorization: Bearer $PAT" \
  -F module=@app.wasm \
  https://haas-lab.com/api/v1/sandbox/validate

Manage API tokens

Create, list, and revoke Personal Access Tokens.

bash
# Create a new token
curl -X POST \
  -H "Authorization: Bearer $PAT" \
  -H "Content-Type: application/json" \
  -d '{"name":"ci-token"}' \
  https://haas-lab.com/api/v1/tokens

# List tokens (plaintext never returned after creation)
curl -H "Authorization: Bearer $PAT" https://haas-lab.com/api/v1/tokens

# Revoke a token
curl -X DELETE \
  -H "Authorization: Bearer $PAT" \
  https://haas-lab.com/api/v1/tokens/<token-id>
Questions? Sign in and use the feedback button on any page.