If you enable Register update REST API Endpoint switcher in Relation settings https://prnt.sc/5uVcmW01T7sk
then you can update relation items and / or meta
Endpoint URL is https://your-site.com/wp-json/jet-rel/RELATION_ID
Method - POST
Relation ID can be found in Relation URL when editing it
Authenticate with Application Password
When you are usind REST API with JetFormBuilder you can use form field macros, like "%post_id%"
For array values (like checkbox, multiple select, etc.) - do not wrap macros into quotes
Parameters:
- parent_id, child_id - single ID or array of IDs
- context - either "child" or "parent"
"child" means we replace / update (add) / disconnect child(ren) of parent(s)
"parent" means we replace / update (add) / disconnect parent(s) of child(ren) - store_items_type - "replace" / "update" / "disconnect"
Example:
Relation is Many to Many
Set two children with IDs of 267234 and 267235 to parent with ID of 686
Parameters:
- parent_id - 686
- child_id - [267234,267235]
- context - "child" so that we replace children for the parent
- store_items_type - "replace"
{
"parent_id": 686,
"child_id": [267234,267235],
"context": "child",
"store_items_type": "replace",
}
If you need to update relation meta, only one pair of parent / child should be updated.
Example:
Update relation meta for the parent-child pair 686-267234
"meta" is an object where keys are meta field keys, and values are meta field values;
for timestamp types you can pass date in a human readable format, it will be converted automatically.
All possible meta types have an example value here.
{
"parent_id": 686,
"child_id": 267234,
"context": "child",
"store_items_type": "update",
"meta": {
"text": "test phrase",
"date": "2023-11-11",
"date_timestamp": "2023-11-11",
"time": "11:00",
"datetime": "2023-11-11T11:00",
"datetime_timestamp": "2023-11-11T11:00",
"checkbox": [
"op1",
"op2"
],
"media_id":266280,
"media_url":"https://SOME.URL",
"media_array": {
"id": 266280,
"url": "https://SOME.URL"
},
"radio": "op1",
"select1": "op2",
"select_multiple": [
"op1",
"op2"
]
}
}