Introduction
Floor Plan API runs a U-Net style wall-segmentation model on the file you upload and returns everything it found in one JSON response: the wall mask as a PNG (base64, in wall_mask_png), the doors and windows as boxes, and the rooms as polygons plus a room mask. In the wall mask, foreground pixels (255) mark walls; background pixels (0) mark everything else. Every coordinate and both masks share one pixel grid. For a raster input that grid is the image's own resolution, so everything lines up pixel-for-pixel with the image you sent. For a PDF you name the page (page, 1-based, default 1); it is rasterised at 200 DPI (longest edge capped at 8192 px) and the grid is that raster; its size comes back as width / height in the body. See Response body for every field.
Two ways to call the API, both fully supported and documented end-to-end:
- Python library —
pip install floorplan-api. Typed sync and asyncio clients, automatic retries, image and PDF input. See Python library. - REST API — plain HTTP from any language or HTTP client (curl, Node fetch, Go, Ruby, …). See REST API.
Quickstart
1. Get an API key
Create an account, then generate a key from the dashboard. Test keys (fp_test_…) use the same model but aren't billed.
2. Make your first request
pip install floorplan-api
# in Python:
from floorplan_api import Client
client = Client(api_key="fp_test_...")
result = client.extract("plan.png")
with open("walls.png", "wb") as fh:
fh.write(result.wall_mask)
print(f"{len(result.doors)} doors, {len(result.windows)} windows, {len(result.rooms)} rooms")3. Inspect the response
On success the response is one JSON object with Content-Type: application/json. It carries the wall mask, the doors and windows, and the rooms. Shortened here; every field is described in Response body:
HTTP/1.1 200 OK
Content-Type: application/json
X-Job-Id: job_abc123
X-Request-Id: req_def456
{
"job_id": "job_abc123",
"width": 1024,
"height": 768,
"page": 1,
"dpi": null,
"min_room_score": 0.9,
"counts": { "door": 12, "window": 11, "room": 11 },
"detections": [ ... ], // doors and windows
"rooms": [ ... ], // room polygons
"wall_mask_png": "iVBORw0K...", // base64 PNG
"room_mask_png": "iVBORw0K..." // base64 PNG, or null
}Response body
POST /v1/extract, POST /v1/analyze (synchronous) and GET /v1/jobs/{job_id}/result all answer 200 with the same JSON object. Every key is always present. All coordinates are pixels, origin at the top-left corner, on the grid given by width / height; both masks use that same grid, so everything lines up with the image you sent (or with the rendered PDF page).
{
"job_id": "job_abc123",
"width": 2339,
"height": 1486,
"page": 2,
"dpi": 200.0,
"min_room_score": 0.9,
"counts": { "door": 12, "window": 11, "room": 11 },
"detections": [
{
"class": "door",
"confidence": 0.9312,
"polygon": [[412.0, 655.5], [468.0, 655.5], [468.0, 671.5], [412.0, 671.5]],
"center": [440.0, 663.5],
"size": [56.0, 16.0]
},
{
"class": "window",
"confidence": 0.8874,
"polygon": [[120.0, 210.0], [132.0, 210.0], [132.0, 318.0], [120.0, 318.0]],
"center": [126.0, 264.0],
"size": [12.0, 108.0]
}
// ... 21 more
],
"rooms": [
{
"id": 1,
"score": 1.0,
"area": 413312.0,
"polygon": [
[[120, 96], [884, 96], [884, 640], [120, 640]], // outer ring
[[402, 300], [450, 300], [450, 348], [402, 348]] // hole ring
]
}
// ... 10 more
],
"wall_mask_png": "iVBORw0KGgoAAAANSUhEUgAA...", // base64 PNG
"room_mask_png": "iVBORw0KGgoAAAANSUhEUgAA..." // base64 PNG, or null
}| Field | Type | Meaning |
|---|---|---|
| job_id | string | The job created for the request. Also sent as X-Job-Id. |
| width, height | integer | Size in pixels of the grid every coordinate and both masks use: the input image's own size, or the rendered page size for a PDF. |
| page | integer | The 1-based PDF page that was processed; 1 for images. |
| dpi | number | null | Resolution the PDF page was rendered at; null for image input. |
| min_room_score | number | null | The room-score floor the job ran with: the request's min_room_score, else the default 0.9. May be null. |
| counts | object | How many doors, windows and rooms were found, under the keys door, window and room. |
| detections | array | The doors and windows, one object each. Empty if none were found. |
| detections[].class | string | "door" or "window". |
| detections[].confidence | number | Confidence of the detection, from 0 to 1. |
| detections[].polygon | [[x, y] × 4] | The four corners of the box around the opening. The box may be rotated, so use the corners rather than assuming it is axis-aligned. |
| detections[].center, .size | [cx, cy], [w, h] | The same box described by its centre point and its width and height along its own axes. |
| rooms | array | The rooms, one object each. Empty if none were found. |
| rooms[].id | integer | Room number, starting at 1 for the largest room. Pixels of this room hold this value in the room mask. |
| rooms[].score | number | 1.0 for a fully enclosed room; lower values (0.9, 0.8, 0.7, 0.5) for rooms the service had to close itself. The request's min_room_score chooses how far down to go: rooms scoring below it are not returned. |
| rooms[].area | number | Room area in square pixels. |
| rooms[].polygon | [ring, …] | The room outline as a list of rings: the first is the outer ring, any further rings are holes inside it (a column, an enclosed core). Each ring is a list of [x, y] points without a closing point. |
| wall_mask_png | string (base64) | The wall mask, a PNG encoded as base64: 8-bit, single channel, 255 = wall, 0 = everything else. See Mask output. |
| room_mask_png | string (base64) | null | The room mask, a PNG encoded as base64 in which each pixel holds the id of the room it belongs to (0 = no room). 8-bit, or 16-bit when there are 255 or more rooms. null if no rooms output exists. |
The polygons and the room mask describe the same rooms in two forms. Use rooms[].polygon to draw or export outlines, and the room mask to answer per-pixel questions: decode it, read the value at (x, y), and that number is the id of the room under that pixel, or 0 if there is none.
The Python library decodes all of this into a Result object (see Types reference); Working with the result has recipes for rooms, doors and windows, and both masks.
Mask output
Every successful response carries two PNG masks, base64 encoded inside the JSON body: the wall mask in wall_mask_png and the room mask in room_mask_png. Knowing exactly what's in them makes the rest of the docs simpler. The wall mask first:
| Property | Value |
|---|---|
| format | PNG |
| channels | 1 (single-channel grayscale) |
| bit depth | 8 |
| pixel values | 0 = background; 255 = wall. No greys — the probability map is thresholded at 0.5 and nothing else is done to it: no morphology, no hole filling, no component filtering. Walls follow the carved convention: door and window openings are not wall, and walls are as thick as the source linework. |
| resolution | Identical to the input image, so the mask aligns pixel-for-pixel with it. For a PDF, identical to the rasterised page (200 DPI, longest edge ≤ 8192 px); read it from width / height in the response body. |
| colour space | None — single-channel grayscale, no embedded ICC profile. |
The room mask (room_mask_png) is a label image on the same pixel grid:
| Property | Value |
|---|---|
| format | PNG, 1 channel (grayscale) |
| bit depth | 8, or 16 when there are 255 or more rooms |
| pixel values | The id of the room the pixel belongs to, matching rooms[].id; 0 = no room. Viewed as an image it looks almost black, because the values are small numbers, not colours. |
| resolution | Same as the wall mask: width × height. |
| availability | null in the response if no rooms output exists. |
See Working with the result for Python recipes that overlay the wall mask on the original image, count wall pixels, convert it to other formats, or look rooms up in the room mask.
What happens to your file
Images and PDFs leave your machine differently. Be aware of the difference before you rely on either.
| You give | What is uploaded |
|---|---|
| PNG / JPEG / WEBP | The file, byte for byte. Neither the Python client nor a raw HTTP call decodes, resizes or re-encodes an image. |
| PDF via the Python client | A new single-page PDF holding only the page you asked for. The client builds it locally with pypdf: the page object is copied with its content stream, resources (fonts, embedded images) and annotations; nothing is rasterised on your side. The other pages, document metadata, bookmarks, attachments and form definitions are never sent. Page errors are raised before any request. |
| PDF via raw HTTP | Whatever you send. Upload the whole document and pass page; the worker renders that page of the stored file. The full document then sits in storage. |
| upload_key | Nothing; the object is already stored. Pass page for a multi-page PDF you stored yourself. |
The API server never touches pixels either: it checks the declared type, size and page, stores the bytes as uploaded, and the GPU worker decodes them once, like this:
- Rasters (PNG, JPEG, WEBP) are decoded with OpenCV in colour mode. Alpha is dropped without compositing, so flatten transparent PNGs onto white before uploading; grayscale is expanded to three channels; 16-bit depth becomes 8-bit; JPEG EXIF orientation is applied, so the result aligns with the image as displayed; ICC profiles are ignored. The masks and coordinates are on the decoded image's own pixel grid.
- Very large rasters (longer edge above 8192 px) are processed downscaled to that bound and the result is scaled back to the input size: still pixel-aligned, with less detail.
- PDF pages are rendered at 200 DPI onto white (transparent regions composite onto white), reduced so the longer edge is at most 8192 px. A 24 × 36 in sheet becomes 4800 × 7200 px. Everything on the page is rendered: linework, hatching, text, dimensions. The masks and all coordinates have the rendered size (
width/heightin the response body;dpiis the resolution actually used). To map them back to PDF coordinates usepx = pt × width_px / page_width_pt; the Python client does this for you viaresult.wall_mask.pdf_scale. - Inference is a two-stage U-Net style process. No test-time augmentation, no ensembling.
- Failures at this stage (undecodable bytes, a password-protected PDF, a page past the end) fail the job with
invalid_request_error; the synchronous endpoints answer400with that error and thejob_id. They are not retried: the same file would fail again.
Authentication
Every request must carry an API key in the Authorization header:
Authorization: Bearer fp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxfp_live_. Charged against your account, write usage records.fp_test_. Run the same model, never billed, never logged as usage.Python library
The official client — typed, with retries built in — in a synchronous flavour (Client, on requests) and an asyncio flavour (AsyncClient, on httpx). Works on Python 3.9+.
Install
pip install floorplan-api # Client (requests)
pip install "floorplan-api[async]" # + AsyncClient (httpx)Runtime dependencies are requests and pypdf (pure Python, used to cut the requested page out of a PDF before upload); the async extra adds httpx. PIL / OpenCV / NumPy are optional and only needed if you want to process the returned masks in Python.
Initialise the client
from floorplan_api import Client
client = Client(
api_key="fp_live_...",
timeout=60.0,
max_retries=3,
retry_backoff=0.5,
)extract()
Synchronous. Accepts a path, raw bytes, or a binary file-like object holding a PNG, JPEG, WEBP or PDF. Returns a Result: the wall mask (wall_mask, a MaskBytes, i.e. the PNG as bytes), the room mask (room_mask), the doors and windows (detections, doors, windows) and the rooms, with width, height, job_id, request_id and mode attached, plus page_size_pt and wall_mask.pdf_scale for a PDF.
from pathlib import Path
# any of these works:
result = client.extract("plans/floor1.png") # path
result = client.extract(Path("plans/set.pdf"), page=3) # PDF: page 3 (1-based; default 1)
result = client.extract(image_bytes) # raw bytes (format is sniffed)
with open("plan.jpg", "rb") as fp:
result = client.extract(fp) # file-like
result.wall_mask # MaskBytes: the PNG wall mask (it is still bytes)
result.room_mask # bytes | None: the PNG room mask (pixel value = room id)
result.doors, result.windows # lists of Detection (result.detections holds both)
result.rooms # list of Room
result.counts # {"door": 12, "window": 11, "room": 11}
result.width, result.height # the pixel grid of both masks and every coordinate
result.job_id # also sent as X-Job-Id
open("walls.png", "wb").write(result.wall_mask)
# Also return rooms the service had to close itself, down to score 0.5
# (default 0.9; allowed 0 to 0.9):
result = client.extract("plan.png", min_room_score=0.5)
# PDF input: map the result back to the page (the client measured it before upload)
result = client.extract("plans/set.pdf", page=3)
result.page_size_pt # (1728.0, 2592.0) points, /Rotate honoured
result.wall_mask.pdf_scale # px per PDF pt -> x_px = x_pt * result.wall_mask.pdf_scale
result.wall_mask.pdf_dpi # the DPI actually rendered (200, or less past the 8192 px cap)
# Per-call timeout override:
result = client.extract("plan.png", timeout=120.0)The client identifies the format from the file's leading bytes (PNG, JPEG, WEBP and PDF signatures), falling back to the extension, and raises InvalidRequestError for anything else before making a request. An image is uploaded byte for byte. A PDF is not: the client rewrites it locally into a single-page PDF holding only the requested page (see What happens to your file), so a 40-page drawing set costs one page of upload and the server never holds the rest; a page that does not exist (or a password-protected file) is rejected before any request. page other than 1 is an error for raster input. Max inline upload size 10 MB. The fields of the returned Result mirror the JSON response (see Response body); wall_mask is a single-channel PNG (see Mask output).
analyze()
Currently returns the same Result as extract(). Costs 2 credits per call. Kept distinct so future capabilities can attach to analyze without changing extract's contract.
result = client.analyze("plan.png")Large files (presigned uploads)
The inline extract() / analyze() path streams the bytes through the API server, which caps the request at 10 MB. For larger files, the client uploads directly to object storage via a presigned URL the API hands back, then submits the job by storage key — the API server never holds the bytes.
upload_then_extract() is the one-shot helper. Files smaller than threshold_bytes (default 10 MiB) go through the inline path; larger files switch to the presigned flow automatically.
# Same return value as extract() — a Result.
# For a PDF the size check runs on the selected page, not the whole file.
result = client.upload_then_extract("big_floor_plan.pdf", page=2)
# Force the presigned path even for small files (e.g. CI smoke tests):
result = client.upload_then_extract("plan.png", threshold_bytes=0)If you need finer control — say, you already have the bytes in S3 and just want to extract — use the two-step API:
# 1. Reserve a slot. Returns {upload_url, key, expires_at, content_type}.
# content_type: image/png | image/jpeg | image/webp | application/pdf
slot = client.create_upload(content_type="image/png")
# 2. PUT the bytes (any HTTP client; we use the built-in session here).
import requests
with open("plan.png", "rb") as fp:
res = requests.put(
slot["upload_url"],
data=fp,
headers={"Content-Type": slot["content_type"]},
)
res.raise_for_status()
# 3. Or, with the helper that wraps create_upload + PUT. For a PDF, page=
# cuts that page out first, so the stored object is a single-page PDF.
upload_key = client.upload("plan.png")
# 4. Run extract by storage key (no bytes flow through the API server).
# analyze() and analyze_async() take upload_key= the same way. If the
# stored object is a multi-page PDF you uploaded yourself, add page=N and
# the server renders that page.
result = client.extract(upload_key=upload_key)AsyncClient (asyncio)
AsyncClient has the same methods as Client, every one a coroutine, on top of httpx. Install with pip install "floorplan-api[async]". Use it as an async context manager so the connection pool is closed, or pass your own httpx.AsyncClient as client= (proxies, HTTP/2) and it is left open.
import asyncio
from floorplan_api import AsyncClient
async def main() -> None:
async with AsyncClient() as client: # FLOORPLAN_API_KEY from env
results = await asyncio.gather(
client.extract("plans/a.pdf", page=2),
client.extract("plans/b.png"),
client.upload_then_extract("plans/huge.pdf"),
)
for result in results:
print(result.job_id, result.size, result.counts)
asyncio.run(main())Retries, error classes, Result and the job helpers below behave identically in both clients; only close() becomes await aclose().
Background jobs
For batches or longer-running analyses, submit a job and poll for completion, then fetch the result. Three calls cover the full lifecycle (available on both clients):
| Step | Method | Returns |
|---|---|---|
| 1. Submit | analyze_async(image) | Job (status="queued") |
| 2. Wait or poll | wait_for_job(job.id) / get_job(id) | Job (terminal) |
| 3. Fetch | get_result(job.id) | Result |
Complete walkthrough:
from floorplan_api import Client, FloorPlanError
with Client() as client:
job = client.analyze_async("plan.png")
print(f"Submitted {job.id} (status={job.status})")
final = client.wait_for_job(
job.id,
poll_interval=2.0, # seconds between polls
timeout=300.0, # raise TimeoutError after 5 min
)
print(f"Final status: {final.status}")
if final.status != "completed" or final.result is None:
raise FloorPlanError(final.error["message"] if final.error else "no result")
print(f"Result is on a {final.result.width}x{final.result.height}px grid")
result = client.get_result(final.id)
with open("walls.png", "wb") as fh:
fh.write(result.wall_mask)
print(result.counts)Or poll yourself with custom logic:
import time
job = client.analyze_async("plan.png")
while not job.is_terminal:
time.sleep(1.0)
job = client.get_job(job.id)Working with the result
result.wall_mask and result.room_mask are standard PNGs, so any image library works; result.rooms and result.detections are plain Python objects. A few common patterns:
from io import BytesIO
from PIL import Image
result = client.extract("plan.png")
# Decode the wall-mask PNG and inspect it.
mask_img = Image.open(BytesIO(result.wall_mask))
print(mask_img.size) # (width, height) — same as the input image
print(mask_img.mode) # "L" — single-channel 8-bit grayscale
# Save a copy, or convert it.
mask_img.save("walls.png")
mask_img.convert("1").save("walls_bw.png") # 1-bit bitmapError handling
import time
from floorplan_api import (
Client, FloorPlanError,
AuthenticationError, RateLimitError, InvalidRequestError, NotFoundError,
ServerError, ProcessingError, TimeoutError, ConnectionError,
)
client = Client()
try:
result = client.extract("plan.png")
except RateLimitError as exc:
# Already retried max_retries times honouring Retry-After.
time.sleep(exc.retry_after or 5.0)
result = client.extract("plan.png")
except TimeoutError as exc:
# 504: the worker is still on it. Do not resubmit — finish the job.
if exc.job_id is None:
raise
job = client.wait_for_job(exc.job_id)
result = client.get_result(job.id)
except ProcessingError as exc:
# The worker failed this file (undecodable, ...). Same input will fail again.
print(f"cannot process: {exc.message} (job {exc.job_id})")
raise
except AuthenticationError:
print("Invalid or revoked API key")
raise
except InvalidRequestError as exc:
# 400 / 409 / 413 / 415, or rejected locally (unsupported bytes) — fix the input
print(f"bad request: {exc.message}")
raise
except FloorPlanError as exc:
# Anything else — keep the request_id for support tickets.
print(f"{exc.type}: {exc.message} (request_id={exc.request_id})")
raiseConnection failures, 429 and transient 5xx responses are retried up to max_retries times with exponential backoff and jitter; a server Retry-After (sent on 429 and on 503 when the queue is at capacity) overrides the backoff, capped at 30 s per attempt. The upload body is rewound before every retry.
Two responses are deliberately not retried because the server has already queued the job: a 504 timeout_error (raised as TimeoutError with job_id set — the job is still running) and a 500 that carries a job_id (raised as ProcessingError — the worker failed that input). Retrying either would create a second job for the same file.
Configuration
| Argument | Default | Description |
|---|---|---|
| api_key | env FLOORPLAN_API_KEY | Your API key. |
| base_url | https://api.floorplanapi.com | Override for self-hosted deployments. Also reads FLOORPLAN_BASE_URL. |
| timeout | 60.0 | Per-request timeout (seconds). Override per call with the keyword arg. |
| max_retries | 3 | Retries for connection errors, 429, and transient 5xx. A 504 or 500 that names a job_id is never retried. |
| retry_backoff | 0.5 | Base delay (s) for exponential backoff with jitter. |
| session / client | new | Reuse a custom requests.Session (Client) or httpx.AsyncClient (AsyncClient, argument client=). |
Method reference
| Method | Returns | REST equivalent |
|---|---|---|
| extract(image=None, *, upload_key=None, page=None, min_room_score=None, timeout=None) | Result | POST /v1/extract |
| analyze(image=None, *, upload_key=None, page=None, min_room_score=None, timeout=None) | Result | POST /v1/analyze |
| upload_then_extract(image, *, page=None, threshold_bytes=10_485_760, timeout=None) | Result | POST /v1/uploads + PUT + POST /v1/extract |
| create_upload(*, content_type="image/png", timeout=None) | dict | POST /v1/uploads |
| upload(image, *, page=None, content_type=None, timeout=None) | str (storage key) | POST /v1/uploads + PUT |
| analyze_async(image=None, *, upload_key=None, page=None, min_room_score=None, timeout=None) | Job | POST /v1/analyze?async=true |
| get_job(job_id, *, timeout=None) | Job | GET /v1/status/{id} |
| wait_for_job(job_id, *, poll_interval=1.0, timeout=300.0) | Job | GET /v1/status/{id} (loop) |
| get_result(job_id, *, timeout=None) | Result | GET /v1/jobs/{id}/result |
| close() / await aclose() | None | Closes the underlying session / connection pool. Context managers do this for you. |
image can be a path (str / pathlib.Path), raw bytes, or any binary file-like object. min_room_score (0 to 0.9, default 0.9) chooses how far down the room score scale to go; rooms scoring below it are not returned.
Types reference
Point = tuple[float, float] # (x, y) in pixels, origin top-left
@dataclass(frozen=True)
class Result: # returned by extract / analyze / upload_then_extract / get_result
wall_mask: MaskBytes # PNG wall mask: 255 = wall, 0 = everything else
room_mask: bytes | None # PNG room mask: pixel value = Room.id, 0 = no room
detections: list[Detection] # doors and windows
rooms: list[Room]
counts: dict[str, int] # {"door": 12, "window": 11, "room": 11}
width: int | None # pixel grid of both masks and every coordinate
height: int | None
page: int | None # PDF page that was processed (the page you asked for)
dpi: float | None # resolution the PDF page was rendered at; None for images
min_room_score: float | None # the room-score floor the job ran with
job_id: str | None # X-Job-Id
request_id: str | None # X-Request-Id
mode: str | None # X-Floorplan-Mode: "live" | "test"
page_size_pt: tuple[float, float] | None # PDF input only: page size in points
raw: dict # the response JSON without the two base64 mask fields
doors: list[Detection] # property: detections with label == "door"
windows: list[Detection] # property: detections with label == "window"
size: tuple[int, int] | None # property: (width, height) when both known
@dataclass(frozen=True)
class Detection:
label: str # "door" | "window" (the JSON field is "class")
confidence: float # 0..1
polygon: list[Point] # four corners of the (possibly rotated) box
center: Point # (cx, cy) of the same box
size: tuple[float, float] # (w, h) of the same box, along its own axes
@dataclass(frozen=True)
class Room:
id: int # 1 = largest; the pixel value in Result.room_mask
score: float # 1.0 fully enclosed; lower = the service had to close it
area: float # square pixels
polygon: list[list[Point]] # [outer ring, *hole rings], rings have no closing point
outline: list[Point] # property: the outer ring
holes: list[list[Point]] # property: the hole rings
class MaskBytes(bytes): # Result.wall_mask: the PNG bytes, with metadata
width: int | None # pixels, same as Result.width
height: int | None # pixels, same as Result.height
job_id: str | None # X-Job-Id
request_id: str | None # X-Request-Id
mode: str | None # X-Floorplan-Mode: "live" | "test"
size: tuple[int, int] | None # (width, height) when both known
page_size_pt: tuple[float, float] | None # PDF input only: page size in points
pdf_scale: float | None # mask px per PDF pt (width / page_size_pt[0])
pdf_dpi: float | None # pdf_scale * 72
def pdf_page_size(data: bytes, page: int = 1) -> tuple[float, float]:
"""(width, height) in points of a PDF page as it renders (crop box, /Rotate applied)."""
@dataclass(frozen=True)
class MaskResult: # Job.result: pointer to a completed job's result
result_url: str # "/v1/jobs/{job_id}/result"; fetch with get_result(job_id)
width: int # pixels
height: int # pixels
@dataclass(frozen=True)
class Job:
id: str
status: Literal["queued","processing","completed","failed"]
created_at: datetime
completed_at: datetime | None
result: MaskResult | None
error: dict | None
@property
def is_terminal(self) -> bool: ...
# All exceptions derive from FloorPlanError:
class FloorPlanError(Exception):
type: str | None
message: str
status_code: int | None
request_id: str | None
job_id: str | None # set when the server had already queued a job
response: dict | None
class AuthenticationError(FloorPlanError): ... # 401 / 403
class InvalidRequestError(FloorPlanError): ... # 400 / 409 / 413 / 415 / other 4xx, or rejected locally
class NotFoundError(FloorPlanError): ... # 404
class RateLimitError(FloorPlanError): # 429 (after retries)
retry_after: float | None
class ServerError(FloorPlanError): ... # 5xx (after retries)
class ProcessingError(ServerError): ... # 500 with job_id: worker failed the job; not retried
class TimeoutError(FloorPlanError): ... # client timeout, wait_for_job deadline, or 504 with job_id (not retried)
class ConnectionError(FloorPlanError): ...REST API
All requests use HTTPS. The hosted base URL is https://api.floorplanapi.com. When developing locally, use http://localhost:3000. Each endpoint below shows the same call in cURL, raw Python (requests), and Node.js (fetch).
Base URL
Production:
https://api.floorplanapi.comLocal development:
http://localhost:3000Authorization header
Authorization: Bearer fp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxPOST /v1/uploads
POST/v1/uploadsfree
Reserve a presigned URL the client can PUT bytes to directly. Use this to upload files larger than the inline 10 MB cap, or whenever you want to keep the bytes off the API server. After the PUT succeeds, pass the returned key as upload_key on /v1/extract or /v1/analyze.
Request body
Content-Type: application/json
{
"content_type": "image/png" // optional; defaults to "image/png"
// image/png | image/jpeg | image/webp | application/pdf
// — must match the Content-Type used on PUT
}Sample call
# 1. Reserve a slot.
curl -X POST https://api.floorplanapi.com/v1/uploads \
-H "Authorization: Bearer fp_test_..." \
-H "Content-Type: application/json" \
-d '{"content_type":"image/png"}'
# Response:
# {"upload_url":"https://...","key":"uploads/<rand>.png","expires_at":"...","content_type":"image/png"}
# 2. PUT the bytes to upload_url with the same content_type.
curl -X PUT "$UPLOAD_URL" \
-H "Content-Type: image/png" \
--data-binary @big_plan.png
# 3. Submit the job by storage key.
curl -X POST https://api.floorplanapi.com/v1/extract \
-H "Authorization: Bearer fp_test_..." \
-F "upload_key=$KEY" \
-o result.json
# 4. The response is JSON; the wall mask is a base64 PNG inside it.
jq -r .wall_mask_png result.json | base64 -d > walls.pngResponse
HTTP/1.1 200 OK
Content-Type: application/json
{
"upload_url": "https://<bucket>.<account>.r2.cloudflarestorage.com/uploads/...?X-Amz-...",
"key": "uploads/<48-hex>.png",
"expires_at": "2026-04-28T13:15:00.000Z",
"content_type": "image/png"
}Notes
- The presigned URL expires 15 minutes after issuance.
- The PUT must use the same
Content-Typedeclared in the request body, or it will be rejected. - The returned
keyis opaque — pass it back as-is. The API never reuses keys across calls.
POST /v1/extract
POST/v1/extract1 credit
Process a floor plan: walls, doors, windows and rooms. Synchronous; the response body on success is the JSON object described in Response body. The server waits up to about 30 s for the worker, then answers 504 with the job id (see below).
Request
- Content-Type:
multipart/form-data - One of (mutually exclusive):
image— PNG / JPEG / WEBP / PDF (first page), ≤ 10 MB inline. The part'sContent-Typemust be the file's type.upload_key— storage key from POST /v1/uploads (recommended for files larger than 10 MB).page— optional, PDF only: the 1-based page to process (default 1). Only that page is rasterised and processed. The server knows the declared kind of the upload (the part'sContent-Type, or theupload_key's extension) and answers 400 ifpageis not a positive integer or is given for anything but a PDF; a PDF with fewer pages fails the job withinvalid_request_error, answered as a 400.min_room_score— optional, number from 0 to 0.9 (default 0.9): how far down the roomscorescale to go. Every room carries ascore: 1.0 for a fully enclosed room, lower values (0.9, 0.8, 0.7, 0.5) for rooms the service had to close itself. Rooms scoring belowmin_room_scoreare not returned, so 0.9 is the strictest setting and 0.5 the most inclusive. Answers 400 for values outside 0–0.9.
Sample call
# Inline (small files, ≤ 10 MB):
curl -X POST https://api.floorplanapi.com/v1/extract \
-H "Authorization: Bearer fp_test_..." \
-F "image=@plan.png" \
-o result.json
# The response is JSON. Both masks are base64 PNGs inside it:
jq -r .wall_mask_png result.json | base64 -d > walls.png
jq -r '.room_mask_png // empty' result.json | base64 -d > rooms.png
# ...and the rest is plain data:
jq '.counts' result.json
jq -c '.rooms[] | {id, score, area}' result.json
# By storage key (after POST /v1/uploads + PUT):
curl -X POST https://api.floorplanapi.com/v1/extract \
-H "Authorization: Bearer fp_test_..." \
-F "upload_key=uploads/<key>.png" \
-o result.json
# Page 3 of a PDF, also returning rooms down to score 0.5:
curl -X POST https://api.floorplanapi.com/v1/extract \
-H "Authorization: Bearer fp_test_..." \
-F "image=@drawing-set.pdf;type=application/pdf" \
-F "page=3" \
-F "min_room_score=0.5" \
-o result.jsonSample response (success)
HTTP/1.1 200 OK
Content-Type: application/json
X-Job-Id: job_abc123
X-Request-Id: req_def456
X-Floorplan-Mode: test
{
"job_id": "job_abc123",
"width": 1024,
"height": 768,
"page": 1,
"dpi": null,
"min_room_score": 0.9,
"counts": { "door": 12, "window": 11, "room": 11 },
"detections": [
{ "class": "door", "confidence": 0.9312,
"polygon": [[412.0, 655.5], [468.0, 655.5], [468.0, 671.5], [412.0, 671.5]],
"center": [440.0, 663.5], "size": [56.0, 16.0] }
// ...
],
"rooms": [
{ "id": 1, "score": 1.0, "area": 413312.0,
"polygon": [ [[120, 96], [884, 96], [884, 640], [120, 640]],
[[402, 300], [450, 300], [450, 348], [402, 348]] ] }
// ...
],
"wall_mask_png": "iVBORw0KGgoAAAANSUhEUgAA...",
"room_mask_png": "iVBORw0KGgoAAAANSUhEUgAA..."
}Every field is described in Response body.
Possible status codes
200— success, body is the JSON result.400— missing/invalidimagefield, or a badpageormin_room_score; also when the worker rejects the file itself (undecodable image, password-protected PDF, a page past the end):error.typeisinvalid_request_errorand the body carriesjob_id.401— missing / invalid / revoked / expired key.413— image larger than 10 MB on the inline path; use POST /v1/uploads +upload_keyinstead.415— unsupported MIME type.429— rate limit exceeded.500— the worker failed the job (error.typee.g.inference_error); body carriesjob_id. Resubmitting the same file will fail again.503— queue full; honourRetry-After.504— timed out before the worker finished; body carriesjob_idand the job keeps running. Poll/v1/status/{job_id}thenGET /v1/jobs/{job_id}/resultinstead of resubmitting.
POST /v1/analyze
POST/v1/analyze2 credits
Returns the same response body as /v1/extract for now. Sync by default; pass async=true to submit a job and receive a job_id instead of the result.
Request fields
- Content-Type:
multipart/form-data - One of
imageorupload_key(required) — same semantics as /v1/extract. page— optional, PDF only: 1-based page to process (default 1), as on /v1/extract.async(defaultfalse) — set totrueto submit asynchronously.min_room_score— optional, number from 0 to 0.9 (default 0.9): how far down the roomscorescale to go (1.0 fully enclosed, lower for rooms the service had to close itself); rooms scoring below it are not returned. 400 outside 0–0.9. Same as on /v1/extract.
Sync call
curl -X POST https://api.floorplanapi.com/v1/analyze \
-H "Authorization: Bearer fp_test_..." \
-F "image=@plan.png" \
-o result.json
jq -r .wall_mask_png result.json | base64 -d > walls.png
jq .counts result.jsonAsync submit
curl -X POST https://api.floorplanapi.com/v1/analyze \
-H "Authorization: Bearer fp_test_..." \
-F "image=@plan.png" \
-F "async=true"Async submission response (202)
{
"success": true,
"job_id": "job_abc123",
"status": "queued",
"created_at": "2026-04-28T13:00:00.000Z",
"mode": "test"
}GET /v1/status/{job_id}
GET/v1/status/{job_id}free
Poll the status of an async job. When the job completes, the response carries a result_url pointing at the result endpoint below.
Sample call
curl https://api.floorplanapi.com/v1/status/job_abc123 \
-H "Authorization: Bearer fp_test_..."Response shape
{
"job_id": "job_abc123",
"status": "completed", // or "queued" | "processing" | "failed"
"created_at": "2026-04-28T13:00:00.000Z",
"completed_at": "2026-04-28T13:00:02.000Z",
"result": {
"result_url": "/v1/jobs/job_abc123/result",
"width": 1024,
"height": 768
},
"error": null // or { "type": "...", "message": "..." }
}Polling pattern
Suggested cadence: poll every 1–2 s for the first 30 s, then every 5 s, with a hard ceiling of a few minutes (depending on your batch size). The Python client's wait_for_job() does this for you.
import time, requests
def wait(job_id, *, key, base="https://api.floorplanapi.com", timeout=300):
deadline = time.monotonic() + timeout
while True:
res = requests.get(f"{base}/v1/status/{job_id}",
headers={"Authorization": f"Bearer {key}"})
res.raise_for_status()
job = res.json()
if job["status"] in ("completed", "failed"):
return job
if time.monotonic() > deadline:
raise TimeoutError(job_id)
time.sleep(1.5)GET /v1/jobs/{job_id}/result
GET/v1/jobs/{job_id}/resultfree
Fetch the result of a completed job: the same JSON response body a synchronous call returns. Use it after an async submit, or to recover a synchronous call that answered 504. Returns 409 invalid_request_error while the job is not completed, 404 for an unknown job, and 403 if the job belongs to another account.
Sample call
curl https://api.floorplanapi.com/v1/jobs/job_abc123/result \
-H "Authorization: Bearer fp_test_..." \
-o result.json
jq -r .wall_mask_png result.json | base64 -d > walls.png
jq .counts result.jsonSuccess response
HTTP/1.1 200 OK
Content-Type: application/json
X-Job-Id: job_abc123
{
"job_id": "job_abc123",
"width": 1024,
"height": 768,
"page": 1,
"dpi": null,
"min_room_score": 0.9,
"counts": { "door": 12, "window": 11, "room": 11 },
"detections": [ ... ],
"rooms": [ ... ],
"wall_mask_png": "iVBORw0KGgoAAAANSUhEUgAA...",
"room_mask_png": "iVBORw0KGgoAAAANSUhEUgAA..."
}Possible status codes
200— the job is completed; body is the JSON result.403— the job belongs to another account.404— unknown job id.409— the job is not completed (still queued or processing, or it failed); check/v1/status/{job_id}.
Response headers
| Header | Description |
|---|---|
| X-Request-Id | Unique ID for the request — include in support tickets. |
| X-Job-Id | Job ID created for the request. Use it to poll /v1/status/{id} after a 504. Also in the body as job_id. |
| X-Floorplan-Mode | live or test. |
| X-RateLimit-Limit | Requests per minute allowed. |
| X-RateLimit-Remaining | Requests left in current window. |
| X-RateLimit-Reset | Unix timestamp when the window resets. |
Errors
Error responses always use Content-Type: application/json with a stable shape. The Python client maps these onto typed exceptions.
{
"error": {
"type": "authentication_error",
"message": "Invalid API key."
}
}| Status | type | Python exception | When |
|---|---|---|---|
| 400 | invalid_request_error | InvalidRequestError | Missing field, malformed body. |
| 401 | authentication_error | AuthenticationError | Missing/invalid/revoked/expired key. |
| 403 | authentication_error | AuthenticationError | Resource doesn't belong to your account. |
| 404 | not_found_error | NotFoundError | Job ID not found or expired. |
| 409 | invalid_request_error | InvalidRequestError | Result requested before the job completed. |
| 413 | invalid_request_error | InvalidRequestError | Image larger than 10 MB. |
| 415 | invalid_request_error | InvalidRequestError | Unsupported MIME type. |
| 429 | rate_limit_error | RateLimitError | Per-minute rate limit exceeded. |
| 503 | service_unavailable | ServerError | Queue at capacity; honour Retry-After. |
| 500 | inference_error, storage_error, processing_error | ProcessingError | The worker failed the queued job; body carries job_id. Not retried. |
| 504 | timeout_error | TimeoutError (job_id set) | Sync request did not finish in time; the job keeps running. Poll /v1/status/{job_id}, then fetch /v1/jobs/{job_id}/result. Not retried. |
| other 5xx | server_error | ServerError | Transient server problem; retried automatically. |
Rate limits & quotas
Rate limits are per API key per minute. Hitting the limit returns 429 with a Retry-After header. Monthly credit budgets apply separately and reset on the first day of the billing period.
Private beta: beta accounts are not rate limited and have no credit budget. Their responses omit the X-RateLimit-* headers. If the processing queue is full the API answers 503 with Retry-After; the Python client retries that for you.
| Plan | Requests/minute | Concurrent | Monthly credits |
|---|---|---|---|
| Free | 10 | 1 | 50 |
| Starter | 30 | 3 | 100 |
| Pro | 60 | 10 | 500 |
| Enterprise | Custom | Custom | Unlimited |
Support
Have a question, found a bug, or want to ship something we don't expose yet?
- Contact us — for everything else.
- Include the
X-Request-Idresponse header (or therequest_idfield on theFloorPlanErrorin Python) to speed things up. - Dashboard — manage keys, view usage, change plan.