From 91d84aa249a2f46280f298a8807246fe10d8e674 Mon Sep 17 00:00:00 2001 From: Thomas Ritter Date: Thu, 29 Aug 2024 14:30:57 +0200 Subject: [PATCH] Create/update/delete units (#322) --- sections/units.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/sections/units.md b/sections/units.md index 432eb4a..86dcb81 100644 --- a/sections/units.md +++ b/sections/units.md @@ -64,3 +64,47 @@ curl -X GET \ 'https://{domain}.mocoapp.com/api/v1/units/{id}' \ -H 'Authorization: Token token=YOUR_API_KEY' ``` + +## POST /units + +Create a unit: + +```bash +curl -X POST \ + 'https://{domain}.mocoapp.com/api/v1/units' \ + -H 'Authorization: Token token=YOUR_API_KEY' \ + -H 'Content-Type: application/json' \ + -d '{ + "name": "A great new team" + }' +``` + +{: .note } +Assigning a user is possible by [updating it](users.md#put-usersid) with the `unit_id` attribute. + +## PUT /units/{id} + +Update a unit: + +```bash +curl -X PUT \ + 'https://{domain}.mocoapp.com/api/v1/units/{id}' \ + -H 'Authorization: Token token=YOUR_API_KEY' \ + -H 'Content-Type: application/json' \ + -d '{ + "name": "A new name" + }' +``` + +Fields are analogous to the POST request. + +## DELETE /users/{id} + +{: .note } +Deleting a unit is only possible if no users are assigned to it. Move existing users to a different unit by [updating them](users.md#put-usersid) with the `unit_id` attribute. + +```bash +curl -X DELETE \ + 'https://{domain}.mocoapp.com/api/v1/units/{id}' \ + -H 'Authorization: Token token=YOUR_API_KEY' +``` \ No newline at end of file