Documentation
WorkflowsNEW

Workflow Resources

Workflow-scoped resources — types, configuration, per-type reference, and workflow file parameters.

1. Concepts and Identifiers

What Is a Resource? A workflow resource is a workflow-scoped configuration object (connection settings, uploaded files, or ephemeral file state) that nodes can reuse at run time. Credentials and shared settings live in one place instead of being duplicated on every node.

You will encounter two main identifiers:

IdentifierMeaning
resource_idUser-chosen string, unique within the workflow. Nodes reference this value in their parameters (per component conventions).
resource_typeRegistry key for the implementation (for example database, s3). Must match a key in registered_resources in api/apps/utils/SandsFlow/components/__init__.py.

2. Resource Catalog

All types below are registered in SandsFlow.

Type ID (resource_type)Display NameTypical Use
temporary_fileTemporary FileRun-scoped temp files; file uploads via workflow parameters; access by generated file ID.
persistent_filePersistent FileDesign-time uploads stored under the workflow folder; nodes resolve paths by file_id.
databaseDatabase (PostgreSQL/MySQL)SQL connections, queries, transactions.
mongodbMongoDBDocument CRUD operations.
redisRedisKey/value get/set and related commands.
s3Amazon S3Object storage (AWS or S3-compatible via optional endpoint).
azure_blobAzure Blob StorageBlobs in a default or per-call container.
rabbitmqRabbitMQPublish/consume, declare queues and exchanges.
kafkaApache KafkaProduce/consume topics, list topics.
minioMinIOS3-compatible object storage.
nextcloudNextcloudFiles via WebDAV-style API (upload, download, list, delete, exists).

3. Set Up Resource

In the workflow graph editor, open Workflow Resources from the left sidebar: click the + (plus) on the right side of the Resources row (next to the resource count).

Workflow editor sidebar: Resources row with expand chevron, label, count badge, and plus button to open Workflow Resources

That opens the Workflow Resources dialog, where you set Resource ID, Resource Type, any extra fields for the chosen type, and Add Resource.

Workflow Resources dialog: Resource ID and Resource Type fields, Update Resource, and Resource Info for Temporary File with create expanded (filename param) and other functions listed

Selecting a Resource Type updates the Resource Info panel with that resource’s metadata: a short description and the Resource Functions you can use with that resource. Expand a function to see its parameters and return type.


4. Per-Type Reference

For each type: Configuration lists config_schema fields shown in the editor. Runtime Functions are the methods exposed to node code (metadata functions); at execution time they are invoked on a wrapper that injects internal context. Each function row lists Description, Params, and Returns.

4.1 temporary_file — Temporary File

Description: Creates and manages temporary files for the duration of a workflow run. Files are tracked by a file_id (UUID). Typical uses: scratch output, intermediate artifacts, and workflow file parameters (the engine registers uploads against the matching temporary_file resource before nodes run). For how the SandsBytes node uses temporary_file for HTTP file parameters (resource id vs file_id), see SandsBytes workflow node — user guide.

Configuration (config_schema): None (empty). No extra fields in the resource form beyond Resource ID and Resource Type.

Runtime Functions:

FunctionDescriptionParamsReturns
createCreate a new empty temporary file and register it.
  • filename (string, required) — basename only (for example report.csv); path separators are rejected
  • stringfile_id (UUID)
openOpen a file by file_id.
  • file_id (string, required)
  • mode (string, optional) — e.g. r, w, a, rb, wb; defaults to r if omitted (the designer metadata may still list mode as required)
  • file_object — usable with a with statement
deleteRemove the file from disk and drop it from tracking.
  • file_id (string, required)
  • booleantrue if the id was known; false otherwise. Disk removal errors are swallowed, but the entry is still removed from state when the id was known
listList files tracked for this resource in the current run.
  • None
  • array — objects with file_id and filename
get_pathAbsolute filesystem path for a file_id.
  • file_id (string, required)
  • string — path. Prefer open in nodes; use get_path when an external tool needs a path. Raises FileNotFoundError if the id is unknown or the file is missing on disk

Behavior: duplicate filenames in the same temporary resource raise FileExistsError. create writes an empty file (text-mode touch); use open(..., "wb") (or other modes) when you need binary or overwrite semantics.

Note

Temporary files for this resource are deleted when the workflow finishes (success or failure): lifecycle hooks remove all tracked files for that resource (same as calling delete for each). Do not rely on temp files after the run ends; copy anything you must keep to a persistent store or persistent_file resource.

Note

One temporary_file resource can store many files in the same run; each file has its own file ID. Create files with create (or rely on engine injection for uploads), and use list to see what this resource is tracking.

Example:

def main(args, resources):
    tmp = resources.get("scratch")
    file_id = tmp.create("hello.txt")
    with tmp.open(file_id, mode="w") as f:
        f.write("hello")
    with tmp.open(file_id, mode="r") as f:
        content = f.read()
    return {"file_id": file_id, "content": content, "listed": tmp.list()}

4.2 persistent_file — Persistent File

Description: Stores one or more files at design time (uploads in the resource editor). At run time you address each file by file_id (UUID) stored in config.files (the id field on each file entry). You may also create empty files at run time; they are appended to the in-memory config.files list for that execution (whether that survives beyond the run depends on how your deployment persists workflow definitions).

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
filesFilesfile (multiple)NoUpload one or more files; each entry gets an id (file_id) for use in nodes.

Runtime Functions:

FunctionDescriptionParamsReturns
createCreate an empty persistent file on disk and register metadata.
  • filename (string, required) — basename only; path separators rejected
  • string — new file_id. Requires workflow_id (injected by the wrapper)
deleteRemove the file from disk and from config.files.
  • file_id (string, required)
  • booleantrue if an entry was removed, else false
listList file entries known to this resource.
  • None
  • array — objects from config.files (each normally includes id and filename)
get_pathAbsolute path for a known file_id.
  • file_id (string, required)
  • string — path. Raises ValueError if the id is not in config.files, FileNotFoundError if the path is missing
openOpen by file_id.
  • file_id (string, required)
  • mode (string, optional) — default rb; common values: rrbwwb
  • file_object — open file handle

Example:

def main(args, resources):
    docs = resources.get("policy_pdfs")
    file_id = "your-file-id-from-resource-config"
    path    = docs.get_path(file_id)
    with docs.open(file_id, mode="rb") as f:
        data = f.read()
    return {"path": path, "size": len(data)}

4.3 database — Database (PostgreSQL/MySQL)

Description: Connect to PostgreSQL or MySQL databases. Execute queries, fetch results, and manage transactions.

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
db_typeDatabase TypeselectYespostgresqlpostgresql or mysql.
hostHosttextYeslocalhostDatabase host.
portPortnumberYes5432Port (5432 PostgreSQL, 3306 MySQL).
databaseDatabase NametextYesDatabase name.
usernameUsernametextYesDB user.
passwordPasswordtextYesDB password.
ssl_modeSSL ModeselectNodisabledisable, require, verify-ca, verify-full (PostgreSQL-oriented).

Runtime Functions:

FunctionDescriptionParamsReturns
connectEstablish a connection to the database.
  • None
  • booleantrue if the connection succeeds
closeClose the database connection.
  • None
  • booleantrue if closed successfully
executeExecute a SQL statement (for example INSERT, UPDATE, DELETE).
  • query (string, required)
  • params (array, optional) — values for a parameterized query
  • integer — number of affected rows
fetch_oneRun a SELECT and fetch a single row.
  • query (string, required)
  • params (array, optional) — values for a parameterized query
  • dict — one row as a dictionary, or None
fetch_allRun a SELECT and fetch all rows.
  • query (string, required)
  • params (array, optional) — values for a parameterized query
  • array — list of rows as dictionaries
commitCommit the current transaction.
  • None
  • booleantrue if committed successfully
rollbackRoll back the current transaction.
  • None
  • booleantrue if rolled back successfully

Example:

def main(args, resources):
    db = resources.get("orders_db")
    db.connect()
    try:
        rows = db.fetch_all(
            "SELECT id, name FROM customers WHERE active = %s",
            [True],
        )
        return {"customer_count": len(rows), "sample": rows[:5]}
    finally:
        db.close()

4.4 mongodb — MongoDB

Description: Connect to MongoDB databases. Insert, find, update, and delete documents.

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
hostHosttextYeslocalhostMongoDB host.
portPortnumberYes27017Port.
databaseDatabase NametextYesDatabase name.
usernameUsernametextNoOptional user.
passwordPasswordtextNoOptional password.
auth_sourceAuthentication DatabasetextNoadminAuth DB.

Runtime Functions:

FunctionDescriptionParamsReturns
connectEstablish a connection to MongoDB.
  • None
  • booleantrue if the connection succeeds
closeClose the MongoDB connection.
  • None
  • booleantrue if closed successfully
insert_oneInsert a single document into a collection.
  • collection (string, required)
  • document (dict, required)
  • string — inserted document ID
insert_manyInsert multiple documents into a collection.
  • collection (string, required)
  • documents (array, required)
  • array — inserted document IDs
find_oneFind a single document in a collection.
  • collection (string, required)
  • filter (dict, optional) — query filter (default empty dict)
  • dict — found document, or None
find_manyFind multiple documents in a collection.
  • collection (string, required)
  • filter (dict, optional)
  • limit (number, optional)
  • array — list of found documents
update_oneUpdate a single document in a collection.
  • collection (string, required)
  • filter (dict, required)
  • update (dict, required) — use $set, $unset, etc.
  • integer — number of modified documents
delete_oneDelete a single document from a collection.
  • collection (string, required)
  • filter (dict, required)
  • integer — number of deleted documents

Example:

def main(args, resources):
    mongo = resources.get("app_mongo")
    mongo.connect()
    try:
        inserted_id = mongo.insert_one("items", {"name": "demo", "count": 1})
        doc         = mongo.find_one("items", {"name": "demo"})
        return {"inserted_id": inserted_id, "doc": doc}
    finally:
        mongo.close()

4.5 redis — Redis

Description: Connect to Redis servers. Get, set, and manage key-value pairs.

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
hostHosttextYeslocalhostRedis host.
portPortnumberYes6379Port.
passwordPasswordtextNoOptional password.
dbDatabase NumbernumberNo0DB index (0–15).
sslUse SSLswitchNofalseEnable SSL.

Runtime Functions:

FunctionDescriptionParamsReturns
connectEstablish a connection to Redis.
  • None
  • booleantrue if the connection succeeds
closeClose the Redis connection.
  • None
  • booleantrue if closed successfully
getGet a value by key.
  • key (string, required)
  • string — value for the key, or None
setSet a key-value pair.
  • key (string, required)
  • value (string, required)
  • ttl (number, optional) — time to live in seconds
  • booleantrue if set successfully
deleteDelete a key.
  • key (string, required)
  • integer — number of keys deleted
existsCheck if a key exists.
  • key (string, required)
  • booleantrue if the key exists
keysGet keys matching a pattern.
  • pattern (string, optional) — default *
  • array — matching keys

Example:

def main(args, resources):
    cache = resources.get("my_redis")
    cache.connect()
    try:
        cache.set("last_run", str(args.get("run_key", "")))
        value = cache.get("some_key")
        return {"cached": value}
    finally:
        cache.close()

4.6 s3 — Amazon S3

Description: Connect to Amazon S3. Upload, download, and manage objects in buckets (optional custom endpoint for S3-compatible services).

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
access_key_idAccess Key IDtextYesAWS access key.
secret_access_keySecret Access KeytextYesAWS secret key.
regionRegiontextYesus-east-1AWS region.
endpoint_urlEndpoint URLtextNoCustom endpoint (optional).

Runtime Functions:

FunctionDescriptionParamsReturns
connectValidate S3 credentials and establish a client connection.
  • None
  • booleantrue if the connection succeeds
uploadUpload an object to S3.
  • bucket (string, required)
  • key (string, required)
  • data (string, required) — string or bytes
  • content_type (string, optional)
  • booleantrue if upload succeeds
downloadDownload an object from S3.
  • bucket (string, required)
  • key (string, required)
  • string — object content
deleteDelete an object from S3.
  • bucket (string, required)
  • key (string, required)
  • booleantrue if delete succeeds
list_objectsList objects in a bucket.
  • bucket (string, required)
  • prefix (string, optional)
  • array — object keys
existsCheck if an object exists in S3.
  • bucket (string, required)
  • key (string, required)
  • booleantrue if the object exists

Example:

def main(args, resources):
    store = resources.get("my_s3")
    store.connect()
    store.upload("my-bucket", "workflow/output.txt", "hello", content_type="text/plain")
    body = store.download("my-bucket", "workflow/output.txt")
    return {"body": body}

4.7 azure_blob — Azure Blob Storage

Description: Connect to Azure Blob Storage. Upload, download, and manage blobs in containers (default container in config).

Configuration (config_schema):

Field IDLabelTypeRequiredDescription
account_nameAccount NametextYesStorage account name.
account_keyAccount KeytextYesAccount key.
containerContainer NametextYesDefault container.

Runtime Functions:

FunctionDescriptionParamsReturns
connectValidate Azure Blob credentials and establish a client connection.
  • None
  • booleantrue if the connection succeeds
uploadUpload a blob.
  • container (string, optional) — overrides default container from config
  • blob_name (string, required)
  • data (string, required) — string or bytes
  • content_type (string, optional)
  • booleantrue if upload succeeds
downloadDownload a blob.
  • container (string, optional)
  • blob_name (string, required)
  • string — blob content
deleteDelete a blob.
  • container (string, optional)
  • blob_name (string, required)
  • booleantrue if delete succeeds
list_blobsList blobs in a container.
  • container (string, optional)
  • prefix (string, optional)
  • array — blob names
existsCheck if a blob exists.
  • container (string, optional)
  • blob_name (string, required)
  • booleantrue if the blob exists

Example:

def main(args, resources):
    blob = resources.get("azure_reports")
    blob.connect()
    blob.upload("daily-report.json", '{"ok": true}', content_type="application/json")
    text = blob.download("daily-report.json")
    return {"text": text}

4.8 rabbitmq — RabbitMQ

Description: Connect to RabbitMQ brokers. Publish and consume messages from queues.

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
hostHosttextYeslocalhostBroker host.
portPortnumberYes5672AMQP port.
usernameUsernametextYesguestUser.
passwordPasswordtextYesguestPassword.
vhostVirtual HosttextNo/vhost.

Runtime Functions:

FunctionDescriptionParamsReturns
connectEstablish a connection to RabbitMQ.
  • None
  • booleantrue if the connection succeeds
closeClose the RabbitMQ connection.
  • None
  • booleantrue if closed successfully
publishPublish a message to an exchange.
  • exchange (string, required)
  • routing_key (string, required)
  • message (string, required)
  • booleantrue if published successfully
consumeConsume messages from a queue (returns the first message).
  • queue (string, required)
  • auto_ack (boolean, optional) — default false
  • dict — message with body and properties, or None
declare_queueDeclare a queue.
  • queue (string, required)
  • durable (boolean, optional) — default false
  • booleantrue if declared successfully
declare_exchangeDeclare an exchange.
  • exchange (string, required)
  • exchange_type (string, required) — direct, topic, fanout, headers, …
  • booleantrue if declared successfully

Example:

def main(args, resources):
    mq = resources.get("my_amqp")
    mq.connect()
    try:
        mq.declare_queue("workflow_jobs", durable=True)
        mq.publish("", "workflow_jobs", '{"task": "ping"}')
        msg = mq.consume("workflow_jobs", auto_ack=True)
        return {"message": msg}
    finally:
        mq.close()

4.9 kafka — Apache Kafka

Description: Connect to Apache Kafka brokers. Produce and consume messages from topics.

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
bootstrap_serversBootstrap ServerstextYeslocalhost:9092Comma-separated brokers.
security_protocolSecurity ProtocolselectNoPLAINTEXTPLAINTEXT, SSL, SASL_PLAINTEXT, SASL_SSL.
sasl_mechanismSASL MechanismselectNoPLAINPLAIN, SCRAM-SHA-256, SCRAM-SHA-512.
sasl_usernameSASL UsernametextNoIf using SASL.
sasl_passwordSASL PasswordtextNoIf using SASL.

Runtime Functions:

FunctionDescriptionParamsReturns
connectEstablish a connection to Kafka.
  • None
  • booleantrue if the connection succeeds
closeClose the Kafka producer/consumer/admin clients.
  • None
  • booleantrue if closed successfully
produceProduce a message to a topic.
  • topic (string, required)
  • message (string, required)
  • key (string, optional)
  • booleantrue if produced successfully
consumeConsume messages from a topic.
  • topic (string, required)
  • group_id (string, required)
  • timeout (number, optional) — seconds; default 1
  • array — message dicts with value and key
list_topicsList all available topics.
  • None
  • array — topic names

Example:

def main(args, resources):
    k = resources.get("my_kafka")
    k.connect()
    try:
        k.produce("events", "hello-from-workflow", key="run-1")
        batch = k.consume("events", "python_code_group", timeout=1)
        return {"messages": batch[:5]}
    finally:
        k.close()

4.10 minio — MinIO

Description: Connect to MinIO object storage. Upload, download, and manage objects in buckets (S3-compatible API).

Configuration (config_schema):

Field IDLabelTypeRequiredDefaultDescription
endpointEndpointtextYeslocalhost:9000host:port.
access_keyAccess KeytextYesAccess key.
secret_keySecret KeytextYesSecret key.
secureUse HTTPSswitchNofalseUse TLS.

Runtime Functions:

FunctionDescriptionParamsReturns
connectValidate MinIO credentials and establish a client connection.
  • None
  • booleantrue if the connection succeeds
uploadUpload an object to MinIO.
  • bucket (string, required)
  • object_name (string, required)
  • data (string, required) — string or bytes
  • content_type (string, optional)
  • booleantrue if upload succeeds
downloadDownload an object from MinIO.
  • bucket (string, required)
  • object_name (string, required)
  • string — object content
deleteDelete an object from MinIO.
  • bucket (string, required)
  • object_name (string, required)
  • booleantrue if delete succeeds
list_objectsList objects in a bucket.
  • bucket (string, required)
  • prefix (string, optional)
  • array — object names
existsCheck if an object exists in MinIO.
  • bucket (string, required)
  • object_name (string, required)
  • booleantrue if the object exists

Example:

def main(args, resources):
    store = resources.get("minio_store")
    store.connect()
    store.upload("my-bucket", "runs/output.bin", b"\x00\x01", content_type="application/octet-stream")
    body = store.download("my-bucket", "runs/output.bin")
    return {"body": body}

4.11 nextcloud — Nextcloud

Description: Connect to Nextcloud servers. Upload, download, and manage files via WebDAV.

Configuration (config_schema):

Field IDLabelTypeRequiredDescription
urlNextcloud URLtextYesServer base URL (for example https://cloud.example.com).
usernameUsernametextYesUser name.
passwordPasswordtextYesPassword or app password.

Runtime Functions:

FunctionDescriptionParamsReturns
connectValidate Nextcloud credentials and establish a session.
  • None
  • booleantrue if the connection succeeds
uploadUpload a file to Nextcloud.
  • path (string, required) — for example /Documents/file.txt
  • data (string, required) — string or bytes
  • booleantrue if upload succeeds
downloadDownload a file from Nextcloud.
  • path (string, required)
  • string — file content
deleteDelete a file from Nextcloud.
  • path (string, required)
  • booleantrue if delete succeeds
list_filesList files in a directory.
  • path (string, optional) — default /
  • array — file and directory names
existsCheck if a file exists in Nextcloud.
  • path (string, required)
  • booleantrue if the file exists

Example:

def main(args, resources):
    nc = resources.get("team_nextcloud")
    nc.connect()
    nc.upload("/Workflows/hello.txt", "hello")
    content = nc.download("/Workflows/hello.txt")
    names   = nc.list_files("/Workflows/")
    return {"content": content, "names": names}

5. Workflow Parameters and File Uploads

If the workflow params schema includes a field with type: file, then:

  1. The field’s id must match a resource_id on the workflow’s resources list.

Configure Workflow Parameters, Visual Builder: a file-type field with Field ID temp_file and Field Type File; this id must match the temporary_file resource’s resource_id

  1. That resource must have resource_type temporary_file.

Workflow Resources dialog: Resource ID temp_file and Resource Type Temporary File (temporary_file), with resource functions listed in the info panel

def main(args, resources):
    res = resources.get("temp_file")

    return args

At run start, uploaded files for that parameter are written into the corresponding temporary file resource state (via TemporaryFileResource.create then open(..., "wb") in run_workflow), and the run params entry for that field becomes a list of file_id values (UUID strings).

Run Workflow dialog for Docs Example Workflow: required Temp File upload area (click to upload or drag and drop) before Start Execution

If the resource is missing or not temporary_file, run_workflow raises ValueError with an explicit message.