Update database

Update a database tree

Add, update or delete a resource, lock, or role in the database tree.

Request

POST https://www.activityinfo.org/resources/databases/{databaseId}

Request body

application/json

object
resourceUpdates array[object] List of resources to add or update. required
resourceDeletions array[string] List of resource ids to delete from the database. required
lockUpdates array[object] List of locks to add or update required
lockDeletions array[string] List of lock ids to delete required
roleUpdates array[object] List of roles to add or update. required
roleDeletions array[string] List of role ids to delete. required
languageUpdates array[string] List of languages to add or update required
languageDeletions array[string] List of languages to delete required
originalLanguage string Original language update optional

Successful response

application/json

object
databaseId string This database's id required
userId string The id of the requesting user. The contents of the tree depends on the permissions of the requesting user. optional
version string The monotonically-increasing version of the database tree. The version number is incremented whenever a change is made that affects the database tree. required
label string This database's human-readable label. required
description string required
ownerRef object required
language string Current database language required
originalLanguage string Original database language optional
languages array[string] The languages that have been defined for this database translation. required
continuousTranslation boolean True if the database continuous automatic translation is enabled required
translationFromDbMemory boolean True if automatic translation from database memory is allowed for the database required
thirdPartyTranslation boolean True if third-party translation is allowed for the database required
suspended boolean True if this database is suspended for billing reasons required
role object The requesting user's assigned role in this database. required
roles array[object] The roles that have been defined for this database. required
securityCategories array[object] The security categories that have been defined for this database. required
resources array[object] The set of resources (folders, forms, and subforms) that belong to this database. required
locks array[object] The record locks that have been defined on this database. required
grants array[object] The permission grants that have been made to the requesting user for this database. required
billingAccountId integer required

Error responses

Status Code Error Code Description
401 AUTHENTICATION_REQUIRED The request must be authenticated

Examples

Add a folder

You can add a folder by including it in the list of resourceUpdates. If a folder with the given id does not exist, it will be added.

curl -X POST https://www.activityinfo.org/resources/databases/ck8oykh8m5 \
  -u anything:APITOKEN \
  -H 'Content-type: application/json' \
  --data-binary @- << EOF
{
  "resourceUpdates": [
    {
      "id": "ceponkikiswy1bt2",
      "parentId": "ck8oykh8m5",
      "label": "My new folder",
      "type": "FOLDER"
    },
    {
      "id": "clfl7zq12ohs",
      "parentId": "ceponkikiswy1bt2",
      "label": "My subfolder",
      "type": "FOLDER"
    }
  ]
}
EOF

Delete a form, folder, or report from the database.

You can delete a resource by including its id in the resourceDeletions list. Note that subforms cannot be deleted through this endpoint, a subform can only be deleted by removing its field from the form schema.

curl -X POST https://www.activityinfo.org/resources/databases/ck8oykh8m5 \
  -u anything:APITOKEN \
  -H 'Content-type: application/json' \
  --data-binary @- << EOF
{
  "resourceDeletions": [
    "ceponkikiswy1bt2"
  ]
}
EOF

Add new role

curl -X POST https://www.activityinfo.org/resources/databases/ck8oykh8m5 \
  -u anything:APITOKEN \
  -H 'Content-type: application/json' \
  --data-binary @- << EOF
{
  "roleUpdates": [
    {
      "id": "cht8p4kdeimokm5",
      "label": "Reporting partner",
      "permissions": [
        {
          "operation": "VIEW",
          "filter": "REPORTING_PARTNER == @user.partner && INCIDENT_TYPE != 'GBV'"
        },
        {
          "operation": "EDIT_RECORD",
          "filter": "REPORTING_PARTNER == @user.partner && INCIDENT_TYPE != 'GBV'"
        },
        {
          "operation": "ADD_RECORD",
          "filter": "REPORTING_PARTNER == @user.partner && INCIDENT_TYPE != 'GBV'"
        },
        {
          "operation": "EXPORT_RECORDS"
        }
      ],
      "parameters": [
        {
          "parameterId": "partner",
          "label": "Partner",
          "range": "ck8oyloog8"
        }
      ],
      "filters": [
        {
          "id": "partner",
          "label": "where record is the user's partner and is not GBV",
          "filter": "REPORTING_PARTNER == @user.partner && INCIDENT_TYPE != 'GBV'"
        }
      ],
      "version": 0,
      "grantBased": false
    }
  ]
}
EOF

Add rule based lock

curl -X POST https://www.activityinfo.org/resources/databases/ck8oykh8m5 \
  -u anything:APITOKEN \
  -H 'Content-type: application/json' \
  --data-binary @- << EOF
{
  "lockUpdates": [
    {
      "id": "clfl85yy0sdi8uc1",
      "label": "February reporting",
      "resourceId": "ck8oykh8m5",
      "dateRange": {
        "start": "2023-01-01",
        "end": "2023-01-31"
      },
      "deactivated": false
    }
  ]
}
EOF

Set original language

curl -X POST https://www.activityinfo.org/resources/databases/ck8oykh8m5 \
  -u anything:APITOKEN \
  -H 'Content-type: application/json' \
  --data-binary @- << EOF
{
  "originalLanguage": "FR"
}
EOF

Add languages for translation

curl -X POST https://www.activityinfo.org/resources/databases/ck8oykh8m5 \
  -u anything:APITOKEN \
  -H 'Content-type: application/json' \
  --data-binary @- << EOF
{
  "languageUpdates": [
    "FA",
    "PS"
  ]
}
EOF
Next item
Update database translations