Create a document
frappe_create_docCreate a new document for a specified DocType using supplied field values to insert records that do not yet exist; use update for existing records.
Instructions
Create a new document of the given DocType from the supplied field values.
Use to insert a record that does not yet exist. Use frappe_update_doc instead to change a record that already exists — this tool never updates in place, so re-running it creates a second, separately named document.
Behavior: writes to the site and is NOT idempotent. The document is inserted as a draft (docstatus 0) and is not submitted, so submittable DocTypes such as Sales Invoice still need a submit step via frappe_run_method. Frappe assigns the name from the DocType's naming series, so the name is unknown until this call returns. Server-side validation, mandatory-field checks and DocType hooks all run on insert; a missing mandatory field or an invalid Link value raises a Frappe error and nothing is created. Requires create permission on the DocType.
Parameters: data keys are fieldnames (customer_name), not form labels ('Customer Name'); Link fields take the target document's name, not its title. Child tables are passed as a list of row objects under the child field's own fieldname. Omit name — it is assigned by the naming series and any value supplied is ignored unless the DocType prompts for naming.
Returns: {"data": {...}} — the created document, including the assigned name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Key-value pairs of document field values to set. Keys are fieldnames (e.g. 'customer_name', 'email_id', 'status', 'items'), not form labels; Link fields take the target document's `name`. Child-table fields take a list of row objects. Must include every field the target DocType marks mandatory, or the insert is rejected. | |
| doctype | Yes | The target DocType name for the new document (e.g. 'Customer', 'Sales Invoice', 'Item', 'ToDo', 'Contact', 'Address'). Case-sensitive and must be a DocType that exists on the target Frappe site. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | A Frappe document. Keys are DocType fieldnames; child tables appear as arrays of row objects. Always includes `name` (the primary key), `owner`, `creation`, `modified` and `docstatus` (0 = draft, 1 = submitted, 2 = cancelled). |