{"id":1100,"url":"https://forum.supero.dev/t/linking-an-order-to-a-customer-after-both-exist-1100","title":"Linking an order to a customer after both exist","type":"question","status":"solved","category":{"slug":"api-sdk-cli","name":"API, SDKs & CLI"},"tags":["crud","data-model"],"author":{"handle":"supero-support","name":"Supero Support","team":true},"created":"2026-12-04T02:40:31.705Z","updated":"2026-12-04T02:40:31.705Z","upvotes":0,"error_text":null,"environment":{"client":null,"sdk_version":null,"deploy_target":null},"body_markdown":"Both records are already created. What's the call to link the order to its customer, and how do I list a customer's orders afterwards?","answers":[{"id":"98c70d37-9831-4c02-ab15-0cd228ffe25a","url":"https://forum.supero.dev/t/linking-an-order-to-a-customer-after-both-exist-1100#post-98c70d37-9831-4c02-ab15-0cd228ffe25a","author":{"handle":"supero-platform","name":"Supero Platform team","team":true},"accepted":true,"official":false,"outdated":false,"sdk_version":null,"upvotes":0,"created":"2026-12-04T02:40:31.705Z","updated":"2026-12-04T02:40:31.705Z","body_markdown":"Declare the link in the order schema's `references[]`, then add it with `ref-update`:\n\n```bash\ncurl -X PUT https://api.supero.dev/api/v1/crud/acme/ref-update \\\n  -H \"Authorization: Bearer $TOKEN\" -H \"Content-Type: application/json\" \\\n  -d '{\"type\": \"order\", \"uuid\": \"<order uuid>\", \"ref-type\": \"customer\", \"ref-uuid\": \"<customer uuid>\", \"operation\": \"ADD\"}'\n```\n\n`operation` is `ADD`, `UPDATE` or `DELETE`. For many edits in one call, `PUT /api/v1/crud/{domain}/ref-update-multi` takes an `updates` array of the same entries. In Python it's `org.crud.set_ref(\"order\", order_uuid, \"customer\", customer_uuid)`.\n\nFrom the order, `GET /api/v1/crud/acme/order/{uuid}/refs/customer` returns the link. From the customer, `GET /api/v1/crud/acme/customer/{uuid}/back-refs?back_ref_type=order` lists the orders pointing at it, and `POST /list-bulk` with `\"type\": \"order\"` and `back_ref_id` does the same with paging.\n\nAdding a reference needs create or update permission on the order and read on the customer. Changing or removing one needs update on both.","comments":[]}],"licence":"CC BY-SA 4.0 (code: MIT-0)"}