Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/classes/modify

Requires JWT

Modify a class.

You modify a class using a working copy. The original is unchanged until you commit your modifications. You can also revert the changes and get the original back.

You can use save_as_new to keep this version and the original.

When you get back the working copy, it will use a working copy of the layout too.

Note: you cannot add working copies of fields, only committed fields can be added.

Request

POST /api/p/<project gid>/classes/modify
Authorization: Bearer <JWT>

{
    "class": "<class gid>",
    "name": "article",
    "label": {"nl":"Artikel"},
}

class the gid of the class that is modified.

optional

name a code name for the class - must look like a variable name, using only upper/lowercase letters, digits, and underscores, and cannot start with a digit
label a localized label for the class, only the specified languages are updated
fields a list of field gids - which you should really manage with the classes/fields api
layout the layout gid for this class - you don't need to use this as you'll get a working copy of the layout automatically
metadata complete metadata dict - this overwrites any existing metadata, no merging - see metadata

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "class": "57393b5b-6e0a-4bf4-bf21-ee0500812f73"
    },
    "data": {
        "classes": {
            "57393b5b-6e0a-4bf4-bf21-ee0500812f73": {
                
            }
        },
        "layouts": {
            
        }
    }
}

result

class the working-copy class - perhaps not the same gid as the request.

data

classes Class info with name, fields.
layouts Layout info with hierarchy, if the layout changed to a working copy.

Error responses

400 Bad request - missing parameters or wrong type or value
401 Unauthorized - missing or expired JWT
403 Forbidden - not a member of this project
422 Unprocessable entity - modify failed