Data Models

This section describes the data models used in the Dify client.

App Token

class AppToken

Represents an API token for an application.

id: str

Unique identifier for the token

type: Literal["app"]

Token type, always “app”

token: str

The actual token string

last_used_at: Optional[int]

Timestamp of last usage

created_at: int

Timestamp of creation

Workflow Models

class WorkflowDraft

Represents a workflow configuration draft.

graph: Optional[Graph]

The workflow graph structure

features: dict

Feature configuration

environment_variables: list

Environment variables used in the workflow

conversation_variables: list

Conversation variables used in the workflow

Graph Models

class Graph

Represents the complete workflow graph structure.

nodes: list[GraphNode]

List of nodes in the graph

edges: list[GraphEdge]

List of edges connecting the nodes

viewport: Viewport

View configuration for the graph

class GraphNode

Represents a node in the workflow graph.

id: str

Unique identifier for the node

type: str

Node type

data: dict

Node configuration data

position: dict

Node position in the graph

targetPosition: str

Position of target connection point

sourcePosition: str

Position of source connection point

positionAbsolute: dict

Absolute position in the graph

width: int

Node width

height: int

Node height

class GraphEdge

Represents an edge connecting two nodes in the workflow graph.

id: str

Unique identifier for the edge

type: str

Edge type

source: str

Source node ID

sourceHandle: str

Source connection point

target: str

Target node ID

targetHandle: str

Target connection point

data: GraphEdgeData

Edge configuration data

zIndex: int

Z-index for rendering

class GraphEdgeData

Configuration data for graph edges.

sourceType: GraphNodeDataTypes

Type of the source node

targetType: GraphNodeDataTypes

Type of the target node

isInIteration: bool

Whether the edge is part of an iteration

class GraphNodeData

Configuration data for graph nodes.

type: GraphNodeDataTypes

Node type (start, end, or llm)

title: str

Node title

description: str

Node description

variables: list

List of variables used by the node

class Viewport

Graph view configuration.

x: Optional[int]

X coordinate of the viewport (default: 0)

y: Optional[int]

Y coordinate of the viewport (default: 0)

zoom: Optional[int]

Zoom level (default: 1)

Base Models

class BaseModel

Base model with common functionality for all data models.

id: str | None

Unique identifier

created_at: int | None

Creation timestamp

updated_at: int | None

Last update timestamp

to_dict() dict

Convert the model to a dictionary.

Returns:

Dictionary representation of the model

created_datetime -> Optional[datetime]

Get creation timestamp as datetime object.

Returns:

Datetime object or None

updated_datetime -> Optional[datetime]

Get update timestamp as datetime object.

Returns:

Datetime object or None

Pagination Models

class PaginatedResponse

Generic paginated response model.

page: int

Current page number

limit: int

Number of items per page

total: int

Total number of items

has_more: bool

Whether there are more pages

data: List[T]

List of items in the current page

__iter__() Iterator[T]

Make the response iterable over data items.

Returns:

Iterator over data items

__len__() int

Get the number of items in the current page.

Returns:

Number of items

Logging Models

class AgentConversation

Represents a single agent or chat conversation.

id: str

Unique identifier for the conversation

status: str

Current status of the conversation

from_source: str

Source from which the conversation originated

from_end_user_id: str | None

ID of the end user who started the conversation

from_end_user_session_id: str | None

Session ID of the end user

from_account_id: str | None

Account ID of the creator

from_account_name: str | None

Name of the account creator

name: str

Name of the conversation

summary: str

Summary of the conversation

read_at: int | None

Timestamp when the conversation was last read

created_at: int

Timestamp when the conversation was created

updated_at: int

Timestamp when the conversation was last updated

annotated: bool

Whether the conversation has been annotated

agent_model_config: Dict

Model configuration for the agent (aliased as “model_config” in API)

message_count: int

Number of messages in the conversation

user_feedback_stats: Dict

Statistics about user feedback

admin_feedback_stats: Dict

Statistics about admin feedback

status_count: Dict

Count of different statuses

class ChatMessage

Represents a single chat message in a conversation.

id: str

Unique identifier for the message

conversation_id: str

ID of the conversation this message belongs to

inputs: Dict[str, Any] | None

Input parameters provided with the message

query: str | None

The user’s query or question

answer: str | None

The assistant’s answer

message: Dict[str, Any] | None

Full message object with additional metadata

feedback: Dict[str, Any] | None

User feedback on the message

created_at: int

Timestamp when the message was created

created_by_role: str | None

Role of the user who created the message

created_by_account: Dict[str, Any] | None

Account information of the creator

created_by_end_user: Dict[str, Any] | None

End user information

from_source: str | None

Source from which the message originated

from_end_user_id: str | None

ID of the end user

from_end_user_session_id: str | None

Session ID of the end user

from_account_id: str | None

Account ID of the creator

from_account_name: str | None

Name of the account creator

class PaginatedChatMessages

Paginated response containing chat messages.

Inherits from PaginatedResponse with ChatMessage as the item type.

data: List[ChatMessage]

List of chat messages in the current page

page: int

Current page number

limit: int

Number of items per page

total: int

Total number of items

has_more: bool

Whether there are more pages available

class PaginatedAgentLogs

Paginated response containing agent conversation logs.

Inherits from PaginatedResponse with AgentConversation as the item type.

data: List[AgentConversation]

List of conversations in the current page

page: int

Current page number

limit: int

Number of items per page

total: int

Total number of items

has_more: bool

Whether there are more pages available

class PaginatedWorkflowLogs

Paginated response containing workflow execution logs.

Inherits from PaginatedResponse with WorkflowLogEntry as the item type.

data: List[WorkflowLogEntry]

List of workflow log entries in the current page

page: int

Current page number

limit: int

Number of items per page

total: int

Total number of items

has_more: bool

Whether there are more pages available

Workflow Execution Models

class WorkflowNodeExecutionMetadata

Metadata about workflow node execution.

parallel_id: str | None

ID for parallel execution

parallel_start_node_id: str | None

ID of the starting node in parallel execution

tool_info: Dict[str, Any] | None

Information about tools used

total_tokens: int | None

Total tokens used

total_price: str | None

Total price of execution

currency: str | None

Currency for the price

class WorkflowNodeExecutions

Container for a list of node executions.

data: List[WorkflowNodeExecution]

List of node executions