PageSourceSearch

https://docs.documentpro.ai/assets/js/ddb410b7.74cdf587.js

js documentpro.ai collected 2026-10-05 01:56:34 UTC 13,444 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkdocumentpro_docs=self.webpackChunkdocumentpro_docs||[]).push([[4639],{3895:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>r,default:()=>p,frontMatter:()=>s,metadata:()=>o,toc:()=>d});const o=JSON.parse('{"id":"using-api/manage-workflows/update-workflow","title":"Update Workflow","description":"Read the introduction to parsers to understand Parsers.","source":"@site/docs/using-api/manage-workflows/update-workflow.mdx","sourceDirName":"using-api/manage-workflows","slug":"/using-api/manage-workflows/update-workflow","permalink":"/docs/using-api/manage-workflows/update-workflow","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":4,"frontMatter":{"sidebar_position":4},"sidebar":"tutorialSidebar","previous":{"title":"Get Workflow","permalink":"/docs/using-api/manage-workflows/get-workflow"},"next":{"title":"Delete Workflow","permalink":"/docs/using-api/manage-workflows/delete-workflow"}}');var i=t(4848),a=t(8453);const s={sidebar_position:4},r="Update Workflow",l={},d=[{value:"API Endpoint",id:"api-endpoint",level:2},{value:"What You Can Update",id:"what-you-can-update",level:2},{value:"Example Implementation",id:"example-implementation",level:2},{value:"Using cURL",id:"using-curl",level:3},{value:"Using Python",id:"using-python",level:3},{value:"Using JavaScript",id:"using-javascript",level:3},{value:"Update Examples",id:"update-examples",level:2},{value:"Update Webhook URL Only",id:"update-webhook-url-only",level:3},{value:"Update Email Setting Only",id:"update-email-setting-only",level:3},{value:"Update Date Format Only",id:"update-date-format-only",level:3},{value:"Update OCR Config Only",id:"update-ocr-config-only",level:3},{value:"Update Query Config Only",id:"update-query-config-only",level:3},{value:"Response",id:"response",level:2},{value:"Successful Response (Status Code: 200)",id:"successful-response-status-code-200",level:3},{value:"Error Response (Status Codes: 400, 404, 500)",id:"error-response-status-codes-400-404-500",level:3},{value:"Important Notes",id:"important-notes",level:2}];function c(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",ul:"ul",...(0,a.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"update-workflow",children:"Update Workflow"})}),"\n",(0,i.jsxs)(n.p,{children:["Read the ",(0,i.jsx)(n.a,{href:"/docs/getting-started/ai-parsers",children:"introduction to parsers"})," to understand Parsers."]}),"\n",(0,i.jsx)(n.p,{children:"This guide explains how to update various aspects of a Workflow, including its schema, settings, and configurations."}),"\n",(0,i.jsx)(n.h2,{id:"api-endpoint",children:"API Endpoint"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"PUT https://api.documentpro.ai/v1/templates/{template_id}\n"})}),"\n",(0,i.jsx)(n.h2,{id:"what-you-can-update",children:"What You Can Update"}),"\n",(0,i.jsx)(n.p,{children:"You can update the following aspects of a Workflow:"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"Workflow schema (template_schema)"}),"\n",(0,i.jsx)(n.li,{children:"Workflow type (template_type)"}),"\n",(0,i.jsx)(n.li,{children:"Webhook URL"}),"\n",(0,i.jsxs)(n.li,{children:["Workflow configurations (parser_config)","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Parse email attachments"}),"\n",(0,i.jsx)(n.li,{children:"Parse email body"}),"\n",(0,i.jsx)(n.li,{children:"Date format"}),"\n",(0,i.jsx)(n.li,{children:"OCR config"}),"\n",(0,i.jsx)(n.li,{children:"Query config"}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"example-implementation",children:"Example Implementation"}),"\n",(0,i.jsx)(n.h3,{id:"using-curl",children:"Using cURL"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:'curl --location --request PUT \'https://api.documentpro.ai/v1/templates/710a20fc-e280-43eb-9a9f-5436e600c710\' \\\n--header \'x-api-key: YOUR_API_KEY\' \\\n--header \'Content-Type: application/json\' \\\n--data \'{\n  "template_type": "Invoice",\n  "template_schema": {\n    "fields": [\n      { "name": "invoice_number", "type": "text", "description": "Unique identifier for the invoice" },\n      { "name": "total_amount", "type": "number", "description": "Total amount on the invoice" },\n      {\n        "name": "line_items",\n        "type": "table",\n        "description": "Invoice line items",\n        "subFields": [\n          { "name": "description", "type": "text", "description": "Description of item" },\n          { "name": "quantity", "type": "number", "description": "Quantity of item" },\n          { "name": "unit_price", "type": "number", "description": "Price per unit" }\n        ]\n      }\n    ]\n  },\n  "webhook_url": "https://your-webhook-url.com",\n  "parser_config": {\n    "date_format": "%d/%m/%y",\n    "ocr_config": { "detect_tables": true },\n    "query_config": { "query_model": "gpt-4o-mini" }\n  }\n}\'\n'})}),"\n",(0,i.jsx)(n.h3,{id:"using-python",children:"Using Python"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'import requests\nimport json\n\ntemplate_id = "710a20fc-e280-43eb-9a9f-5436e600c710"\nurl = f"https://api.documentpro.ai/v1/templates/{template_id}"\n\n# Example payload updating multiple aspects\npayload = {\n    "template_type": "Invoice",\n    "template_schema": {\n        "fields": [\n            {\n                "name": "invoice_number",\n                "type": "text",\n                "description": "Unique identifier for the invoice"\n            },\n            {\n                "name": "total_amount",\n                "type": "number",\n                "description": "Total amount on the invoice"\n            },\n            {\n                "name": "line_items",\n                "type": "table",\n                "description": "Invoice line items",\n                "subFields": [\n                    {\n                        "name": "description",\n                        "type": "text",\n                        "description": "Description of item"\n                    },\n                    {\n                        "name": "quantity",\n                        "type": "number",\n                        "description": "Quantity of item"\n                    },\n                    {\n                        "name": "unit_price",\n                        "type": "number",\n                        "description": "Price per unit"\n                    }\n                ]\n            }\n        ]\n    },\n    "webhook_url": "https://your-webhook-url.com",\n    "parser_config": {\n        "date_format": "%d/%m/%y",\n        "ocr_config": {\n            "detect_tables": true\n        },\n        "query_config": {\n            "query_model": "gpt-4o-mini"\n        }\n    }\n}\n\nheaders = {\n    \'x-api-key\': \'YOUR_API_KEY\',\n    \'Content-Type\': \'application/json\'\n}\n\nresponse = requests.put(url, headers=headers, json=payload)\n\nif response.status_code == 200:\n    print(\'Workflow updated successfully\')\n    print(json.dumps(response.json(), indent=2))\nelse:\n    print(\'Failed to update Workflow\')\n    print(response.text)\n'})}),"\n",(0,i.jsx)(n.h3,{id:"using-javascript",children:"Using JavaScript"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-javascript",children:"const templateId = '710a20fc-e280-43eb-9a9f-5436e600c710';\n\nconst payload = {\n  template_type: 'Invoice',\n  template_schema: {\n    fields: [\n      { name: 'invoice_number', type: 'text', description: 'Unique identifier for the invoice' },\n      { name: 'total_amount', type: 'number', description: 'Total amount on the invoice' },\n      {\n        name: 'line_items',\n        type: 'table',\n        description: 'Invoice line items',\n        subFields: [\n          { name: 'description', type: 'text', description: 'Description of item' },\n          { name: 'quantity', type: 'number', description: 'Quantity of item' },\n          { name: 'unit_price', type: 'number', description: 'Price per unit' }\n        ]\n      }\n    ]\n  },\n  webhook_url: 'https://your-webhook-url.com',\n  parser_config: {\
1n    date_format: '%d/%m/%y',\n    ocr_config: { detect_tables: true },\n    query_config: { query_model: 'gpt-4o-mini' }\n  }\n};\n\nconst response = await fetch(`https://api.documentpro.ai/v1/templates/${templateId}`, {\n  method: 'PUT',\n  headers: {\n    'x-api-key': 'YOUR_API_KEY',\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify(payload)\n});\n\nif (response.ok) {\n  console.log('Workflow updated successfully:', await response.json());\n} else {\n  console.error('Failed to update Workflow', await response.text());\n}\n"})}),"\n",(0,i.jsx)(n.h2,{id:"update-examples",children:"Update Examples"}),"\n",(0,i.jsx)(n.p,{children:"You can update specific aspects of the Workflow by including only the relevant fields in your payload. Here are some examples:"}),"\n",(0,i.jsx)(n.h3,{id:"update-webhook-url-only",children:"Update Webhook URL Only"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n    "webhook_url": "https://your-webhook-url.com"\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"update-email-setting-only",children:"Update Email Setting Only"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n    "parser_config": {\n        "parse_email_attachments": false,\n        "parse_email_body": true\n    }\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"update-date-format-only",children:"Update Date Format Only"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n    "parser_config": {\n        "date_format": "%d/%m/%y"\n    }\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"update-ocr-config-only",children:"Update OCR Config Only"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n    "parser_config": {\n        "ocr_config": {\n            "detect_tables": true,\n            // ... other OCR settings ...\n        }\n    }\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"update-query-config-only",children:"Update Query Config Only"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n    "parser_config": {\n        "query_config": {\n            "query_model": "gpt-4o-mini",\n            // ... other query settings ...\n        }\n    }\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"response",children:"Response"}),"\n",(0,i.jsx)(n.h3,{id:"successful-response-status-code-200",children:"Successful Response (Status Code: 200)"}),"\n",(0,i.jsx)(n.p,{children:"A successful update will return a 200 status code and the updated Workflow object in the response body:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n    "template_id": "710a20fc-e280-43eb-9a9f-5436e600c710",\n    "template_title": "Custom Invoice Workflow",\n    "template_type": "invoice",\n    "template_category": "other",\n    "template_schema": {\n        "fields": [\n            // ... updated fields ...\n        ]\n    },\n    "email_id": "[email protected]",\n    "webhook_url": "https://your-webhook-url.com",\n    "parser_config": {\n        "parse_email_attachments": false,\n        "parse_email_body": true,\n        "date_format": "%d/%m/%y",\n        "ocr_config": {\n            "detect_tables": true,\n            // ... other OCR settings ...\n        },\n        "query_config": {\n            "query_model": "gpt-4o-mini",\n            // ... other query settings ...\n        }\n    },\n    "created_at": "2023-11-15T12:13:12.056281"\n}\n'})}),"\n",(0,i.jsx)(n.h3,{id:"error-response-status-codes-400-404-500",children:"Error Response (Status Codes: 400, 404, 500)"}),"\n",(0,i.jsx)(n.p,{children:"For errors, you will receive a response with the following structure:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n    "success": false,\n    "error": "error_code",\n    "message": "descriptive error message"\n}\n'})}),"\n",(0,i.jsx)(n.h2,{id:"important-notes",children:"Important Notes"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"You can update multiple aspects of the Workflow in a single request by including all relevant fields in your payload."}),"\n",(0,i.jsx)(n.li,{children:"Only include the fields you want to update in y
1our request payload. Any fields not included will remain unchanged."}),"\n",(0,i.jsxs)(n.li,{children:["When updating the ",(0,i.jsx)(n.code,{children:"template_schema"}),", ensure that your new schema is valid and includes all necessary fields and subfields."]}),"\n",(0,i.jsx)(n.li,{children:"After updating a Workflow, it's a good practice to retrieve the Workflow details to confirm your changes were applied correctly."}),"\n"]})]})}function p(e={}){const{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>r});var o=t(6540);const i={},a=o.createContext(i);function s(e){const n=o.useContext(a);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:s(e.components),o.createElement(a.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.