Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/records/link

Requires JWT.

Create a linked copy of a record.

Copy a record and move it to a new parent, return the copy. The original is set as the canonical record, creating a link that makes sure all linked records are updated in sync. If the original already is a link, we use their canonical to have everything point at the same canonical record.

The place where the record is inserted is determined by before_record, which should be a child of the parent. If before_record is given, the record is placed before that record, and all subsequent siblings are placed accordingly. If before_record is not given, this means that the record should be the last child of the parent. This also works if the parent is currently empty.

A linked copy cannot have children.

If the title of the linked copy exists under the parent, we update it to indicate we've made a linked copy.

Request

POST /api/p/<project gid>/records/link
Authorization: Bearer <JWT>

{
    "record": "f2e64fe0-9ffa-4d9a-8750-d561d6542453",
    "parent": "9c5e1c75-6b81-44e1-a3fc-1b41ec9ba58b",
    "before_record": "e1c3e5cb-2a98-434c-87e3-b14e95e94a1b",
    "ordering": "87b53a4e-359d-45c7-81cb-5e1c3ef444ec"
}

record gid for the record we are copying and linking.
parent is the parent gid for the linked record and must exist.
ordering the current ordering.

optional

before_record is the gid for the next sibling; the linked record is placed before this one in the current ordering. If it isn't given, the record is placed last.
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.

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "record": "f5a05b94-b02b-43d5-a154-b9fc04c4a679",
        "parent": "9c5e1c75-6b81-44e1-a3fc-1b41ec9ba58b"
    },
    "data": {
        "records": {
            "f5a05b94-b02b-43d5-a154-b9fc04c4a679": {
                "gid": "f5a05b94-b02b-43d5-a154-b9fc04c4a679",
                "canonical": "f2e64fe0-9ffa-4d9a-8750-d561d6542453",  // link to the source
                "parent": "9c5e1c75-6b81-44e1-a3fc-1b41ec9ba58b",
                "is_link": true,
                
            },
            "9c5e1c75-6b81-44e1-a3fc-1b41ec9ba58b": {
                
            }
        }
    }
}

result

record the newly copied and linked record.
parent the parent of this record.

data

records Record info with hierarchy, definition, field values. Unordered.

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 - parent record doesn't exist