You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

Compose API

Any operation doable via the front-end application is doable via the API; either a single endpoint or a combination of.

The compose API is responsible for Corteza Low Code related resources such as modules, records and charts.

Whenever an operation affects Compose, you will most likely need to use the compose API.

We omit most of the data returned by these endpoints. We replace the important data with variables, such as $RECORD_ID so that we can copy-paste these examples over any environment.

  • URL path: /compose,

  • alias: $ComposeAPI,

Sending emails

To send an email to a recipient or a set of, call the POST $ComposeAPI/notification/email/send endpoint.

Refer to the API reference to find all the available parameters.

Make sure that you’ve properly configured your environment with the SMTP credentials.

Example request

curl "$ComposeAPI/notification/email" \
  -H "Authorization: Bearer $JWT" \
  --data "{
    \"to\": [\"$USER_EMAIL\"],
    \"subject\": \"Test CURL email\",
    \"content\": { \"html\": \"<div>Test Content</div>\" }
  }"

Example response

{
  "response": true
}

Record listing

Record listing provides you with a list of records that conform to the given constraints. Use this when you wish to show some sort of list of available records, such as a record list.

To list records stored under a specific module, use the GET $ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record endpoint.

Using filters

If you don’t need filtering simply omit this.

When filtering over records, use module field names as $PROPERTY_NAME in your expressions.

Filters allow you to define…​

Filter by data

Use the query=…​ query property to specify what items should be included in the response.

We provide a SQL-like query language in the form of $PROPERTY_NAME=$VALUE [$BITWISE_OPERATOR $PROPERTY_NAME=$VALUE […​]].

Sorting

Use the sort=…​ query property to specify how to the response items should be sorted.

We provide a SQL-like sorting language in the form of $PROPERTY_NAME $ORDER [, $PROPERTY_NAME $ORDER[, …​]].

Pagination

Use the page=…​ and perPage=…​ query properties to specify the pagination properties of the response.

Pagination is 1-based, meaning the first page index is 1.

If you wish to list all items, define perPage=0.

Example request

curl "$ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record?filter=$FIELD1+LIKE+'%25$VALUE1%25'+AND+$FIELD2+LIKE+'%25$VALUE2%25'&sort=$SORT_FIELD+$SORT_DIR&page=$PAGE&perPage=$PER_PAGE" \
  -H "Authorization: Bearer $JWT";

Example response

{
  "response": {
    "filter": {
      "moduleID": "$MODULE_ID",
      "namespaceID": "$NAMESPACE_ID",
      "query": "$FIELD1 LIKE '%$VALUE1%' AND $FIELD2 LIKE '%$VALUE2%'",
      "sort": "$SORT_FIELD $SORT_DIR",
      "page": $PAGE,
      "perPage": $PER_PAGE,
      "count": 1(1)
    },
    "set": [{
      "recordID": "$RECORD_ID",
      "moduleID": "$MODULE_ID",
      "namespaceID": "$NAMESPACE_ID",
      "values": [
        { "name": "fieldName", "value": "fieldValue" }
        ...
      ]
    }]
  }
}
1 The total number of records that match the provided filter.

Record reading

Record reading provides you a single record that you wish to get the details for. Use this when you wish to show a specific record, for example when clicking on a specific record in a record list.

To get a specific record stored under a specific module, use the GET $ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID endpoint.

If you wish to read multiple records at the same time, instead of making N requests, simply use Record listing with the query of query=recordID=$RECORD_ID_1+OR+recordID=$RECORD_ID_2+OR+…​

Example request

curl "$ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID" \
  -H "Authorization: Bearer $JWT";

Example response

{
  "response": {
    "recordID": "$RECORD_ID",
    "moduleID": "$MODULE_ID",
    "namespaceID": "$NAMESPACE_ID",
    "values": [
      { "name": "fieldName", "value": "fieldValue" }
      ...
    ]
  }
}

Creating a record

To create a record for a specific module, use the POST $ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record endpoint.

Example request

curl "$ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/" \
  -H "Authorization: Bearer $JWT" \
  -H 'Content-Type: application/json' \
  --data-binary "{
    \"values\": [
      { \"name\": \"$FIELD1\", \"value\": \"$VALUE1\" },
      { \"name\": \"$FIELD2\", \"value\": \"$VALUE2\" }
    ]
  }";

Example response

{
  "response": {
    "recordID": "$RECORD_ID",
    "moduleID": "$MODULE_ID",
    "namespaceID": "$NAMESPACE_ID",
    "values": [
      { "name": "$FIELD1", "value": "$$VALUE1" },
      { "name": "$FIELD2", "value": "$$VALUE2" },
    ]
  }
}

Updating a record

To update a specific record for a specific module, use the POST $ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID endpoint.

The new record values will be as provided in the update request. The values that are omitted in the update request will be removed from the given record.

Example request

curl "$ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID" \
  -H "Authorization: Bearer $JWT" \
  -H 'Content-Type: application/json' \
  --data-binary "{
    \"values\": [
      { \"name\": \"$FIELD1\", \"value\": \"$VALUE1\" },
      { \"name\": \"$FIELD2\", \"value\": \"$VALUE2\" }
    ]
  }";

Example response

{
  "response": {
    "recordID": "$RECORD_ID",
    "moduleID": "$MODULE_ID",
    "namespaceID": "$NAMESPACE_ID",
    "values": [
      { "name": "$FIELD1", "value": "$$VALUE1" },
      { "name": "$FIELD2", "value": "$$VALUE2" },
    ]
  }
}

Deleting a record

To delete a specific record for a specific module, use the DELETE $ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID endpoint.

Example request

curl -X DELETE "$ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID" \
  -H "Authorization: Bearer $JWT";

Example response

{
  "success": {
    "message":"OK"
  }
}

Download attachment

Attachments are protected resources and require you to generate a signature in order to access them.

To download the attachment you must perform the following:

Obtain a signed download URL

When fetching a specific attachment via the GET $ComposeAPI/namespace/$NAMESPACE_ID/attachment/record/$ATTACHMENT_ID or listing attachments via the GET $ComposeAPI/namespace/$NAMESPACE_ID/attachment/record you will receive the following JSON object:

{
  "attachmentID": "$ATTACHMENT_ID",
  "ownerID": "$USER_ID",
  "url": "$ATTACHMENT_ORIGINAL_URL",(1)
  "previewUrl": "$ATTACHMENT_PREVIEW_URL",(2)
  "name": "$FILENAME_ORIGINAL",
  "meta": {...},
  "namespaceID": "$NAMESPACE_ID"
}
1 url contains a signed URL path to the attachment.
2 previewUrl contains a signed URL path to the preview version of the attachment, when available.

Example request

curl "$ComposeAPI/namespace/$NAMESPACE_ID/attachment/record/$ATTACHMENT_ID" \
 -H "Authorization: Bearer $JWT";

Example response

{
  "response": {
    "attachmentID": "$ATTACHMENT_ID",
    "ownerID": "$USER_ID",
    "url": "$ATTACHMENT_ORIGINAL_URL",
    "previewUrl": "$ATTACHMENT_PREVIEW_URL",
    "name": "$FILENAME_ORIGINAL",
    "meta": {...},
    "namespaceID": "$NAMESPACE_ID"
  }
}

Download the attachment

Use the attachments response.url property to get the path of the downloadable attachment. For example, /namespace/$NAMESPACE_ID/attachment/record/$ATTACHMENT_ID/original/$ATTACHMENT_NAME.$ATTACHMENT_EXT?sign=$ATTACHMENT_SIGNATURE&userID=$SIGNATURE_OWNER.

Get the full path by joining the compose API base URL and the provided attachment path. For example: $composeAPI/$ATTACHMENT_ORIGINAL_URL.

You can then use any approach you wish to either display or download the attachment, such as using the <a href="…​">…​</a> element, using Axios or any other client.