The Document API provides methods to create, read, update, and delete documents in Frappe.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/frappe/frappe/llms.txt
Use this file to discover all available pages before exploring further.
Getting documents
get_doc
Return a Document object.DocType name
Document name (optional for Single DocTypes)
Select document with FOR UPDATE clause for locking
Permission type to check (e.g., “read”, “write”). True checks “read” permission
Document object with all fields and child tables loaded
get_lazy_doc
Return a Document object without loading child tables. Child tables are loaded on access.DocType name
Document name
Select with FOR UPDATE clause
Permission type to check
get_cached_doc
Get a document from cache or database.DocType name
Document name
get_last_doc
Get the last created document of a DocType.DocType name
Additional filters
Creating documents
new_doc
Create a new document instance.DocType name
Return as dict instead of Document object
New document instance with default values
copy_doc
Create a copy of a document.Document to copy
Fields to exclude from copy
Document methods
insert
Insert the document into the database.Bypass permission checks
Skip mandatory field validation
Don’t raise error if duplicate
save
Update the document in the database.Bypass permission checks
Don’t create version on save
submit
Submit a submittable document.cancel
Cancel a submitted document.delete
Delete the document.reload
Reload the document from database.Field access
get
Get a field value with a default.Field name
Default value if field is not set
set
Set a field value.Field name
Value to set
db_set
Set a field value directly in the database without loading the document.Field name or dict of field-value pairs
Value to set
Update modified timestamp
Trigger update event
db_get
Get the latest field value from database.Field name
Child table operations
append
Append a row to a child table.Child table fieldname
Field values for the new row
The appended child document
remove
Remove a child table row.Child document to remove
Permission checks
has_permission
Check if user has a specific permission on the document.Permission type: “read”, “write”, “submit”, “cancel”, “delete”
User to check permission for. Default: current user
True if user has permission
check_permission
Check permission and raise exception if not permitted.Permission type to check
Document state
as_dict
Convert document to dictionary.Exclude default fields like owner, creation
Exclude child table fields
as_json
Convert document to JSON string.Helper functions
delete_doc
Delete a document by doctype and name.DocType name
Document name
Delete even if document is linked
Bypass permission checks
Delete permanently without creating Deleted Document
rename_doc
Rename a document.DocType name
Current name
New name
Merge with existing document if new name exists
Force rename even if links exist