Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/records/definition/layouts/components/create

Requires JWT

Add a new component to a record definition's layout.

You can only change the layout if you have extended the definition.

If the parent component doesn't exist or doesn't accept children, you'll get an error.

If you don't specify before_component (or the specified component isn't in the layout or a child of the given parent), the new component is added at the end.

Request

POST /api/p/<project gid>/records/definition/layouts/components/create
Authorization: Bearer <JWT>

{
    "record": "<record gid>",
    "name": "optional component name",
    "type": "field",
    "options": {"field": "<field gid>", "style": "title"},
    "parent": "<component gid>",
    "before_component": "<component gid>"
}

record the record's gid
parent add the created component to this parent
type the type of component

optional

name the name of the component
options some types need extra options
before_component the created component is put before this component
language return data for this (project) language.
languages return data for these (project) languages.

If you request language and/or languages, you get the records' title and fields for the combined set. If you request neither, you'll get all available languages.

See layouts for types and options for components

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "record": "<record gid>",
        "definition": "<definition gid>",
        "layout": "<layout gid>",
        "component": "<new component gid>"
    },
    "data": {
        "records": {
            "<record gid>": {
                "gid": "<record gid>",
                "definition": "<definition gid>",
                
            }
        },
        "definitions": {
            "<definition gid>": {
                "gid": "<definition gid>",
                
            }
        },
        "layouts": {
            "<layout gid>": {
                "gid": "<layout gid>",
                
            }
        },
    }
}

result

record the record.
definition the record's definition is (now) a working copy.
layout the layout is (now) a working copy.
component the newly created component's gid - you can find it in the components property of the layout data.

data

records Record info with hierarchy, definition, field values.
definitions Definition info with name, classes, fields, and layout.
layouts Layout info with hierarchy.

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 - can't work with this item