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 |
-
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. |
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 |
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 |
- 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 |
- Pagination
-
Use the
page=…
andperPage=…
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 |
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 |
Creating a record
To create a record for a specific module, use the POST $ComposeAPI/namespace/$NAMESPACE_ID/module/$MODULE_ID/record
endpoint.
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\" }
]
}";
Deleting a record
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.