Learn how to quickly get started with the Keyfax REST based Web API.
This is a quick start guide intended to help developers integrating Keyfax into an existing housing management system or tenant portal. This quick start guide is intended to get you up and running as quickly as possible and as such only details the minimal steps necessary for host systems to launch Keyfax and process Keyfax results.
Some more advanced concepts are not covered in this guide. For further information please refer to the "Additional Reading" section below for links to our full integration documentation.
Verification Methods
Certain requests into the Keyfax REST based Web API require verification. We support 3 types of verification, these are Basic, Bearer and API Key. Verification is achieved by providing a Authorization header with each request. An example Authorization header is shown below for each supported verification method.
Basic
Basic verification is primarily used by native applications or for server-to-server communication where you can secure the private signing key. This is the most secure verification method. All API requests are signed with the private signing key via a pre-flight request to the server and the resulting signature is then sent along with the real request. The signature is then generated again on the server and compared with the sent signature. The public API key must also match.
Bearer verification is intended for client side scenarios were it's not possible to hide a private key. Bearer tokens are typically short lived. The /api/v1/tokens end point can be used to generate a short lived JSON web token which can be used with the Bearer verification method. This is the preferred approach to ensure verified client side requests.
Authorization: Bearer {hostName}:{bearerToken}
API Key
API Key uses a static API key to allow requests - this can be used both server and client side. Requests using this approach are not considered verified as the API key could be visible to anyone. We offer this option for those that are not able to execute server side code to generate an initial bearer token for client side requests.
Authorization: ApiKey {hostName}:{apiKey}
The hostName would typically be Default, Dev, Test or Live depending on the hostName supplied during initial key creation or when calling /api/v1/key?hostName={hostName} to create the initial key. (see below).
1. Obtaining a Keyfax API Key
Make a request to /interview/api/v1/key?hostName=Live to obtain an initial API key. This will provide the response shown below (with different keys)...
TIP By default as of Keyfax 4.4.6 and below the created API keys will be added to the database defined within the default Keyfax configuration. For Keyfax 4.4.7 and above to use a specific Keyfax configuration you can optionally specify a co querystring paramater with the above request to use a specific Keyfax configuration & database. For example /interview/api/v1/key?hostName=Test&co=Keyfax_Staff_Test
Make a note of the returned apiKey, signingKey & hostName - you will need these for subsequent API requests that require verification. It's worth noting a request to api/v1/key will only work if keys don't already exists for the supplied host name. If keys already exists for the supplied host name new keys will not be created.
To keep things simple for the rest of this example we'll be using the simplest static API Key verification method.
2. Returning a Keyfax Launch URL
Once you have your API key you can make verified POST request into /api/v1/startup supplying Keyfax start-up data to get back a unique URL you can use to launch a Keyfax session. An example request with minimal example Keyfax start-up data is provided below...
You'll notice as part of the start-up data supplied to Keyfax we provide a returnUrl property. If provided Keyfax will return to this URL after the Keyfax script is completed. Hosts would typically then perform additional post-processing of Keyfax results upon this returnUrl page.
The above request will return the following response...
You can then use the launchUrl returned within the response to open a Keyfax session for the tenant or agent. The Keyfax session can be opened in the same browser window, a new tab or a separate pop-up window.
Once the tenant or agent has completed the Keyfax script they will be automatically redirected to the returnUrl supplied within the start-up data provided to Keyfax. When redirecting back to the returnUrl Keyfax will add a unique identifier to the end of the returnUrl. This identifier can be used upon the returnUrl page to obtain Keyfax results.
3. Obtaining Keyfax Results
Upon the user being redirected back to the returnUrl page you would make the below API request upon the returnUrl page to retrieve Keyfax results. The GUID within the request body would be obtained from the guid querystring parameter appending to the returnUrl page.
The /api/v1/results end-point will return Keyfax results containing all of the information related to the completed Keyfax session. An example response from /api/v1/results is shown below...
{
"KeyfaxData": {
"Fault": {
"@name": "Fault1",
"@type": "RD",
"IsDeleted": "False",
"IsDirty": "False",
"IsNew": "True",
"Fault_Dialog": "11104",
"Fault_Category": "10763",
"CompanyCode": null,
"ScriptSet": "1",
"FaultText": "Baths: Bath; cracked; tenant action",
"LogDate": "09/08/2022 10:15:18",
"Communal_Type": "",
"Reason_Code": "DT",
"Reason_Text": "DT",
"Recharge": "0",
"Recharge_Code": "RREP",
"Recharge_Cost": "0.00",
"Repair_No": "",
"Repair_Status": "2",
"RTR": null,
"RTR_Date": null,
"Insurance": null,
"Schedule_ID": "operator\\176",
"Site_Visit": "",
"Additional_Info": "",
"Special_Instructions": "",
"Tenancy_Type": "1",
"ClientID": "",
"TenantID": "",
"TenantText": "",
"UserCode": "operator",
"ScriptPath": {
"Question": [
"Q1 = What is the problem with the bath?: A1 = cracked",
"Q2 = Can the bath still be used?: A2 = can be used",
"Q3 = How did it happen?: A3 = tenant action",
"Q4 = Continue logging tenant responsible repair?: A4 = Yes",
"Q5 = Tenant responsibility justifications: A5 = DT"
]
},
"Contractor_Code": "",
"Contractor_Email": null,
"Contractor_Region": null,
"Expenditure_Code": null,
"Nominal_Code": null,
"Job_Code": null,
"Location": null,
"HDIH": null,
"RepairCount": "1",
"AdviceCount": "1",
"CustomCount": "0",
"ActionCount": "0",
"SubActionCount": "0",
"UpdateCount": "0",
"Repair": {
"@name": "Repair1",
"CompleteBy": "06/09/2022 10:15:18",
"ResponseDays": "28",
"Priority": "R",
"PriorityId": "2105",
"RepairCode": "INSP",
"RepairCodeEx": "INSP",
"RepairCodeDesc": "Inspection by Technical Officer",
"UnitOfMeasure": "No",
"UnitOfMeasureQuantity": "1",
"Contractor": "T01",
"IsDeleted": "False",
"IsDirty": "False",
"IsNew": "True"
},
"Advice": {
"@name": "Advice1",
"AdviceCode": "ATR007",
"AdviceCodeEx": "ATR007",
"AdviceCodeDesc": "Landlord not responsible",
"AdvicePlainText": "MSG: Example Paragraph 123 \nExample link within an example paragraph with example link. Example link within an example paragraph with another example link. Links \n Default link msg-text-primary msg-text-secondary msg-text-info msg-text-danger msg-text-warning\n Text \n msg-text-primary msg-text-secondary msg-text-info msg-text-danger msg-text-warning\n Unordered List \n List Item 1 List Item 2 List Item 3\n Ordered List \n List Item 1 List Item 2 List Item 3\n Description List \n List Item 1 List Item 2 List Item 3\n Blockquote \nAn example block quote Code \nvoid Browser_Load(object sender, EventArgs e) Badges \n msg-badge-primary msg-badge-secondary msg-badge-success msg-badge-info msg-badge-danger msg-badge-warning\n Buttons \n msg-btn-primary msg-btn-secondary msg-btn-success msg-btn-info msg-btn-danger msg-btn-warning\n Alerts \nNOTE This alert has the msg-alert-primary class. NOTE This alert has the msg-alert-secondary class. NOTE This alert has the msg-alert-success class. NOTE This alert has the msg-alert-info class. NOTE This alert has the msg-alert-danger class. NOTE This alert has the msg-alert-warning class. Headings \nDefault Heading 1 This is some example text below a header Heading 2 This is some example text below a header Heading 3 This is some example text below a header Heading 4 This is some example text below a header Heading 5 This is some example text below a header Heading 6 This is some example text below a header Primary \nHeading 1 This is some example text below a header Heading 2 This is some example text below a header Heading 3 This is some example text below a header Heading 4 This is some example text below a header Heading 5 This is some example text below a header Heading 6 This is some example text below a header Secondary \nHeading 1 This is some example text below a header Heading 2 This is some example text below a header Heading 3 This is some example text below a header Heading 4 This is some example text below a header Heading 5 This is some example text below a header Heading 6 This is some example text below a header Success \nHeading 1 This is some example text below a header Heading 2 This is some example text below a header Heading 3 This is some example text below a header Heading 4 This is some example text below a header Heading 5 This is some example text below a header Heading 6 This is some example text below a header Info \nHeading 1 This is some example text below a header Heading 2 This is some example text below a header Heading 3 This is some example text below a header Heading 4 This is some example text below a header Heading 5 This is some example text below a header Heading 6 This is some example text below a header Danger \nHeading 1 This is some example text below a header Heading 2 This is some example text below a header Heading 3 This is some example text below a header Heading 4 This is some example text below a header Heading 5 This is some example text below a header Heading 6 This is some example text below a header Warning \nHeading 1 This is some example text below a header Heading 2 This is some example text below a header Heading 3 This is some example text below a header Heading 4 This is some example text below a header Heading 5 This is some example text below a header Heading 6 This is some example text below a header Table Primary \n # First Last Handle 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter \n Table Secondary \n # First Last Handle 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter \n Table Success \n # First Last Handle 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter \n Table Info \n # First Last Handle 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter \n Table Danger \n # First Last Handle 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter \n Table Warning \n # First Last Handle 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter \n Examples \nHeader 1 with Badge NEW Header 2 with Badge UPDATED \nNOTE \nThis is an example of an alert. This alert could be used to draw users attention to important content within a message. NEW Check out what's new - Learn More UPDATED Something updated! WARNING \nFor further information please click this example hyperlink. # First Last Handle 1 Mark Otto @mdo 2 Jacob Thornton @fat 3 Larry the Bird @twitter \n BEFORE PROCEEDING \nThis is an example of an alert. This alert could be used to draw users attention to important content within a message. You can see below an optional link.\n\nLearn More\n FURTHER READING \nThis is an example of an alert. This alert could be used to draw users attention to important content within a message. You can see below optional links.\n\nDownload PDF Open PDF\n\n",
"IsDeleted": "False",
"IsDirty": "False",
"IsNew": "True"
}
},
"GUID": "e728783b-fe9f-40bf-9f39-5329d77161b7",
"Status": "1"
}
}
Host systems would typically perform additional processing of the results produced by Keyfax. For example you may wish to parse the SOR codes or overall priority and associate these with a work item or order within your system.
Example Data
Minimal Start Up Data Examples
The below illustrates the minimum start-up data you must post to Keyfax via /api/v1/startup. This is only to serve as an example and to show what's possible. Host systems would typically work with Omfax Systems to craft this start-up data based on your specific requirements & configuration.
The below illustrates some realistic start-up data you would typically post to Keyfax via /api/v1/startup. This is only to serve as an example and to show what's possible. Host systems would typically work with Omfax Systems to craft this start-up data based on your specific requirements & configuration.
This would then be accessible within Keyfax via Import Databoxes (i.e. Startup/CustomData/CustomRoot1/CustomRoot1_Child1/text() would return "Child 1 Value").
You can also nest custom properties as demonstrated below...