2023:API Services (Service)

From Grooper Wiki

This article is about an older version of Grooper.

Information may be out of date and UI elements may have changed.

202520242023.12023

You can perform Batch processing via REST API web calls by installing API Services.

About

The Grooper REST API (Application Programming Interface) allows for seamless integration between line of business solutions or custom-built software and your existing Grooper repositories and processes. A set of REST API methods allows users to push documents through Grooper Batch Processes and retrieve the results.

For example, using the Grooper REST API you can:

  • Get information about a single Batch or all Batches
  • Create a new Batch
  • Delete a Batch
  • Start or resume a Batch Process
  • Get metadata for a specified Batch Folder.
  • And more!

The first step in using the Grooper REST API is setting up an API endpoint for your 3rd party application to interact with a Grooper Repository. To do this, you will need to install a Grooper service in Grooper Config called API Services.

You must register an API key for the API endpoint to function. The API key is passed in the HTML header for Grooper's API calls as a key-value pair.

  • key name: apikey
  • value format (GUID): 00000000-0000-0000-0000-000000000000

Instructions on how to obtain an API key are found in the How to install the Grooper API Services tutorial.

How To: Install the Grooper API Services

The Grooper Service User must have the "Logon as Service" permission."

  1. In Grooper config click the "Edit Services" button to open the "Service Manager" window.


  1. From the Service Manager window click the "Install" button.
  2. Select the desired repository from the "Repository" dropdown.
  3. Choose API Services.
  4. Click the "OK" button to confirm and open the "API Services" window.


  1. From the "API Services" window add an API key for the API Keys property.
  2. Copy the API endpoint URL from the URL property.
  3. Ensure the Windows service user credentials are correct on the User Name and Password properties.
  4. When finished configuring click the "Execute" button to confirm changes and close the "API Services" window.


  1. In the "Service Manager" window, with the newly created "Grooper API Services" service installed and selected, click the "Start" button.
    • FYI - If everything was configured properly, the "Status" of the service will change from "Stopped" to "Running".

How Tow: Enable a Grooper API Test Endpoint

When using the Grooper REST API, you may find it helpful to test out certain API calls before you implement them. By turning the Enable Test Endpoint property on, you can expose a Grooper REST API testing interface which you can access by entering the API URL in a browser.

  1. When editing an "API Services" service, in the "API Services" window, set the Enable Test Endpoint property to True.
  2. Copy the API endpoint URL from the URL property.
  3. When finished configuring click the "Execute" button to confirm changes and close the "API Services" window.



  1. Paste the copied URL into a browser of your choice.



From here, you can view and test the various REST API methods available to process documents in Grooper.

Testing Grooper API endpoints

Be aware this section is a work-in-progress. For more information about each API endpoint, set up a test endpoint and try it out for yourself!

Here, you will find more information about testing the Grooper API endpoints.

  • Note, parameters you can pass with the request are in curly brackets.
  • Example: You would replace {BatchID} with the GUID of a Batch.

PLEASE NOTE: Browsers will cache certain values entered in the API tester. This can cause confusion when testing endpoints with optional data (particularly the CreateBatch and CreateFolder endpoints). There are scenarios where cached values may be used unexpectedly.

The Grooper API Tester is meant for quick and simple tests. We recommend using a more robust API tester (such as Postman) before implementation.

DeleteBatch: Delete a Batch

DELETE {baseUrl}/api/v1/BatchProcessing/Batches/{BatchID}


This request will delete a Batch in Grooper. Enter a Batch's GUID to delete it.

  • If successfully deleted, the response will be true

GetBatchInfo: Get info for a specific Batch

GET {baseUrl}/api/v1/BatchProcessing/Batches/{BatchID}


This request will give you information about a Batch in Grooper (its "Id", "Name", "Status" and more property values). Enter the Batch's GUID to return information about it.

  • You will receive a JSON response containing information about the Batch.

See below for an example response:

{
  "Id": "be0336a2-5e9a-4f60-83d0-15ea4b092cd9",
  "Name": "Invoices",
  "NodeIndex": 2,
  "NumChildren": 2,
  "ParentId": "46225e5b-c2a5-4d30-9bf8-68646e5e11fc",
  "TypeName": "Grooper.Core.Batch",
  "Created": "/Date(1664458774624-0500)/",
  "CreatedBy": "BIS\\dgreenwood",
  "Priority": 3,
  "RootFolderId": "7b80c102-2a22-4525-b05a-a1389849425a",
  "Status": 4,
  "StepNo": -1
}

GetBatchInfos: Get info for all Batches (Production branch only)

GET {baseUrl}/api/v1/BatchProcessing/Batches/All/All?Level={Level}


The Batches/All call returns information about all production Batches in a Grooper Repository at a specified level.

Entering a {Level} of 0 will return information about all production Batches at all folder levels.

  • This is the most common request but can be computationally inefficient as Grooper must iterated through various nodes to determine if Batches are present at multiple levels in the Production branch.

Entering a {Level} other than 0 will return information about production Batches only at the specified level of the Production branch.

  • This can be more efficient if you expect all your Batches to be at the same level.
  • In the example below, we set {Level} to 2, returning information about the single Batch at the second level of the Production branch.

GetContentStream: Get data from a file in the Grooper file store

GET {baseUrl}/api/v1/BatchProcessing/Files/{ItemId}/{FileName}


This request returns information about files in the Grooper file store. You will need to enter two things:

  • The item's GUID (often a Batch Folder's GUID)
  • The file's name (often a file associated with or attached to that Batch Folder)


Depending on the file type, the API will return:

  • For most file types, the API will return the file's MIME type and file size.
  • For JSON files, the API will return the full JSON content. This could be used to return any number of things, including the full JSON for the "Grooper.DocumentData.json" file generated for a Batch Folder after it was extracted.


In this example, {ItemId} was set to the GUID of a Batch Folder and {FileName} was set to the name of an attached PDF.

  • The MIME type and file size for that file was returned.
  • However,


See below for an example response for a pdf file:

Type: application/pdf, Size: 75922


See below for an example response of a "Grooper.DocumentData.json" file:

{
  "Ch": [
    {
      "__type": "FieldInstance:#Grooper.Core",
      "Val": "30cbbb98-bada-407d-aaca-573748e31350",
      "IxId": "88e97d14-c60a-4133-8efc-30d81bd9afcb",
      "Name": "GUID",
      "FC": 1
    },
    {
      "__type": "SectionInstance:#Grooper.Core",
      "Ch": [
        {
          "__type": "FieldInstance:#Grooper.Core",
          "Val": "#PBJ001",
          "CI": [
            {
              "Val": "INVOICE NUMBER",
              "Name": "Invoice Number",
              "Idx": 91,
              "Len": 14,
              "Loc": {
                "X1": 0.75,
                "Y1": 1.8458,
                "X2": 2.0267,
                "Y2": 1.9458
              },
              "FC": 1
            }
          ],
          "IxId": "f165f384-7fda-4dd6-ade5-2ff9bb65866b",
          "Idx": 120,
          "Len": 7,
          "Name": "Invoice Number",
          "Loc": {
            "X1": 2.7275,
            "Y1": 2.1858,
            "X2": 3.3225,
            "Y2": 2.2858
          },
          "FC": 1
        },
        {
          "__type": "FieldInstance:#Grooper.Core",
          "Val": "10/19/2009",
          "CI": [
            {
              "Val": "INVOICE DATE",
              "Name": "Invoice Date",
              "Idx": 106,
              "Len": 12,
              "Loc": {
                "X1": 3.5,
                "Y1": 1.8458,
                "X2": 4.5125,
                "Y2": 1.9458
              },
              "FC": 1
            }
          ],
          "IxId": "c2692a97-2a71-442a-91d3-d753978bf8b1",
          "Idx": 128,
          "Len": 10,
          "Name": "Invoice Date",
          "Loc": {
            "X1": 5.2808,
            "Y1": 2.1725,
            "X2": 6.0775,
            "Y2": 2.3008
          },
          "FC": 1
        },
        {
          "__type": "FieldInstance:#Grooper.Core",
          "Val": "688.98",
          "CI": [
            {
              "Val": "TOTAL $",
              "Name": "Invoice Total",
              "Idx": 441,
              "Len": 7,
              "Loc": {
                "X1": 5.9125,
                "Y1": 7.0633,
                "X2": 6.4909,
                "Y2": 7.1783
              },
              "FC": 1
            }
          ],
          "IxId": "b9e8adb4-4a16-45e1-b10b-6048bd81e39b",
          "Idx": 488,
          "Len": 6,
          "Name": "Invoice Total",
          "Loc": {
            "X1": 7.3933,
            "Y1": 7.47,
            "X2": 7.8517,
            "Y2": 7.5692
          },
          "FC": 1
        }
      ],
      "IxId": "d13da629-8f65-4a49-ac22-13d9a629e2ba",
      "Spans": [
        {
          "Length": 752
        }
      ],
      "Name": "Header Details",
      "Loc": {
        "X1": 0.51,
        "Y1": 0.5483,
        "X2": 8.0008,
        "Y2": 10.3175
      }
    }
  ],
  "IxId": "68dc0073-3ee9-4b3f-af9e-963380a5763e",
  "Name": "Data Model",
  "Loc": {
    "X1": 0.51,
    "Y1": 0.5483,
    "X2": 8.0008,
    "Y2": 10.3175
  },
  "FC": 0.5
}

GetContentTypes: Get info for all Content Types

GET {baseUrl}/api/v1/BatchProcessing/ContentTypes


This request returns information about all Content Types (Content Models, Content Categories and Document Types) in your repository.

  • There is no configuration necessary.

See below for an example response. This response is from a Grooper Repository that only has a single Content Model (named "HR Model - Small") with three Document Types (named "Benefits Questionnaire" "Data Change" and "Data Info"):

[
  {
    "Id": "bc22effb-0db9-4d1e-9665-2209206cd13c",
    "Name": "HR Model - Small",
    "NodeIndex": 0,
    "NumChildren": 5,
    "ParentId": "6cc455ff-a386-4e7a-a924-8ef367c637fa",
    "TypeName": "Grooper.Core.ContentModel",
    "Children": [
      {
        "Id": "97b3b424-72ad-47ed-8d94-73a42df8e06a",
        "Name": "Benefits Questionnaire",
        "NodeIndex": 2,
        "NumChildren": 1,
        "ParentId": "bc22effb-0db9-4d1e-9665-2209206cd13c",
        "TypeName": "Grooper.Core.DocumentType"
      },
      {
        "Id": "52130f97-a419-4ef8-8c41-aaf83a9c555a",
        "Name": "Data Change",
        "NodeIndex": 3,
        "NumChildren": 2,
        "ParentId": "bc22effb-0db9-4d1e-9665-2209206cd13c",
        "TypeName": "Grooper.Core.DocumentType"
      },
      {
        "Id": "95e52a6b-b7b3-4ef9-a068-9f18bb06e1e9",
        "Name": "Data Info",
        "NodeIndex": 4,
        "NumChildren": 1,
        "ParentId": "bc22effb-0db9-4d1e-9665-2209206cd13c",
        "TypeName": "Grooper.Core.DocumentType"
      }
    ]
  }
]

GetFolderInfo: Get info for a single Batch Folder

GET {baseUrl}/api/v1/BatchProcessing/Folders/{FolderId}


This will will return information about the folder. Enter a Batch Folder's GUID to return information about it.

  • Notably, its name and "DataIsValid" value are often of use.


Example JSON response if the folder exists:

{
  "Id": "0379d4ba-d67c-4ecc-ba82-f61117bc898c",
  "Name": "Doc Type (1)",
  "NodeIndex": 0,
  "NumChildren": 1,
  "ParentId": "3f1139e4-da29-488e-bed8-f1f381b483c3",
  "TypeName": "Grooper.Core.BatchFolder",
  "DataIsValid": false
}


Example JSON response if an invalid GUID is provided (i.e. the object whose GUID you summited is not a folder):

{
  "Message": "Object with ID '74b475a5-fc58-4e6d-b737-b94f6d0aed4c' is not a Batch Folder."
}


Example JSON response if the folder is not found (i.e. the folder has been deleted or never existed in the first place):

{
  "Message": "Batch Folder with ID '79aa46db-cc9c-4ee0-b15d-0c369b603910' not found."
}

GetFolders: Get info for all Batch Folders (at a specific level)

GET {baseUrl}/api/v1/BatchProcessing/Folders/{ParentId}/Folders?Level={Level}


This request will return information about all folders at a specified level within a specifield folder. Enter the GUID for any parent folder (such as a Batch's root folder's GUID) and the folder level you want to search.

  • You will receive information about all folders at that level, including their GUID id, names, index, "DataIsValid" values and more.


See below for an example response:

[
  {
    "Id": "5256e88d-d032-4d24-ab94-edc43056bca2",
    "Name": "1 (1)",
    "NodeIndex": 0,
    "NumChildren": 1,
    "ParentId": "d754077b-9903-4e79-93da-4ececb3aabaf",
    "TypeName": "Grooper.Core.BatchFolder",
    "DataIsValid": false
  },
  {
    "Id": "7bb14095-28a5-4195-b675-29fafb39eee3",
    "Name": "2 (2)",
    "NodeIndex": 1,
    "NumChildren": 0,
    "ParentId": "d754077b-9903-4e79-93da-4ececb3aabaf",
    "TypeName": "Grooper.Core.BatchFolder",
    "DataIsValid": false
  }
]

GetMetadata: Get extracted results for a document (single instance Data Fields only)

GET {baseUrl}/api/v1/BatchProcessing/Folders/{FolderId}/Metadata


This request returns extracted data for a Batch Folder. Enter a Batch Folder's GUID and you will return two things:

  1. The Batch Folder's "ContentTypeId" value (This is its Document Type's GUID).
  2. A list of key-value pairs for each single instance field extracted for the document.
    • For example, if you extracted a value (000-00-0000) for a "Social Sec Num" field you would see something like the following:
"FieldValues": [
  {
    "Key": "Social Sec Num",
    "Value": "000-00-0000"
  }
]
  • Note: "Key" names for Data Fields in single instance Data Sections are returned using dot notation (e.g. "DataSectionName.DataFieldName")


See below for an example response:

{
  "ContentTypeId": "812c3ce5-8334-47dc-bfb9-3c7be1c86e36",
  "FieldValues": [
    {
      "Key": "Header_Details.GUID",
      "Value": "29F17B36-3B51-41C1-811F-9FF8C91CDEFE"
    },
    {
      "Key": "Header_Details.Invoice_Number",
      "Value": "KRS8974"
    },
    {
      "Key": "Header_Details.Invoice_Date",
      "Value": "01/02/2020"
    },
    {
      "Key": "Header_Details.Invoice_Total",
      "Value": "$834.30"
    },
    {
      "Key": "Header_Details.Remit_To_Address",
      "Value": "123 Main St\r\nCity, ST 99999"
    }
  ]
}

Get page info for a specific folder

GET {baseUrl}/api/v1/BatchProcessing/Folders/{ParentId}/Pages?Recursive={Recursive}


This request returns information about pages in a folder. Enter the GUID for a Batch Folder and either "true" or "false" to indicate if the search is recursive.

  • For the recursive parameter, enter:
    • True if you want all pages from all levels below the Batch Folder
    • False if you want only pages at the given Batch Folder level.


Example when {Recursive} is False.

  • Here, there was only a single page at the selected Batch Folder's level.


Example JSON response when {Recursive} is False.

[
  {
    "Id": "afa2699d-6f71-40d1-9a33-0a3a8a233772",
    "Name": "Page 2",
    "NodeIndex": 1,
    "NumChildren": 0,
    "ParentId": "7d7984d4-ac9f-4742-9dfe-31e96311e403",
    "TypeName": "Grooper.Core.BatchPage",
    "DisplayImage": null,
    "Height": 11,
    "OriginalPageNo": 0,
    "PixelFormat": 0,
    "PrimaryImage": "Grooper.Image.pdf",
    "Width": 8.5
  }
]

Example when {Recursive} is True.

  • Here, there are two pages. One is at level 1 and the other at level 2.


Example JSON response when {Recursive} is False.

[
  {
    "Id": "a5502938-e76e-40e4-a8eb-8f4e44651617",
    "Name": "Page 1",
    "NodeIndex": 0,
    "NumChildren": 0,
    "ParentId": "74df0ea0-6225-4cc8-ae19-316906c3d017",
    "TypeName": "Grooper.Core.BatchPage",
    "DisplayImage": null,
    "Height": 11,
    "OriginalPageNo": 0,
    "PixelFormat": 0,
    "PrimaryImage": "Grooper.Image.pdf",
    "Width": 8.5
  },
  {
    "Id": "afa2699d-6f71-40d1-9a33-0a3a8a233772",
    "Name": "Page 2",
    "NodeIndex": 1,
    "NumChildren": 0,
    "ParentId": "7d7984d4-ac9f-4742-9dfe-31e96311e403",
    "TypeName": "Grooper.Core.BatchPage",
    "DisplayImage": null,
    "Height": 11,
    "OriginalPageNo": 0,
    "PixelFormat": 0,
    "PrimaryImage": "Grooper.Image.pdf",
    "Width": 8.5
  }
]

Get information about a published Batch Process

GET {baseUrl}/api/v1/BatchProcessing/Process?Process={Process}


This will return information about a published Batch Process, including information about each of its child steps.

You may enter one of the following for the {Process} parameter:

  • The published Batch Process's name.
  • A published Batch Process's corresponding working Batch Process's GUID.

You will return information about the current published version in either case.


Example when entering the published Batch Process's name.


Example when entering the working Batch Process's GUID.


Example JSON Response:

{
  "Id": "06a50482-633c-42e1-b455-435a5d4ddae3",
  "Name": "10 - Get Batch Process Info",
  "NodeIndex": 0,
  "NumChildren": 1,
  "ParentId": "b42eb137-326c-4bc0-9b05-048d01673ff9",
  "TypeName": "Grooper.Core.BatchProcess",
  "ParentProcessId": "9a8193fc-efe8-4c36-8b2e-4a4de1df760b",
  "PublishedDate": "/Date(1699453839000-0600)/",
  "Steps": [
    {
      "Id": "7051d45b-5c13-40c0-ba46-64b383e720e9",
      "Name": "Split Pages",
      "NodeIndex": 0,
      "NumChildren": 0,
      "ParentId": "06a50482-633c-42e1-b455-435a5d4ddae3",
      "TypeName": "Grooper.Core.BatchProcessStep",
      "ActivateMode": 0,
      "ActivityType": "Grooper.Activities.SplitPages",
      "FolderLevel": 1,
      "NextStepExpression": "",
      "Scope": 2,
      "ShouldSubmitExpression": "",
      "ThreadPool": null
    }
  ]
}


Error response when an invalid Batch Process name is passed:

{
  "Message": "Invalid Published Process Name."
}


Error response when an invalid Batch Process GUID is passed:

{
  "Message": "Invalid Working Process Id."
}

Get a list of all published Batch Processes

GET {baseUrl}/api/v1/BatchProcessing/Processes?Verbose={Verbose}


This returns a list of all published Batch Processes. You must enter <cdoe>True or False for {Verbose}

  • Verbose=False will return a simple list of published Batch Processes and some information about them (Their "Id", "Name", "ParentId" and more).
  • Verbose=True will return a nested list of published Batch Processes and information about about each of their steps.


Example when using Verbose=False


Example when using Verbose=True

Pause a Batch

GET {baseUrl}/api/v1/BatchProcessing/Batches/{BatchId}/Pause


This request will pause a Batch in production. Enter the Batch's GUID to pause it.

  • The JSON response will be property information about the Batch.
  • Note the "Status" value in the JSON response is "4". A status of "4" indicates the Batch is paused.


See below for an example response:

{
  "Id": "69a5c738-2ae4-4a85-9469-c7185cebffd2",
  "Name": "Invoices 2022-03-15 09:30:44 AM",
  "NodeIndex": 1,
  "NumChildren": 2,
  "ParentId": "9d73e0de-a2a5-449f-8f53-93680b55de37",
  "TypeName": "Grooper.Core.Batch",
  "Created": "/Date(1647354644443-0500)/",
  "CreatedBy": "BIS\\dgreenwood",
  "Priority": 3,
  "RootFolderId": "b169bfa7-2fc6-4ad8-8aeb-2723c303621d",
  "Status": 4,
  "StepNo": 5
}

Start/resume processing on a Batch

GET {baseUrl}/api/v1/BatchProcessing/Batches/{BatchId}/Start


This request will start processing a Batch or otherwise resume processing for a paused Batch. Enter a Batch's GUID to start processing it.

  • The JSON response will be property information about the Batch.
  • Note the "Status" value in the JSON response is "1". A status of "1" indicates the Batch is processing/working.


See below for an example response:

{
  "Id": "69a5c738-2ae4-4a85-9469-c7185cebffd2",
  "Name": "Invoices 2022-03-15 09:30:44 AM",
  "NodeIndex": 1,
  "NumChildren": 2,
  "ParentId": "9d73e0de-a2a5-449f-8f53-93680b55de37",
  "TypeName": "Grooper.Core.Batch",
  "Created": "/Date(1647354644443-0500)/",
  "CreatedBy": "BIS\\dgreenwood",
  "Priority": 3,
  "RootFolderId": "b169bfa7-2fc6-4ad8-8aeb-2723c303621d",
  "Status": 1,
  "StepNo": 5
}

Create a new Batch

POST {baseUrl}/api/v1/BatchProcessing/Processes/{ProcessName}/CreateBatch?BatchName={BatchName}


This request will create a new Batch in Grooper. This request has one required parameter and two optional parameters.

  • Required Parameters
    • You must enter a published Batch Process name for {ProcessName}
  • Optional Parameters
    • You may enter a name for the Batch by editing the {BatchName}. If this parameter is left blank, the Batch will be named with a timestamp (date/time created).
    • You may enter Batch level field values in JSON format.
      • The published Batch Process must have a Content Type assigned to it with corresponding Data Elements in its Data Model or you will get an error.