Skip to main content

Update the schema

Read the introduction to parsers to understand Parsers.

You can update the schema of a parser using the API. This is useful when you want to add or remove fields from a parser.

Guide to updating a parser schema#

API Endpoint#


Example Implementation using Python#

import requestsimport json
url = ""
payload = json.dumps({  "template_type": "Invoice",  "template_schema": {    "fields": [      {        "name": "buyer_name",        "type": "text",        "description": "name of the buyer"      },      {        "name": "total_amount",        "type": "number"      },      {        "name": "line_items",        "type": "table",        "description": "invoice line items",        "subFields": [          {            "name": "description",            "type": "text",            "description": "description of item"          },          {            "name": "subtotal",            "type": "number"          }        ]      }    ]  }})
headers = {  'x-api-key': 'YOUR_API_KEY',  'Content-Type': 'application/json'}
response = requests.request("PUT", url, headers=headers, data=payload)
# If the request was successful, status_code will be 200if response.status_code == 200:    print('Parser updated successfully')else:    print('Failed to update parser')

You can include either template_type or template_schema or both in the request body.

Response body#

A 200 status code will have the following body structure.

{    "template_id": "710a20fc-e280-43eb-9a9f-5436e600c710",    "template_title": "Custom Invoice Parser",    "template_type": "Invoice",    "template_category": "other",    "template_schema": {      "fields": [        {          "name": "buyer_name",          "type": "text",          "description": "name of the buyer"        },        {          "name": "total_amount",          "type": "number"        },        {          "name": "line_items",          "type": "table",          "description": "invoice line items",          "subFields": [            {              "name": "description",              "type": "text",              "description": "description of item"            },            {              "name": "subtotal",              "type": "number"            }          ]        }      ]    }    "email_id": "",    "webhook_url": null,    "parser_config": {      "date_format": null,      "outbound_integration": null,      "ocr_config": {        "engine": "aws_textract",        "precision": "low",        "auto_select_precision": true,        "formatting_level": "low",        "show_page_number": false,        "split_by_page": false,        "trim_spaces": true,        "show_type_label": true      },      "query_config": {        "query_model": "gpt-3.5-turbo-1106",        "set_max_output_tokens": false,        "include_example": false,        "minimize_tokens": false,        "selected_language": "english"      }    },    "created_at": "2023-11-15T12:13:12.056281"}

For status codes 400, 404 and 500 you will get the following response body.

{    "success": false,    "error": "error message",    "message": "descriptive error message"}