Unicat API Reference

Up - API Reference - Home


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

Requires JWT.

Create linked records in bulk using the selection parameter.

Processing is done as a job running in the background, it may be incomplete when you receive the response. Job progress can be queried using the returned job.token.

Learn more about the selection parameter and responses to bulk requests.

Request

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

{
    "parent": "9c5e1c75-6b81-44e1-a3fc-1b41ec9ba58b",
    "before_record": "e1c3e5cb-2a98-434c-87e3-b14e95e94a1b",
    "ordering": "87b53a4e-359d-45c7-81cb-5e1c3ef444ec",
    "selection": [
        "<gid-1>",
        "<gid-2>",
        "<gid-3>",
        {
            "children": "<gid-9>",
            "channel": <channel key>,
            "exclude": ["<gid-x>", "<gid-y>", "<gid-z>"],
        },
        {
            "search": {
                "language": "nl",
                "q": "+cms 225",
                "filter": ["classes", "has", "article"],
            },
            "exclude": ["<gid-a>", "<gid-b>", "<gid-c>"]
        },
    ],
}

parent is the parent gid for the linked copies of all records in the selection and must exist.
selection is the selection of records to link.

For children entries, we support optional channel and ordering parameters. The ordering for children can be different from the ordering key for the link.

optional

before_record is the gid for the next sibling; the linked records are placed before this one in the current ordering. If it isn't given, the records are placed last.
ordering the current ordering.

Success response

For many bulk operations, we don't report on individual items, because that report can potentially be very large, or it is processed in the background. We return a job.token, and you can look for it when you handle sync information - we report on the job while it is running and post a completion status there as soon as the operation is done.

Authorization: <JWT>

{
    "success": true,
    "result": {
        "job.token": "7c136ddb-4dfa-4ec1-bad4-15067cbf80d9",
    },
    "data": {}
}

result

job.token the job token to look for in sync events.

Job status

Look for the job.token in sync events to find status updates on the operation. The sync event looks like this:

{
    "type": "cc",
    "cursor": <cursor>,
    "action": "UPDATE",
    "data_type": "jobs",
    "data_key": "7c136ddb-4dfa-4ec1-bad4-15067cbf80d9",
    "data": {
        "project_gid": "<project_gid>",
        "job": "bulk_link_records",
        "status": "processing",
        "info": {
            "total": 120,
            "remaining": 26
        },
        "created_on": 1613565541.4195538,
        "updated_on": 1613565543.2836412,
    }
}

status can be either queued, rejected, processing, or done.

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
1006 Selection error - selection or cursor parameter is invalid