Speckle Automate API Reference
This reference documents the essential APIs and interfaces for developing functions in Speckle Automate. All APIs are available in both Python and C# SDKs.Start with the Quickstart Guide to understand the basic concepts before using this API reference.
Function Inputs
Function inputs define what users can configure when running your automation. They automatically generate forms in the web interface.Supported Types
Type | Python | C# | Use Case |
---|---|---|---|
Text | str | string | Names, descriptions, IDs |
Number | float | double | Measurements, thresholds |
Integer | int | int | Counts, indices |
Boolean | bool | bool | Toggle options |
Selection | Enum | enum | Choose from options |
Secret | SecretStr | [Secret] | API keys, passwords |
Validation Attributes
Validation | Python | C# | Description |
---|---|---|---|
Required | Field(...) | [Required] | Field must be provided |
Length | min_length=1, max_length=100 | [MinLength(1)] , [MaxLength(100)] | String length limits |
Range | gt=0, lt=100 | [Range(0, 100)] | Number value limits |
Pattern | pattern=r"^[A-Z]+$" | [RegularExpression("^[A-Z]+$")] | Regex validation |
Example: Simple Inputs
simple_inputs.py
Example: Dropdown Selections
dropdown_selections.py
Example: Secure Inputs
secure_inputs.py
Automation Context
TheAutomationContext
is your function’s interface to Speckle. It provides access to data, authentication, and methods for reporting results.
Properties
Metadata about the current automation run, including run ID, trigger information, and execution context
Pre-configured, authenticated client for Speckle API calls. Provides full access to the Speckle SDK functionality.
User-provided configuration values that were specified when the automation was triggered
🔧 Full SDK Access: The
speckle_client
property provides access to the complete Speckle SDK functionality. You can use all features from SpecklePy (Python) or SpeckleSharp (C#) within your Automate functions.Methods
Get the model that triggered this automation. Returns the complete Speckle data structure.
Report successful completion of the automation. Call this when your function completes successfully.
Report business logic failure. Use this when validation fails or business rules are violated.
Report unexpected error. Use this when an exception occurs that wasn’t part of normal business logic.
Mark specific objects with errors. Useful for validation failures or processing errors on individual elements.
Add warnings to specific objects. Use for performance issues, recommendations, or non-critical problems.
Mark objects as successfully processed. Useful for tracking which elements were processed correctly.
Create a new model version with modified data. Returns the ID of the newly created version.
Save a file as an artifact. Useful for reports, exports, or analysis results. Returns the artifact ID.
Getting Model Data
getting_model_data.py
Status Reporting
Your function must report its final status using one of these methods:status_reporting.py
Annotating Objects
Add status information to specific objects in the model:annotating_objects.py
Creating New Model Versions
creating_versions.py
Saving Files
saving_files.py
Working with Speckle Data
Data Structure
Speckle models are directed acyclic graphs (DAGs):- Objects can reference other objects
- Properties can be primitive values or object references
- References are one-way (parent → child)
- Common properties:
elements
,parameters
,units
,applicationId
Complete Function Example
Here’s a complete example that demonstrates all the key concepts:complete_example.py
Next Steps
- Function Inputs - Detailed input configuration
- Working with Data - Advanced data processing patterns
- Function Testing - Testing your functions
- Creating Automations - Setting up automation workflows