Formlabs Local API (0.8.0)

Download OpenAPI specification:Download

Introduction

The Formlabs Local API is designed for integrations that want to automate job preparation, getting local-network printer status, or sending jobs to Formlabs printers without launching the PreForm graphical user interface. A server application must be installed and run on a user's computer to use this API.

Example use cases:

  • Scripted job preparation that takes a folder of models, sets up a print, and uploads it to a printer without user input.
  • Deep and custom integrations into 3D Modeling and Design software to prepare print scenes beyond the scope of the PreForm Command Line Arguments.

This API uses RESTful principles. This means the API is organized around resources and collections of resources. Resources and collections are each available at their own URI. You can interact with these resources using standard HTTP Methods on the resource's URI.

Example endpoint:

GET http://localhost:44388/scene/

Responses from the API server will be in JSON and are documented throughout the reference docs. This API is described by an OpenAPI Specification. This interactive documentation is automatically generated from the specification file.

Technical Overview

PreFormServer Background Application

All Local API integrations involve starting the PreFormServer background application to expose its HTTP API, then making local HTTP API calls in your own code. This application is like PreForm, Formlabs' regular job preparation application, but it does not open a graphical window, and interaction is done via HTTP API requests. The PreFormServer application is supported on Windows and MacOS with separate downloads for each Operating System.

Installing PreFormServer

The PreFormServer application can be downloaded from the Formlabs API downloads and release notes page. After downloading, unzip the file and move the application to the desired location on your computer. Any location can be used as the path to the application should be referenced from your integration code.

In the current release, we also recommend adding the PreFormServer application the users' antivirus software exception list or explicitly whitelisting the application in the security settings of MacOS.

On MacOS, you can use the following terminal command to whitelist the PreFormServer application:

xattr -r -d com.apple.quarantine PreFormServer.app

Starting PreFormServer

The PreFormServer application can started manually from your Operating System's command prompt or terminal, but most integrations will start the application programatically from integration code. By default the HTTP Server will listen on port 44388, but this can be changed by passing in a different port number as the command line argument --port to the PreFormServer application.

The HTTP API server started by the PreFormServer application cannot immediately respond to requests. When the server is ready to accept requests, it will output READY FOR INPUT in the standard output.

For example, running the PreFormServer application on Windows from the command prompt:

PreFormServer.exe

will output something like the following:

starting HTTP server
Listening...
HTTP server listening on port  44388
READY FOR INPUT

Making API Requests

The code to make HTTP API requests to a running PreFormServer can be written directly in your integration code or by using a generated library that does the API calls. The endpoints and format of the HTTP API are described on this page and in the openapi.yaml file. Formlabs provides an example Python library that handles the setup and request formatting.

Glossary

  • Scene: The current state of a job that can be printed on a particular printer model. This includes both the “Scene Settings” and all of the currently loaded models and their support structures.
  • Scene Settings: Printer type and material information of scene. Describes the build platform size, the printer capabilities, and what material and print settings it is set up to be printed with.

Stateful Interactions

The PreForm Server is stateful in that while it is running, it keeps a cache of the current scene and requests will use the cached scene and possibly modify it. For example, initially a scene may be empty and then if a load model request is made then the cached scene will have one model loaded. Calling the load model requests again will load another copy of the model resulting in two models in the cached scene.

Blocking Calls & Asynchronous Requests

Unless otherwise stated, API calls are blocking: the HTTP request will not return until the operation has completed. Some requests like running the auto support action on a scene with many complicated models could take over 1 minute (depending on computer resources). The Server has a timeout of 10 minutes for all requests.

Requests made asynchronously will use the last cached state. For example, if a “get scene” request is made during a “auto support” request that has not finished, then the “get scene” request will return data that will not include the auto support changes.

File Paths

When saving and loading files, the local API inputs expect full operating system paths to local files on disk.

Correct file path:

  • C:\Projects\Models\part.stl

Incorrect file paths:

  • .\Models\part.stl
  • %ENV_VAR%\part.stl
  • part.stl
  • https://filestorage.com/part.stl

Errors

Conventional HTTP response codes are used to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided. Codes in the 5xx range indicate an error with Formlabs' servers.

Security

The HTTP Server that PreForm uses to communicate is only exposed to the local network of your computer and not to the public Internet, unless you have configured your computer to expose the port running the PreForm Server to the Internet.

Some requests require an Internet connection, require Dashboard login, and make web requests to perform their action (such as printing to a remote printer).

Devices

Operations related to Formlabs devices

Get Devices

List of previously discovered device statuses

By default, only locally discovered printer names are returned. To include your Fleet Control queues or printers registered to your Dashboard account, you must be logged in and have an Internet connection. Use the Login endpoint to authenticate with Formlabs Web Services.

Responses

Response samples

Content type
application/json
{
  • "count": 0,
  • "devices": [
    ]
}

Get Device

Get a previously discovered device's status

path Parameters
id
required
string

The unique identifier of the printer

Responses

Response samples

Content type
application/json
Example
{
  • "id": "string",
  • "product_name": "string",
  • "status": "string",
  • "is_connected": true,
  • "connection_type": "UNKNOWN",
  • "ip_address": "string",
  • "firmware_version": "string"
}

Discover Devices

Discover new devices on the network

Request Body schema: application/json
required
timeout_seconds
integer

Number of seconds to wait when discovering devices

ip_address
string

Local network IP address to attempt to discover a device at

Responses

Request samples

Content type
application/json
Example
{
  • "timeout_seconds": 10
}

Response samples

Content type
application/json
{
  • "count": 0,
  • "devices": [
    ]
}

Modifying a Scene

Operations related to modifying the scene

Create Scene

Create a new scene

Request Body schema: application/json
required

Create a scene with a given printing setup. For a full list of possible settings, call the GET /list-materials/ endpoint

machine_type
required
string

The machine type of the scene

material_code
required
string

The material code of the scene

print_setting
string

The print setting of the scene

required
string or number

The slice thickness of the scene

Responses

Request samples

Content type
application/json
Example
{
  • "machine_type": "FORM-4-0",
  • "material_code": "FLGPBK05",
  • "print_setting": "DEFAULT",
  • "layer_thickness_mm": 0.025
}

Response samples

Content type
application/json
{
  • "models": [
    ],
  • "scene_settings": {
    },
  • "material_usage": {
    },
  • "layer_count": 0
}

Load .form file

Load a .form file and create a new scene from it

Request Body schema: application/json
required

Full path to the .form file to load

file
required
string

Responses

Request samples

Content type
application/json
{
  • "file": "C:\\Users\\user\\Desktop\\test.form"
}

Response samples

Content type
application/json
{
  • "models": [
    ],
  • "scene_settings": {
    },
  • "material_usage": {
    },
  • "layer_count": 0
}

Update model

Update a model's properties

path Parameters
id
required
string

The unique identifier of the model

Request Body schema: application/json
required

Model properties to update

name
string

The name of the model used within job preparation.

object (ScenePositionModel)

The global position within the build volume of a printer of the model in the scene

EulerAnglesModel (object) or TransformMatrixModel (object) or DirectionVectorsModel (object) (OrientationModel)

The orientation of the model in the scene. It can be specified using one of the following: Euler angles, a transform matrix, or direction vectors.

scale
number

The scale factor to apply to the model

units
string (UnitsModel)
Enum: "MILLIMETERS" "INCHES"

The units of the model

Responses

Request samples

Content type
application/json
Example
{
  • "position": {
    }
}

Response samples

Content type
application/json
{
  • "error": {
    }
}

Delete model

Delete a model from the current scene

path Parameters
id
required
string

The unique identifier of the model

Responses

Duplicate model

Duplicate a model

path Parameters
id
required
string

The unique identifier of the model

Request Body schema: application/json
required
count
integer

Number of duplicates to create

Responses

Request samples

Content type
application/json
{
  • "count": 0
}

Response samples

Content type
application/json
{
  • "models": [
    ],
  • "scene_settings": {
    },
  • "material_usage": {
    },
  • "layer_count": 0
}

Replace model

Replace a model currently in the scene with a new model, copying the existing models setup and supports

path Parameters
id
required
string

The unique identifier of the model

Request Body schema: application/json
required
file
string

Full path to the file to load

repair_behavior
string (RepairBehaviorModel)
Default: "ERROR"
Enum: "REPAIR" "ERROR" "IGNORE"

The behavior to use when loading a broken model

Responses

Request samples

Content type
application/json
{
  • "file": "string",
  • "repair_behavior": "REPAIR"
}

Response samples

Content type
application/json
{
  • "warnings": [
    ],
  • "model_properties": {
    }
}

Import model

Import a model into the current scene

Request Body schema: application/json
required
file
required
string

Full path to the file to load

repair_behavior
string (RepairBehaviorModel)
Default: "ERROR"
Enum: "REPAIR" "ERROR" "IGNORE"

The behavior to use when loading a broken model

name
string

The name of the model used within job preparation.

object (ScenePositionModel)

The global position within the build volume of a printer of the model in the scene

EulerAnglesModel (object) or TransformMatrixModel (object) or DirectionVectorsModel (object) (OrientationModel)

The orientation of the model in the scene. It can be specified using one of the following: Euler angles, a transform matrix, or direction vectors.

scale
number
Default: 1

The scale factor to apply to the model

units
string (ImportUnitsModel)
Default: "DETECTED"
Enum: "DETECTED" "MILLIMETERS" "INCHES"

The units of the model

Responses

Request samples

Content type
application/json
Example
{
  • "file": "C:\\Users\\user\\Desktop\\test.stl"
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "name": "string",
  • "position": {
    },
  • "orientation": {
    },
  • "scale": 0,
  • "units": "MILLIMETERS",
  • "bounding_box": {
    },
  • "original_file": "string",
  • "visible": true,
  • "has_supports": true,
  • "in_bounds": true,
  • "raw_mesh_hash": "string",
  • "canonical_model_hash": "string"
}

Auto Orient

Run auto orient operation

Request Body schema: application/json
required

Models to run the auto orient operation on

One of
required
Select all models (string) or Array of Apply to a list of specific models (strings) (ModelsSelectionModel)

Responses

Request samples

Content type
application/json
Example
{
  • "models": "ALL"
}

Response samples

Content type
application/json
{
  • "error": {
    }
}

Auto Support

Run auto support operation

Request Body schema: application/json
required

Models to run the auto support operation on

required
Select all models (string) or Array of Apply to a list of specific models (strings) (ModelsSelectionModel)
raft_type
string
Enum: "FULL_RAFT" "MINI_RAFTS" "NONE"

The type of raft to apply to the models

raft_label_enabled
boolean

Whether to enable raft labeling

breakaway_structure_enabled
boolean

Whether to enable breakaway structure

density
number >= 0

The density of the supports

touchpoint_size_mm
number >= 0

The size of the touchpoints

internal_supports_enabled
boolean

Whether to enable internal supports

raft_thickness_mm
number >= 0

The thickness of the raft

slope_multiplier
number >= 0

The slope multiplier

height_above_raft_mm
number >= 0
z_compression_correction_mm
number >= 0
early_layer_merge_mm
number >= 0

Responses

Request samples

Content type
application/json
Example
{
  • "models": "ALL"
}

Response samples

Content type
application/json
{
  • "error": {
    }
}

Auto Layout

Run auto layout operation. Only applies to SLA-type scenes like the Form 4

Request Body schema: application/json
required

Models to run the auto layout operation on

required
Select all models (string) or Array of Apply to a list of specific models (strings) (ModelsSelectionModel)
model_spacing_mm
number >= 0

Minimum (non-zero) distance between models in the scene.

allow_overlapping_supports
boolean

Whether to allow rafts to overlap.

lock_rotation
boolean

Whether to keep model rotation about Z fixed during layout.

build_platform_2_optimized
boolean

Whether to optimize the build platform for two models.

Responses

Request samples

Content type
application/json
Example
{
  • "models": "ALL",
  • "model_spacing_mm": 1,
  • "allow_overlapping_supports": false,
  • "lock_rotation": false,
  • "build_platform_2_optimized": false
}

Response samples

Content type
application/json
{
  • "models": [
    ],
  • "scene_settings": {
    },
  • "material_usage": {
    },
  • "layer_count": 0
}

Auto Pack

Run auto pack operation. Only applies to SLS-type scenes like the Fuse 1+

Request Body schema: application/json
required

Auto pack parameters

model_spacing_mm
number >= 0

The minimum spacing between models when packing

Responses

Request samples

Content type
application/json
{
  • "model_spacing_mm": 0
}

Response samples

Content type
application/json
{
  • "models": [
    ],
  • "scene_settings": {
    },
  • "material_usage": {
    },
  • "layer_count": 0
}

Getting Scene Information

Operations related to getting information about a scene

Get Scene

Get data about the current scene

Responses

Response samples

Content type
application/json
{
  • "models": [
    ],
  • "scene_settings": {
    },
  • "material_usage": {
    },
  • "layer_count": 0
}

Get model

Get a model's properties

path Parameters
id
required
string

The unique identifier of the model

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "name": "string",
  • "position": {
    },
  • "orientation": {
    },
  • "scale": 0,
  • "units": "MILLIMETERS",
  • "bounding_box": {
    },
  • "original_file": "string",
  • "visible": true,
  • "has_supports": true,
  • "in_bounds": true,
  • "raw_mesh_hash": "string",
  • "canonical_model_hash": "string"
}

Get Print Validation

Calculate the print validation for the current scene

Responses

Response samples

Content type
application/json
{
  • "per_model_results": {
    }
}

Estimate Print Time

Calculate the estimated print time for the current scene

Responses

Response samples

Content type
application/json
{
  • "total_print_time_s": 0,
  • "preprint_time_s": 0
}

Exporting

Save .form file

Save the current scene to a .form file

Request Body schema: application/json
required

Full path where the file should be saved

file
required
string

Responses

Request samples

Content type
application/json
{
  • "file": "C:\\Users\\user\\Desktop\\test.form"
}

Response samples

Content type
application/json
{
  • "error": {
    }
}

Save screenshot file

Save a screenshot of the current scene.

Request Body schema: application/json
required

Full path where the image should be saved

file
required
string^.*\.png$

The file path to save the .png screenshot to

view_type
string
Default: "ZOOM_ON_MODELS"
Enum: "ZOOM_ON_MODELS" "FULL_BUILD_VOLUME" "FULL_PLATFORM_WIDTH"

The type of view to use when taking the screenshot

Select all models (string) or Array of Apply to a list of specific models (strings) (ModelsSelectionModel)

Responses

Request samples

Content type
application/json
Example
{
  • "file": "C:\\Users\\user\\Desktop\\screenshot.png"
}

Response samples

Content type
application/json
{
  • "error": {
    }
}

Printing

Print

Upload the current scene to a printer or Fleet Control.

By default, only locally discovered printer names or local IP addresses are supported. To upload prints remotely to your Fleet Control queue or printers registered to your Dashboard account, you must be logged in and have an Internet connection. Use the Login endpoint to authenticate with Formlabs Web Services.

Request Body schema: application/json
required
printer
required
string

Printer serial name, IP address, or Fleet Control Queue ID

job_name
required
string

Responses

Request samples

Content type
application/json
{
  • "printer": "10.35.15.12",
  • "job_name": "Test Job"
}

Response samples

Content type
application/json
{
  • "job_id": "string"
}

Remote Access

Operations related to remote access and printing that require Internet access and authentication with Formlabs Web Services."

Login

Log in to Formlabs Web Services using an existing formlabs.com account.

Request Body schema: application/json
required

User credentials

One of
username
required
string
password
required
string

Responses

Request samples

Content type
application/json
Example
{
  • "username": "username",
  • "password": "password"
}

Response samples

Content type
application/json
{
  • "access_token": "string",
  • "refresh_token": "string"
}

Print

Upload the current scene to a printer or Fleet Control.

By default, only locally discovered printer names or local IP addresses are supported. To upload prints remotely to your Fleet Control queue or printers registered to your Dashboard account, you must be logged in and have an Internet connection. Use the Login endpoint to authenticate with Formlabs Web Services.

Request Body schema: application/json
required
printer
required
string

Printer serial name, IP address, or Fleet Control Queue ID

job_name
required
string

Responses

Request samples

Content type
application/json
{
  • "printer": "10.35.15.12",
  • "job_name": "Test Job"
}

Response samples

Content type
application/json
{
  • "job_id": "string"
}

Get Devices

List of previously discovered device statuses

By default, only locally discovered printer names are returned. To include your Fleet Control queues or printers registered to your Dashboard account, you must be logged in and have an Internet connection. Use the Login endpoint to authenticate with Formlabs Web Services.

Responses

Response samples

Content type
application/json
{
  • "count": 0,
  • "devices": [
    ]
}

Get Device

Get a previously discovered device's status

path Parameters
id
required
string

The unique identifier of the printer

Responses

Response samples

Content type
application/json
Example
{
  • "id": "string",
  • "product_name": "string",
  • "status": "string",
  • "is_connected": true,
  • "connection_type": "UNKNOWN",
  • "ip_address": "string",
  • "firmware_version": "string"
}

Discover Devices

Discover new devices on the network

Request Body schema: application/json
required
timeout_seconds
integer

Number of seconds to wait when discovering devices

ip_address
string

Local network IP address to attempt to discover a device at

Responses

Request samples

Content type
application/json
Example
{
  • "timeout_seconds": 10
}

Response samples

Content type
application/json
{
  • "count": 0,
  • "devices": [
    ]
}

Print Settings

Operations related to getting available print settings.

List Materials

List all available materials and material settings by printer type. The returned JSON has 3 layers: Printer types (e.g. "Form 4"), Materials (e.g. "Black V5"), and Material Setting (e.g. "0.025mm" or "0.100mm (Legacy)"). These "label" strings at each level are the preferred way of referring to that printer types, materials, and settings. They can presented in a UI as a 3-level dropdown menu, or a flat filtered list. This list is static (it will not change for a given version of the PreFormServer executable). Each value has scene_settings with all data needed to create a new scene. It can be passed directly to a /scene/ POST to create a scene for that printer, material, and materialSettings.

Responses

Response samples

Content type
application/json
{
  • "printer_types": [
    ]
}

API Info

Get information about the API itself

Get API Version

Get the version of the API

Responses

Response samples

Content type
application/json
{
  • "version": "string"
}