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

Working With Low Code Records

Listing Records

To search over records for a specific module, use the GET $BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/ endpoint.

Refer to the documentation on how to get the complete reference.

curl -X GET "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/" \
  -H 'accept: application/json, text/plain, */*' \
  -H "authorization: Bearer $JWT" \
  --compressed;
{
  "response": {
    "filter": {
      "moduleID": "$MODULE_ID",
      "namespaceID": "$NAMESPACE_ID",
      "query": "",
      "deleted": 0,
      "sort": "id"
    },
    "set": [
      {}
    ]
  }
}

Filtering Records

To search over records for a specific module, use the GET $BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/ endpoint with the query query parameter.

Refer to the documentation on how to get the complete reference.

curl -X GET "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/?query=f2='value+2'" \
  -H 'accept: application/json, text/plain, */*' \
  -H "authorization: Bearer $JWT" \
  --compressed;
{
  "response": {
    "filter": {
      "moduleID": "$MODULE_ID",
      "namespaceID": "$NAMESPACE_ID",
      "query": "f2='value 2'",
      "deleted": 0,
      "sort": "id"
    },
    "set": [
      {}
    ]
  }
}

Filtering Records With Missing Values

A record value can have two states — existing and nonexisting. When the value is nonexisting, it is NULL.

To exemplify; a checkbox field can either be true, false, and NULL, therefore we three values are recognized instead of two.

The following examples use three records:
  • { "name": "a", "good": true }

  • { "name": "b", "good": false }

  • { "name": "c", "good": NULL }

Finding Records Where the Value Is NULL

curl "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/?query=good+IS+NULL" \
  -H 'accept: application/json, text/plain, */*' \
  -H "authorization: Bearer $JWT" \
  --compressed;
{
    "response": {
        "filter": {
            "moduleID": "$MODULE_ID",
            "namespaceID": "$NAMESPACE_ID",
            "query": "good IS NULL",
            "deleted": 0,
            "sort": "id"
        },
        "set": [
            {
                "recordID": "$RECORD_ID",
                "moduleID": "$MODULE_ID",
                "values": [
                    {
                        "name": "name",
                        "value": "c"
                    }
                ],
                "namespaceID": "$NAMESPACE_ID"
            }
        ]
    }
}

Finding Records Where the Value Is NULL or false

curl "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/?query=good+IS+NULL+OR+good=false" \
  -H 'accept: application/json, text/plain, */*' \
  -H "authorization: Bearer $JWT" \
  --compressed | pp_json;
{
    "response": {
        "filter": {
            "moduleID": "$MODULE_ID",
            "namespaceID": "$NAMESPACE_ID",
            "query": "good IS NULL OR good=false",
            "deleted": 0,
            "sort": "id"
        },
        "set": [
            {
                "recordID": "$RECORD_ID",
                "moduleID": "$MODULE_ID",
                "values": [
                    {
                        "name": "good"
                    },
                    {
                        "name": "name",
                        "value": "b"
                    }
                ],
                "namespaceID": "$NAMESPACE_ID"
            },
            {
                "recordID": "$RECORD_ID",
                "moduleID": "$MODULE_ID",
                "values": [
                    {
                        "name": "name",
                        "value": "c"
                    }
                ],
                "namespaceID": "$NAMESPACE_ID"
            }
        ]
    }
}

Updating Records

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

The record update API endpoint sets record values to exactly what was provided in the request. If you wish to update only specific fields, first fetch the original record, change the desired values, then update the record.

The fields you omit in the request are removed from the record (value sanitation, automation, and other system processes may still define the value).

Example of Omitting Existing Values

The following request sets the second field and resets the first (already populated) one:
curl -X POST "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID" \
  -H 'Accept: application/json, text/plain, */*' \
  -H "Authorization: Bearer $JWT" \
  -H 'Content-Type: application/json' \
  --data-raw '{ "values": [
    { "name": "f2", "value": "value 2" }
  ]}
' \
  --compressed
The following response is produced by the above request:
{
  "response": {
    "recordID": "$RECORD_ID",
    "moduleID": "$MODULE_ID",
    "values": [
      { "name": "f2", "value": "value 2" }
    ],
    "namespaceID": "$NAMESPACE_ID"
  }
}

Example of Preserving Existing Values

The following request sets the second field and preserves the first (already populated) one:
curl -X POST "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID" \
  -H 'Accept: application/json, text/plain, */*' \
  -H "Authorization: Bearer $JWT" \
  -H 'Content-Type: application/json' \
  --data-raw '{ "values": [
    { "name": "f1", "value": "value 1" },
    { "name": "f2", "value": "value 2" }
  ]}
' \
  --compressed
The following response is produced by the above request:
{
  "response": {
    "recordID": "$RECORD_ID",
    "moduleID": "$MODULE_ID",
    "values": [
      { "name": "f1", "value": "value 1" },
      { "name": "f2", "value": "value 2" }
    ],
    "namespaceID": "$NAMESPACE_ID"
  }
}

Creating Records

To search over records for a specific module, use the POST $BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/ endpoint.

Refer to the documentation on how to get the complete reference.

curl -X POST "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/" \
  -H 'accept: application/json, text/plain, */*' \
  -H "authorization: Bearer $JWT" \
  -H 'Content-Type: application/json' \
  --data-raw '{ "values": [
    { "name": "f1", "value": "value 1" },
    { "name": "f2", "value": "value 2" }
  ]}' \
  --compressed;
{
  "response": {
    "recordID": "RECORD_ID",
    "moduleID": "MODULE_ID",
    "values": [
      { "name": "f1", "value": "value 1" },
      { "name": "f2", "value": "value 2" }
    ],
    "namespaceID": "NAMESPACE_ID"
  }
}

Read records

To search over records for a specific module, use the GET $BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID endpoint.

Refer to the documentation on how to get the complete reference.

curl -X GET "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID" \
  -H 'accept: application/json, text/plain, */*' \
  -H "authorization: Bearer $JWT" \
  --compressed;
{
  "response": {
    "recordID": "RECORD_ID",
    "moduleID": "MODULE_ID",
    "values": [
      { "name": "f1", "value": "value 1" },
      { "name": "f2", "value": "value 2" }
    ],
    "namespaceID": "NAMESPACE_ID"
  }
}

Deleting Records

To search over records for a specific module, use the DELETE $BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID endpoint.

Refer to the documentation on how to get the complete reference.

curl -X DELETE "$BASE_URL/compose/namespace/$NAMESPACE_ID/module/$MODULE_ID/record/$RECORD_ID" \
  -H 'accept: application/json, text/plain, */*' \
  -H "authorization: Bearer $JWT" \
  --compressed;
{ "success": { "message": "OK" } }