Reference / Quick guide
The most important calls at a glance, each with curl. Details can be found in API configuration, Data interface and Queries.
CMS=https://cms.example.org
USER='my-account:my-password'
APIs (schema)
# Namespaces, APIs of a namespace, description of an API
curl -u "$USER" "$CMS/schema"
curl -u "$USER" "$CMS/schema/my-ns"
curl -u "$USER" "$CMS/schema/my-ns/my-api"
# Create, change (replaces the description completely), delete (including all records!)
curl -X POST -u "$USER" -H 'Content-Type: application/json' -d @schema.json "$CMS/schema/my-ns/my-api"
curl -X PUT -u "$USER" -H 'Content-Type: application/json' -d @schema.json "$CMS/schema/my-ns/my-api"
curl -X DELETE -u "$USER" "$CMS/schema/my-ns/my-api"
Records
# First page of all records, or a single record
curl -u "$USER" "$CMS/data/my-ns/my-api"
curl -u "$USER" "$CMS/data/my-ns/my-api/<id>"
# For display: finished HTML and file URLs
curl -u "$USER" "$CMS/data/my-ns/my-api/<id>?exported"
# Create, change (only the changed fields), delete
curl -X POST -u "$USER" -H 'Content-Type: application/json' -d @record.json "$CMS/data/my-ns/my-api"
curl -X PUT -u "$USER" -H 'Content-Type: application/json' -d '{ "title": "New" }' "$CMS/data/my-ns/my-api/<id>"
curl -X DELETE -u "$USER" "$CMS/data/my-ns/my-api/<id>"
# Query with filter, sorting and paging
curl -X POST -u "$USER" -H 'Content-Type: application/json' \
-d '{ "filter": { "age": { "$gte": 18 } }, "sort": { "name": "ascending" }, "pageSize": 20 }' \
"$CMS/data/my-ns/my-api/query"
Files
# Upload a record with a file
curl -X POST -u "$USER" \
-F 'data={ "title": "Image", "image": { "path": "file1", "name": "image.png" } }' \
-F 'file1=@image.png' "$CMS/data/my-ns/my-api"
# Retrieve a file (path from the record)
curl -u "$USER" -o image.png "$CMS/media/my-ns/my-api/<path>"
# Short-lived token (5 minutes) for retrieval without an Authorization header, e.g. in <img>
curl -u "$USER" "$CMS/token"
Export and import
curl -u "$USER" -o export.zip "$CMS/data/my-ns/_export/.*"
curl -X POST -u "$USER" -H 'Content-Type: application/zip' --data-binary @export.zip "$CMS/import" # check only
curl -X POST -u "$USER" -H 'Content-Type: application/zip' --data-binary @export.zip "$CMS/import?execute&insertOnly"
Account
# Logged-in account and roles
curl -u "$USER" "$CMS/user"
# Set password (administrator)
curl -X POST -u 'admin:<password>' -H 'Content-Type: application/json' \
-d '{ "account": "my-account", "password": "<new password>" }' "$CMS/data/cms/users/actions/password"