Skip to content

Setup a collection

Note: IF you have already applied a template then you can skip this step of creating workflows and fields.

Step 2.2.2: Create workflows and fields in a collection using individual API's

Creating workflows, fields in a collections is done in following steps and order:

A: Create Workflow

B: Get FieldTypes

C: Create Fields

A: Create Workflow

Workflows are created inside collections and can be created by passing following parameters:

POST /workflows

Mandatory Body parameters
Parameter Comment
collection_id Collection ID where the workflow will be created
workspace_id ID of workspace of the collection
classification Types of items this workflow will recieve. ( One of ['SUPPLIER_INVOICE','CUSTOMER_INVOICE','CREDIT_INVOICE','RECEIPT','OTHER','REMINDER'])
name Name of the workflow

Example

{
  "collection_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "classification": "string",
  "workspace_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "name": "string"
}

B: Get FieldTypes

Once we have a workflow, we need to add fields to it, Aiida has some pre-defined field-types which you can use. Get id's of these pre-defined field types by following API call:

GET /field_types/shared

Example Response

{
[
  {
    "id": "3334fe76-5e70-4256-8bb2-1dfe6bdc0eb0",
    "created_at": "2019-09-19 12:51:49.245100",
    "updated_at": "2019-09-19 12:51:49.245107",
    "name": "E-mail Address",
    "workspace_id": null,
    "formatter": [
      "VALUE"
    ],
    "validator": [
      "REGEXP_MATCH",
      "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$",
      "VALUE"
    ],
    "shared": true
  }
]
}

Save the id's from the response, we will need them in step 2.2.3

C: Create Fields

Fields for a workflow can be created by following API call:

POST /fields

Mandatory Body parameters
Parameter Comment
field_type_id Field Type ID of the field to be created (See step 2.2.2)
workflow_id ID of workflow of the field
shared true/false (Can be shared with your other workflows)
name Name of the field
required true/false (The field should always be needed for an item in this workflow)

Example

{
  "field_type_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "required": true,
  "shared": true,
  "name": "string",
  "workflow_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}