Skip to main content

Model and Snapshot APIs

The model interface handles two types of information at the same time: model records save name, description, public scope, personal group and workspace type; model snapshots save a complete topology and parameters. When updating model content, the platform creates a new snapshot and points the "current snapshot" of the model to it, rather than overwriting the previous content.

This page describes the HTTP interface. See API Conventions for request headers, status codes and general response structures, see Model, Job, Result, and Snapshot Lifecycles for complete resource relationships, and see Resource Identifiers for the uses of various UUIDs.

First Distinguish Three Types of Objects​

ObjectWhat to SaveProduced by What OperationMain Purpose
Model recordName, description, visibility, workspace type, creator, and current snapshot referenceCreate modelLocate a model that can be edited further
Model snapshotFull model JSON submitted on one saveSubmit snapshot_data when creating or updating a modelOpen the model again and continue editing
Job freeze snapshotThe graph and component definition used when launching the jobCreate jobRestore the fixed input of a certain calculation

Although model snapshots and job frozen snapshots are carried by the same type of underlying resources, their referrers and semantics are different. The current_snapshot returned by the model details is the data content of the current model snapshot; the job snapshot interface returns the frozen data of the specified job. State snapshots during operation belong to another type of resource, see Job, Control, and Result APIs.

Interface Overview​

MethodPathFunction
GET/api/models/Query undeleted models
POST/api/models/Create a model and create the first model snapshot at the same time
GET/api/models/{model_id}/Read an undeleted model and its current snapshot
PUT/api/models/{model_id}/Update metadata; create new snapshot when committing snapshot_data
DELETE/api/models/{model_id}/soft delete model
POST/api/models/{model_id}/restore/Restore soft deleted model
POST/api/models/validate/Verify drafts uniformly according to the specified workspace without saving data
GET / POST/api/models/groups/Query your group and quantity, or create a group
PUT / DELETE/api/models/groups/{group_id}/Rename or delete self-created groups
POST/api/models/move-group/Example of moving individuals in batches
GET/api/jobs/{job_id}/snapshot/Read input frozen on job creation

These interfaces require a valid Bearer access token. There is currently no PATCH model interface, nor a client-side model snapshot history list, snapshot details, or rollback interface.

Model Fields and Snapshot Fields​

Commonly used fields in model responses are as follows:

FieldTypeDescription
idUUID stringModel UUID, created by the platform
namestringModel name, leading and trailing blanks will be removed when submitting, cannot be empty
descriptionString or nullModel description
publicitystringprivate, depart_public or public
typestringworkspace type, must correspond to an existing type
group_idUUID string or nullReadable and writable, only my calculations are returned; null represents the default grouping
group_namestringRead-only, only my calculations are returned; the default value is "Default Group"
created_at / updated_atdatetime stringCreation time and last update time
created_byUser IDmodel creator
created_by_usernamestringCreator username
current_snapshotObject or nullThe JSON content of the current model snapshot, not the snapshot UUID
is_deleteBoolean valueSoft deletion markers; normal lists and details only return non-deleted models

Use snapshot_data when writing model content. It is a write-only field, so the original name will not appear in the response; after successful saving, the same content is returned through current_snapshot. current_snapshot is a read-only field, and it cannot be used to replace snapshot_data for submission and saving.

Clients should not submit id, created_at, updated_at, current_snapshot, created_by, or is_delete. The creator is determined by the current login identity, and the deletion status should be changed through the dedicated deletion and recovery interface. Even if a server-side serialized field currently appears on a writable surface, it should not be taken as a formal contract to transfer ownership or bypass lifecycle interfaces.

Disclosure Scope and Access Determination​

The meanings of the three public scopes are:

publicityUser Visible NameNormal Reading Range
privateprivateThe creator himself
depart_publicDisclosure within the organizationThe creator himself, and the people who share the organization with the creator
publicfull disclosureLogged in user

Permissions also overlap platform roles and organization management scope: super administrators can access any model; organization administrators can read and operate models of members of the organization they manage, including private models. For ordinary users, the public scope only extends read permissions and does not grant update, delete, or restore permissions.

A special distinction needs to be made between "list discovery" and "object reading":

  • When querying public, organization shared, or all-accessible models, the list of non-superadmins is also filtered by the type of workspace they have access to.
  • When reading details through the model UUID, the current interface is judged according to the model ownership, public scope, and management scope, and the same workspace filtering is no longer performed.
  • When creating and updating a model, the current interface will check that the account has been authenticated, that type corresponds to an existing workspace type, and that the snapshot infrastructure is checked, but it will not perform the same set of space authorization checks in the unified verification interface.

Therefore, the caller cannot regard "appearing in the list", "can read details" or "created successfully" as workspace authorization conclusions alone. When preparing to edit, verify or run the model, you should also call the corresponding interface according to the actual operation, and the server will judge the permissions again. Calling the unified verification interface before creation can also confirm that the current user can access the target space.

Query Model List​

GET /api/models/
Authorization: Bearer <access-token>

Select Query Scope​

query_typeReturn Range
my_modelsModel created by the current user; default
public_modelsA model that is fully public and whose workspace is accessible to the current user
org_modelsModels shared by organization members are published as public within the organization and can be accessed by the current user in their workspace
all_accessibleThe current user can access personal models, fully public models, and public models within the organization in the space.
all_modelsSuper administrator queries all undeleted models
admin_org_modelsOrganization administrators can query all undeleted models of members of the managed organization, including private models.

When a normal user submits a management query value that they don't have permission to use, the current implementation falls back to "My Model" instead of returning 403 . Unknown query_type also falls back to My Models. Clients should still only send values that match the current role and cannot infer administrative permissions based on a null or non-null return.

org_models Filter by the membership of the organization where the current user belongs. The member collection may include the current user himself. If the page only wants to display "models shared with me by other members", the current user also needs to be excluded based on created_by.

Filter, Search, Sort and Field Clipping​

ParametersDescription
publicityFilter exactly by one of three valid visibility ranges; invalid values are ignored
typeRefine filtering by workspace type
group_idOnly used for query_type=my_models (default range); default filters the default group, and UUID filters the self-created group. If not passed, it means all
searchDo a case-insensitive include search in names and descriptions
search_nameDo a case-insensitive include search in names
search_descriptionDo a case-insensitive include search in the description
orderingComma-separated sort fields; preceded by - for descending order
fieldsComma separated response fields to avoid returning unnecessarily large snapshots
count_only=trueOnly return the quantity that meets the conditions and do not return paginated results.

When search_name and search_description appear together, there is an "OR" between them; if search is also provided, there is an "AND" between the general search condition and this set of field conditions.

The sortable fields are id , name , description , publicity , type , created_at , updated_at and is_delete , each field can use - prefix. When there is no ordering, the default is updated_at descending order; invalid sorting items will be ignored. The normal list itself only contains records for is_delete=false, so sorting by is_delete usually doesn't make sense.

fields can only retain fields that already exist in the model response, unknown fields will not fail the request. You can usually use fields=id,name,description,publicity,type,updated_at,created_by_username on the list page, and then read the details when you really want to open the model to avoid repeatedly transmitting current_snapshot on each page.

Pagination and Responsiveness​

The default value of page is 1. If it is smaller than 1, it will be processed as 1. page_size defaults to 20, and the valid range is 1 to 100; invalid values return to 20. Page numbers exceeding the last page will be converged to the last page.

{
"message": "获取模型列表成功",
"code": 0,
"data": {
"results": [
{
"id": "1d02d62a-7444-4c41-9b10-5f81609e79c7",
"name": "示例模型",
"type": "liquid_demo",
"publicity": "private",
"updated_at": "2026-08-29 10:20:30"
}
],
"pagination": {
"current_page": 1,
"page_size": 20,
"total_pages": 1,
"total_count": 1,
"has_next": false,
"has_previous": false
}
}
}

When using count_only=true, data is changed to {"count": 1}, and results and pagination are no longer included.

Personal Model Grouping​

Groups are only visible and manageable by the user. Different workstations of the same user share the same set of groups. The default group ID is null and cannot be renamed or deleted. Personal grouping and Workbench configuration Grouping of typical calculation examples are independent of each other.

Query and Maintain Groups​

GET /api/models/groups/?type=liquid_demo

type is optional. It only limits the range of quantity statistics and does not count all types. Response data is a grouped array, including empty groups; the default group is at the top, self-built groups are arranged by creation time, count only counts undeleted calculation cases:

[
{"id": null, "name": "默认分组", "is_default": true, "count": 2, "created_at": null},
{"id": "70000000-0000-4000-8000-000000000001", "name": "项目 A", "is_default": false, "count": 1, "created_at": "2026-11-02 10:00:00"}
]

POST /api/models/groups/ is used for creation, PUT /api/models/groups/{group_id}/ is used for renaming, {"name": "项目 A"} is submitted, and the group object is returned successfully. The name must be 1-50 characters after removing leading and trailing spaces. It is not case-sensitive within the same user. "Default Group" or "All Calculation Examples" cannot be used.

Remove using DELETE /api/models/groups/{group_id}/. The calculation cases in the group (including soft-deleted records) are moved back to the default group, and the calculation cases themselves will not be deleted; in response to data.moved_count, only the calculation cases that have not been deleted are counted.

Batch Adjustment of Attribution​

POST /api/models/move-group/
Content-Type: application/json

{"model_ids": ["1d02d62a-7444-4c41-9b10-5f81609e79c7"], "group_id": "70000000-0000-4000-8000-000000000001"}

Both fields are required: model_ids is the non-empty UUID array of the calculation examples that I have not deleted; group_id is my group UUID. Passing null means moving back to the default group. If the entire batch operation is successful or the entire batch fails, data.moved_count will be returned successfully. Only adjusting the attribution does not create a snapshot, nor does it change existing computing jobs.

HTTP 400 is returned if the name or request parameter is invalid; HTTP 404 is returned when the group or batch calculation example does not exist, has been deleted, or has no access rights.

Create the Model and First Snapshot​

POST /api/models/
Content-Type: application/json
Authorization: Bearer <access-token>

The optional field group_id is used to specify the personal group; when omitted or null is passed, it is classified into the default group.

It is recommended to clearly commit the name, public scope, workspace type and non-empty snapshot_data when creating:

{
"name": "示例模型",
"description": "用于接口联调",
"publicity": "private",
"type": "liquid_demo",
"snapshot_data": {
"schemaVersion": 2,
"global": {},
"viewOptions": {},
"sheets": [
{
"id": "sheet_0",
"name": "图纸1",
"nodes": [],
"edges": []
}
]
}
}

The empty diagram in the example is only used to illustrate the request structure and may not meet the business verification rules of the target workspace. Actual integrations should submit drafts generated by this space or built as defined by it.

After successful creation, the platform generates the model UUID; if a valid and non-empty snapshot_data is submitted, a model snapshot is also created and set as the current snapshot. If this field is omitted, the model can temporarily have no current snapshot. To avoid leaving an empty record that cannot be opened or run directly, you should usually verify the draft before creating the model with the first snapshot.

The model save interface checks the underlying graph structure of the snapshot. The legacy single-graph structure is currently supported, as is the multi-graph structure of schemaVersion: 2; new clients should generate version 2. The platform saves data in the submitted form, and reading the old structure will not automatically rewrite the content in the database to version 2.

Read and Update Models​

Read details:

GET /api/models/{model_id}/
Authorization: Bearer <access-token>

The response uses a generic wrapper and the model object is located at data. Where current_snapshot is directly snapshot data; it does not contain resource metadata such as snapshot UUID, creation time, or creator. If the model has not saved a snapshot, this field is null.

Update model:

PUT /api/models/{model_id}/
Content-Type: application/json
Authorization: Bearer <access-token>

Currently PUT is processed as a partial update and uncommitted fields remain unchanged. Although it allows only one field to be submitted, the path and method are still PUT , don't use the non-existent PATCH instead:

{
"name": "示例模型(已复核)"
}

Submit group_id when modifying the belonging group: retain the current belonging when omitted, and move back to the default group when passing null.

Simply updating the name, description, visibility, or group will not create a new snapshot. When a valid and non-empty snapshot_data is included in the request, the platform performs the following operations:

  1. Verify the basic JSON and graph structure of the snapshot;
  2. Create a new model snapshot record;
  3. Point the model's current_snapshot to the new snapshot;
  4. Keep the old snapshot content unchanged.

The model interface does not have an operation to update existing snapshots. Old snapshots may still be stored by the platform, but there is currently no public history list and rollback interface, and clients cannot treat it as self-recoverable version history.

When updating, only the metadata and draft content that must be modified this time are sent. Sending a complete model object copied from the old response may overwrite the name, description, or exposure scope that was just modified by another client back to the old value.

Do Unified Model Verification First​

Model creation and update only perform snapshot infrastructure checks; connection relationships, component parameters and workspace rules need to call the unified verification interface:

POST /api/models/validate/
Content-Type: application/json
Authorization: Bearer <access-token>
{
"workspace_type": "liquid_demo",
"snapshot_data": {
"schemaVersion": 2,
"global": {},
"viewOptions": {},
"sheets": [
{
"id": "sheet_0",
"name": "图纸1",
"nodes": [],
"edges": []
}
]
}
}

This interface confirms that the workspace exists, that the current user has permission to access the space, and calls unified rules to check the draft. It does not create or update models, nor does it generate snapshots. HTTP 200 is returned when the verification service is completed normally; when the draft does not comply with the business rules, it may still be valid: false in the successful response:

{
"message": "模型校验完成",
"code": 0,
"data": {
"valid": false,
"counts": {
"error": 1,
"warning": 0,
"info": 0
},
"issues": [
{
"severity": "error",
"code": "parameter.constraint",
"message": "参数不满足当前工作台空间的约束",
"scope": "parameter",
"path": "sheets.sheet_0.nodes.source_1.data.Pressure",
"sheet_id": "sheet_0",
"element_id": "source_1",
"component_class_id": "Source",
"parameter_key": "Pressure"
}
]
}
}

The client should use data.valid to decide whether to continue, rather than just looking at HTTP 200 or code: 0. counts summarizes issues at all levels, and issues is a list of specific issues; the specific issue fields are returned by the current validator, and the client should tolerate new fields.

If the request body or space type is invalid, 400 will be returned. If there is no space access permission, 403 will be returned. If the verification service is unavailable, 503 will be returned. If the verification timeout occurs, 504 will be returned. These service errors cannot be considered "verification passed".

The recommended writing order is:

  1. Use the same snapshot_data to be saved to call unified verification;
  2. Submit creation or update only at valid: true;
  3. After successful saving, record id and updated_at in the model response;
  4. When confirmation is needed, re-read the details and compare with the current snapshot.

Verify and save are two independent requests, and they are not currently encapsulated into a single transaction. If the workspace definition changes between the two requests, successful saving does not prove that the draft still conforms to the new definition. Accepting the infrastructure of the job creation interface does not mean that the business verification has passed; the caller using the HTTP API directly should explicitly perform unified verification before creating the job.

Soft Delete and Recovery​

Delete a model:

DELETE /api/models/{model_id}/
Authorization: Bearer <access-token>

The delete operation simply marks the model as deleted. Normal lists and details no longer return it afterward, but this does not automatically delete jobs and results that have already been created.

Recovery model:

POST /api/models/{model_id}/restore/
Authorization: Bearer <access-token>

The recovery interface only searches for soft-deleted models, and upon success returns the complete model object after recovery. The current common model list does not provide "deleted model" query, nor does it have a permanent deletion interface; if the business process needs to be restored, the model UUID should be reliably saved before deletion, or it should be obtained through the management and audit process provided by the platform.

Recovery still requires write permission. The current recovery path uses a unified exception response for partial failures, and clients should not assume that all "no permission" and "not present" conditions will necessarily return some fixed 4xx status; both the HTTP status and the response body should be checked.

Read Job Freeze Snapshot​

Continuing to save the model will not change the jobs that have been created. When you need to view the actual input used by a job, read the job freeze snapshot:

GET /api/jobs/{job_id}/snapshot/
Authorization: Bearer <access-token>

Successful response:

{
"message": "获取任务快照成功",
"code": 0,
"data": {
"job_id": "03f83fef-c19d-485e-9777-7e86ace8514e",
"snapshot_id": "b6cf3cc9-fbfe-4d92-9474-79456395acbf",
"snapshot": {
"graph": {},
"definition": {}
}
}
}

snapshot_id is the UUID of the snapshot referenced by the job; snapshot.graph is the graph frozen when the job was created, and snapshot.definition is the component definition used by this job. They do not change with subsequent modifications to the source model or workspace.

Job snapshots are judged by job permissions: they can be read by job creators, super administrators, and organization administrators who manage the job creator's organization. Making the source model public or public within the organization does not automatically grant other users permission to read the job snapshot.

When the job snapshot is regularly cleaned or the association has expired, the interface returns HTTP 410 and returns the current job_id, snapshot_id: null and snapshot: null in data. This means that the job record still exists, but the frozen input is irrecoverable and cannot be resolved by retrying.

This interface is not a model snapshot history interface, nor can it be used to find the previous version of a model. For the application, reading and recovery startup methods of running status snapshot, see Job, Control, and Result APIs.

Don'T Confuse Response Encapsulation with Snapshot Content​

The model list, model details, creation, update, recovery, unified verification, and job freezing snapshot interfaces involved in this page all use message, code, and data general packages. They do not directly return a bare model graph at the top of the response.

What is easily confusing is that current_snapshot in the model object itself directly saves the graph JSON, rather than another snapshot resource package with id and data; the job interface puts the frozen content under data.snapshot and returns snapshot_id at the same time.

For example, when GET /api/jobs/case-file/{task_id} is successful, the calculation example JSON is directly returned without using general encapsulation; it is a job resource and the response form of the model interface cannot be inferred based on it. See Job, Control, and Result APIs for specific differences.

Handling Concurrent Saves​

The current model interface does not have ETags, conditional updates, version numbers, or server-side optimistic locking. When two clients start editing at the same current_snapshot and proceed to PUT, a new snapshot is created every time the content is saved, but the last successful request becomes the current snapshot of the model. The platform does not automatically merge the two drafts.

Although the old snapshot has not been overwritten in place, the client cannot rely on unpublished snapshot records to roll back on its own. It is recommended that the integrator adopts the following protections:

  1. Save updated_at and the current draft when loading the model;
  2. Re-read the model before submission. As long as updated_at has changed, the save will be suspended and manual comparison will be prompted;
  3. PUT Only sends the fields to be modified this time to avoid overwriting other metadata with the old complete model object;
  4. The background integration writes serially to the same model UUID;
  5. After saving, re-read the details to confirm that updated_at and current_snapshot are as expected.

Comparing updated_at before committing only narrows the conflict window, not a server-side lock: another update may still occur between the read and the write. If the business must ensure strict conditions for writing, a clear concurrency control protocol needs to be added to the platform interface layer, and it cannot just rely on client agreement.

Minimal Curl Process​

The following command uses jq to assemble JSON to avoid writing the token, account or model content in the script. First prepare environment variables and a draft file:

export NEXUSFLOW_BASE_URL="https://nexusflow.example.com"
export NEXUSFLOW_ACCESS_TOKEN="<access-token>"
export NEXUSFLOW_WORKSPACE_TYPE="liquid_demo"
export NEXUSFLOW_MODEL_NAME="接口联调模型"
export NEXUSFLOW_SNAPSHOT_FILE="./draft.json"

List your own models without returning the snapshot body:

curl --fail-with-body --get \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
-H "Accept: application/json" \
--data-urlencode "query_type=my_models" \
--data-urlencode "type=${NEXUSFLOW_WORKSPACE_TYPE}" \
--data-urlencode "ordering=-updated_at" \
--data-urlencode "fields=id,name,type,publicity,updated_at" \
--data-urlencode "page=1" \
--data-urlencode "page_size=20" \
"${NEXUSFLOW_BASE_URL%/}/api/models/"

Check draft.json:

jq -n \
--arg workspace_type "${NEXUSFLOW_WORKSPACE_TYPE}" \
--slurpfile snapshot "${NEXUSFLOW_SNAPSHOT_FILE}" \
'{workspace_type: $workspace_type, snapshot_data: $snapshot[0]}' |
curl --fail-with-body \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
--data-binary @- \
"${NEXUSFLOW_BASE_URL%/}/api/models/validate/"

After confirming that data.valid in the response is true, create the model:

jq -n \
--arg name "${NEXUSFLOW_MODEL_NAME}" \
--arg type "${NEXUSFLOW_WORKSPACE_TYPE}" \
--slurpfile snapshot "${NEXUSFLOW_SNAPSHOT_FILE}" \
'{
name: $name,
description: "通过 HTTP API 创建",
publicity: "private",
type: $type,
snapshot_data: $snapshot[0]
}' |
curl --fail-with-body \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
--data-binary @- \
"${NEXUSFLOW_BASE_URL%/}/api/models/"

Get the model UUID from the response data.id before setting the variable. Do not deduce it from the model name:

export NEXUSFLOW_MODEL_ID="<model-uuid>"

curl --fail-with-body \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
-H "Accept: application/json" \
"${NEXUSFLOW_BASE_URL%/}/api/models/${NEXUSFLOW_MODEL_ID}/"

Update model content still uses PUT. The following request only updates the current snapshot, without duplicating the commit name and visibility:

jq -n \
--slurpfile snapshot "${NEXUSFLOW_SNAPSHOT_FILE}" \
'{snapshot_data: $snapshot[0]}' |
curl --fail-with-body -X PUT \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
--data-binary @- \
"${NEXUSFLOW_BASE_URL%/}/api/models/${NEXUSFLOW_MODEL_ID}/"

Delete and restore:

curl --fail-with-body -X DELETE \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
"${NEXUSFLOW_BASE_URL%/}/api/models/${NEXUSFLOW_MODEL_ID}/"

curl --fail-with-body -X POST \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
"${NEXUSFLOW_BASE_URL%/}/api/models/${NEXUSFLOW_MODEL_ID}/restore/"

Read job freeze snapshot:

export NEXUSFLOW_JOB_ID="<job-uuid>"

curl --fail-with-body \
-H "Authorization: Bearer ${NEXUSFLOW_ACCESS_TOKEN}" \
-H "Accept: application/json" \
"${NEXUSFLOW_BASE_URL%/}/api/jobs/${NEXUSFLOW_JOB_ID}/snapshot/"

Security Verification Before Release​

  • Use HTTPS and put the access token in the Authorization request header; do not write URLs, source code, model JSON, or logs.
  • Treat the model UUID, job UUID and snapshot UUID as opaque identifiers, verify the format first, and then let the server determine resource ownership and permissions.
  • Before exposing the model, check whether scripts, tables, text parameters, and descriptions contain account numbers, network addresses, credentials, or business-sensitive data.
  • Do not regard publicity, list query range, or workspace type as authorization results that the client can determine by itself.
  • Perform unified verification before creation and saving; process valid: false, 403, 503 and 504 separately, and cannot run them directly after failure.
  • Lists use fields on demand to avoid unintentional downloading and recording of large amounts of current_snapshot content.
  • Perform serial control on the writing of the same model, and check updated_at before and after saving to make it clear that the current interface still has the risk of being overwritten by the last write.
  • Preserve model UUIDs before soft deletion; do not assume there are undocumented history, rollback, or permanent deletion interfaces.
  • Job freeze snapshots are only used to restore job inputs; running snapshots and job results are processed as Job, Control, and Result APIs.