This article describes the basics of working with cases in the Pattern API. This covers:
- Creating new cases
- Updating existing cases
- Getting case data
- Getting case profile data
- Generating and retrieving profile exports
Guidance on uploading and downloading documents to and from cases is available in the Working with Documents article.
Creating New Cases
To create cases, use the "pattern/case/create" endpoint.
Simple Case Creation
Creating a case in the Pattern API requires a lens, a unique identifier (typically a matter id or case id of your own), first name, last name, and DOB. An example for creating a simple case with no extra information may look like the following:
curl --location 'https://service.patterndata.io/pattern/case/create' \
--header 'Content-Type: application/json' \
--header 'Accept: text/plain' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"lensId": "paraquat",
"id": "MAT-122344111",
"claimantGivenName": "John",
"claimantSurname": "Doe",
"dateOfBirth": "1990-01-01"
}'The "id" provided in the body is the primary identifier for this case in your Pattern account, and must be unique across all of your lenses. This id will be the primary mechanism to interact with a given case within the Pattern API.
Case Creation with Custom Properties
For lenses with custom properties configured, they can be provided in the following structure on case creation.
curl --location 'https://service.patterndata.io/pattern/case/create' \
--header 'Content-Type: application/json' \
--header 'Accept: text/plain' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"lensId": "paraquat",
"id": "MAT-122344111",
"claimantGivenName": "John",
"claimantSurname": "Doe",
"dateOfBirth": "1990-01-01"
"properties": [
{
"key": "property_1_name",
"value": "Property Value"
},
{
"key": "property_2_name",
"value": "Property Value 2"
}
]
}'
Custom properties can also be configured to accept json data. This data is sent and returned as a string. On load, Pattern will parse the json to ensure validity, but it will be transmitted as a string, meaning it will need to be serialized and parsed separately from the main body.
curl --location 'https://service.patterndata.io/pattern/case/create' \
--header 'Content-Type: application/json' \
--header 'Accept: text/plain' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"lensId": "paraquat",
"id": "MAT-122344111",
"claimantGivenName": "John",
"claimantSurname": "Doe",
"dateOfBirth": "1990-01-01"
"properties": [
{
"key": "property_1_name",
"value": "Property Value"
},
{
"key": "json_property_name",
"value": "{\"my_val\": 1, \"alt_val\": 4}"
}
]
}'Updating Cases
Cases can be updated using the "pattern/case/update" endpoint. Generally, the body follows a very similar structure to case creation. The primary differences between create and update are:
- Update does not take a "lensId"
- Update can take an "assigneeEmail", which can be used to update the assignee to any valid Pattern user.
An example of updating a case with a new property, and changing its assignee, might look like the following:
curl --location 'https://service.patterndata.io/pattern/case/update' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"id": "MAT-122344111",
"claimantGivenName": "Timothy",
"stateOfResidence": "VA",
"properties": [
{
"key": "property_1_name",
"value": "Updated Property 1 Value"
}
],
"assigneeEmail": "new_user@yourfirm.com"
}'The above request would update the case "MAT-122344111" such that:
- The first name would be changed from "John" to "Timothy"
- The state of residence would be changed from NULL to "VA"
- The first property would be changed from "Property Value" to "Updated Property 1 Value"
- The case would be assigned to the user with email "new_user@yourfirm.com"
Getting Case Data
Case data is segmented into 2 components. "Main" data is data that can be created/updated with the case consistent with the Create Case and Update Case endpoints. Profile data consists of lens specific data points configured specifically to that profile, along with any information for pinned document references. Consequently, any two cases in two different lenses will have profile data that follows an entirely different schema based on the lens configuration.
Case Main Data
There are 2 options for retrieving case main data. The List Cases endpoint covered in the Working with Lenses article will return most case data when returning the list of cases requested by that endpoint. . To get this data for an individual case, use the "pattern/case/get" endpoint. A request to get data for an individual case might look like the following:
curl --location 'https://service.patterndata.io/pattern/case/get' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"caseId": "MAT-122344111"
}'Case Profile Data
Profile data can be retrieved with the "pattern/case/getProfile" endpoint. A request to get profile data might look like the following:
curl --location 'https://service.patterndata.io/pattern/case/getProfile' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"caseId": "MAT-122344111"
}'The return for this section will vary based on your profile specification. Use the OpenAPI specification and Postman to explore your specific lens profile data.
Profile Exports
Profile exports in Pattern allow you to create a "to-go" packet of key profile data. The configuration tool in the UI allows you to customize these exports for future use. Creating a profile export is an asynchronous operation.
Step 1: Trigger Export
The first step is to trigger the profile export using the "pattern/case/triggerProfileExport" endpoint. A request to trigger that export might look like the following:
curl --location 'https://service.patterndata.io/pattern/case/triggerProfileExport' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"caseId": "MAT-122344111",
"configName": "Medical Proof Packet"
}'This will initiate export generation for the specified configuration for the specified case. This request will return a "caseExportId" within the body, which can be used in subsequent steps.
Step 2: Get Export URL
Most case exports complete in 2-5 seconds. After an export has been triggered, use the "pattern/case/getProfileExportUrl" endpoint to retrieve a URL that can be used to download the export. A request to get the URL might look like the following:
curl --location 'https://service.patterndata.io/pattern/case/getProfileExportUrl' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <Your Token>' \
--data '{
"caseExportId": 123456,
"inline": false
}'The "inline" setting allows for a synchronous download if set to "true", but is not recommended. If the export is ready, this endpoint will return a pre-signed S3 URL that can be used to download the export.
Step 3: Download with Pre-Signed Link
A download from the pre-signed link might look like the following:
curl --location --request GET '<Your URL>'