1. Connect to BriteCore ACORD XML API
Path: /api/v2/acord
Method: POST
Request: Valid ACORD XML
Authentication: Caller must authenticate via one of the following ways:
- Provide a valid access key obtained from OAuth 2.0 Client Credentials grant (see this article);
- Provide a BriteCore API Key in HTTP "Authorization" header; or
- Provide a BriteCore API Key in HTTP request body at XPath: ACORD/SignonRq/ClientApp/com.britecore_ApiKey
2. Configure XML Processing Templates
Three templates are involved in ACORD XML processing:
- Router template
- Request processing template
- Response processing template
Currently, the XML processing templates borrow the custom deliverable template system, accessible under Settings > Deliverables > Mass Deliverables > Custom Deliverables. All templates are processed with the Jinja2 template engine.
2.1 Configure Router Template
The router template must be named acord_xml_router, and construct a JSON object with the following attributes:
-
api: Specify which API endpoint to invoke, in dot format. Example:
api.v2.policies.create_quote_extendedwill send the processed request to/api/v2/policies/create_quote_extended. - request_template: Specify the template name to transform the request XML content to API JSON input. See section 2.2.
- response_template: Specify the template name to transform the API JSON output to response XML content. See section 2.3.
The router template can send the request to different processing paths based on request XML content. Here is an example that supports EZLynx credential testing on top of the rating request:
{%- set acord = document -%}
{%- if acord.xpath('*')|length == 1 and acord.SignonRq -%}
{
"api": "api.v2.contacts.get_contact",
"request_template": "acord-signon-verify-rq",
"response_template": "acord-signon-verify-rs"
}
{%- else -%}
{
"api": "api.v2.policies.create_quote_extended",
"request_template": "acord-home-policy-rq",
"response_template": "acord-home-policy-rs"
}
{%- endif -%}The XML content is available under the document global symbol, provided by the lxml.objectify API (see lxml docs). It provides flexible access to document content, including XPath as shown above.
2.2 Configure Request Template
The request template has the same document global symbol to access request XML content.
Based on the API endpoint selected by the router template, the request template must construct a JSON object to pass into the API endpoint. Refer to https://api.britecore.com/ for endpoint details.
The request template has two additional facilities:
- var_data global: Initialized as an empty Python dictionary. The request template can add keys and values that are later available in the response template.
-
raise_hard_stop(): Skips the API call and proceeds directly to the response template. Useful when a hard-stop condition is detected. Any values stored in
var_databefore the hard stop remain available to the response template.
See Appendix A for additional utility functions available as global symbols.
Example: Request Template Example
2.3 Configure Response Template
The response template constructs an XML response based on the request XML content and API response.
The following globals are available:
- document: Same as router and request templates.
-
api_response: The dictionary returned by the API endpoint. (If
raise_hard_stop()was called, this will beNone.) - var_data: Data passed from the request template.
To construct the XML response, you may modify the document in place using the utility functions in Appendix A, then serialize it using to_xml().
Example: Response Template Example
Appendix A. Utility Functions
XML Document Manipulation
-
add_sub_tag(el, tag_name, tag_ref=None, tag_value=None): Adds a child tag to an XML element. -
change_tag(el, old_tag_name, new_tag_name): Changes the name of an existing tag. -
change_value(el, child_tag_name, value): Rewrites the value of a child tag. -
new_element(tag_name, tag_ref=None): Creates a new XML element. -
add_new_element(parent_el, el): Adds a new element as a child of the parent. -
delete_tag(parent_el, tag): Deletes a tag from the parent element. -
remove_element(el): Removes an element from the XML document. -
to_xml(document_el): Renders an XML document to a string.
Other Utility Functions
-
parse_date(date_string): Reads a date string into a Python date object.
raise_hard_stop(message=""): Raises a hard stop.