{"_id":"56cf49208acacb1300814884","parentDoc":null,"version":{"_id":"56c35c56c0c4630d004e864f","project":"56c35c56c0c4630d004e864c","__v":8,"createdAt":"2016-02-16T17:28:54.864Z","releaseDate":"2016-02-16T17:28:54.864Z","categories":["56c35c57c0c4630d004e8650","56c7b9e5379b311700ed8fe3","56c7bab4606ee717003c4766","56c7bb3613e5400d001e8cbd","56cf3f5a5267d70b00494c4b","56cf3f866c5d7a13005ee894","56fd3956caad892200847bce","599da256e7742b002588bb02"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"0.5.0","version":"0.5"},"user":"56c39c05bc41330d009f25d7","githubsync":"","project":"56c35c56c0c4630d004e864c","__v":3,"category":{"_id":"56c35c57c0c4630d004e8650","version":"56c35c56c0c4630d004e864f","__v":17,"pages":["56c35c58c0c4630d004e8652","56c38f9c2d97560d00e23cb8","56c39b11e1e4190d003429b0","56c3a90c28bd680d005e7aa3","56c7b98a8bf67e0d0073477a","56c7b9d7379b311700ed8fe1","56c7bcc55652c217008e0923","56c7bee8606ee717003c4769","56cf423f8629f91300fd9779","56cf45b944c5700b0095c175","56cf4709287eb20b009f9eec","56cf49208acacb1300814884","56cf4c4c287eb20b009f9f01","56cf4d968629f91300fd9797","56cf4ede8acacb1300814890","56cf520b8629f91300fd97a9","56cf52d5287eb20b009f9f12"],"project":"56c35c56c0c4630d004e864c","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-02-16T17:28:55.483Z","from_sync":false,"order":0,"slug":"documentation","title":"Buzz API Overview"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-25T18:34:08.712Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[]},"method":"delete","results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":6,"body":"Deletes use the http `DELETE` verb. In order to delete an object you must pass the unique key of that object. For example, if you wish to delete a `user`, the `user_id` field must be present in the JSON request (other fields are ignored). Note, that most object have extensive validation to prevent data inconsistencies and it may not always be possible to delete an object. Generally, to delete something in Buzz you need to be assured that no other object is dependent on the object to be deleted. For example, Buzz will not allow you to delete an `Advertiser`, if a `Campaign` belongs to that Advertiser.\n[block:api-header]\n{\n  \"type\": \"delete\",\n  \"title\": \"Example DELETEs\"\n}\n[/block]\nSome examples of successful and unsuccessful DELETE requests:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X DELETE \\\"[host]/rest/advertiser\\\" -b cookies.txt -d '{\\\"advertiser_name\\\":\\\"new name\\\"}'\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nUNSUCCESSFUL: `advertiser_id` must be provided\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X DELETE \\\"[host]/rest/advertiser\\\" -b cookies.txt -d '{\\\"advertiser_id\\\":1}'\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nSUCCESSFUL: `advertiser_id` 1 is deleted\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X DELETE \\\"[host]/rest/advertiser\\\" -b cookies.txt -d '{\\\"advertiser_id\\\":[1,2]}'\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nSUCCESSFUL: `advertiser_id` 1 and 2 are deleted\n[block:api-header]\n{\n  \"type\": \"delete\",\n  \"title\": \"Example DELETE Requests\"\n}\n[/block]\nIn order to delete an object you must use the object's unique ID. You can include this ID in the request path as shorthand, as shown in this example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X DELETE \\\"[host]/rest/user/1\\\" -b cookies.txt\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nWhich is equivalent to: \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X DELETE \\\"[host]/rest/user\\\" -b cookies.txt -d '{\\\"user_id\\\":1}'\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nUsing the ID in the path may be desirable since the http specification does not support a data payload on DELETE and some IDEs may not allow it.\n\nWhen deleting multiple objects, pass the IDs as a list:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -X DELETE \\\"[host]/rest/user\\\" -b cookies.txt -d '{\\\"user_id\\\":[1,2,3]}'\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"delete\",\n  \"title\": \"Multiple Object Deletes\"\n}\n[/block]\nWhen deleting multiple objects the http status and messaging will vary depending on whether all, none, or some of the objects were successfully deleted as shown below:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Successful Updates\",\n    \"h-1\": \"HTTP status\",\n    \"h-2\": \"Message\",\n    \"0-0\": \"All\",\n    \"0-1\": \"200\",\n    \"0-2\": \"Success message\",\n    \"1-0\": \"Partial\",\n    \"1-1\": \"200\",\n    \"1-2\": \"WARNING message. The \\\"payload\\\" object will provide details on why some deletes failed.\",\n    \"2-0\": \"None\",\n    \"2-1\": \"406 or other error code as appropriate\",\n    \"2-2\": \"ERROR message. The \\\"payload\\\" object will provide details on why deletes failed.\"\n  },\n  \"cols\": 3,\n  \"rows\": 3\n}\n[/block]\nWhen using \"Strict mode\" the API will treat any errors as fatal and will not delete any objects. This may be useful if your application wishes to avoid partial deletes.","excerpt":"","slug":"delete-ing-objects-with-the-api","type":"endpoint","title":"DELETE-ing Objects with the API"}

deleteDELETE-ing Objects with the API


Deletes use the http `DELETE` verb. In order to delete an object you must pass the unique key of that object. For example, if you wish to delete a `user`, the `user_id` field must be present in the JSON request (other fields are ignored). Note, that most object have extensive validation to prevent data inconsistencies and it may not always be possible to delete an object. Generally, to delete something in Buzz you need to be assured that no other object is dependent on the object to be deleted. For example, Buzz will not allow you to delete an `Advertiser`, if a `Campaign` belongs to that Advertiser. [block:api-header] { "type": "delete", "title": "Example DELETEs" } [/block] Some examples of successful and unsuccessful DELETE requests: [block:code] { "codes": [ { "code": "curl -X DELETE \"[host]/rest/advertiser\" -b cookies.txt -d '{\"advertiser_name\":\"new name\"}'", "language": "curl" } ] } [/block] UNSUCCESSFUL: `advertiser_id` must be provided [block:code] { "codes": [ { "code": "curl -X DELETE \"[host]/rest/advertiser\" -b cookies.txt -d '{\"advertiser_id\":1}'", "language": "curl" } ] } [/block] SUCCESSFUL: `advertiser_id` 1 is deleted [block:code] { "codes": [ { "code": "curl -X DELETE \"[host]/rest/advertiser\" -b cookies.txt -d '{\"advertiser_id\":[1,2]}'", "language": "curl" } ] } [/block] SUCCESSFUL: `advertiser_id` 1 and 2 are deleted [block:api-header] { "type": "delete", "title": "Example DELETE Requests" } [/block] In order to delete an object you must use the object's unique ID. You can include this ID in the request path as shorthand, as shown in this example: [block:code] { "codes": [ { "code": "curl -X DELETE \"[host]/rest/user/1\" -b cookies.txt", "language": "curl" } ] } [/block] Which is equivalent to: [block:code] { "codes": [ { "code": "curl -X DELETE \"[host]/rest/user\" -b cookies.txt -d '{\"user_id\":1}'", "language": "curl" } ] } [/block] Using the ID in the path may be desirable since the http specification does not support a data payload on DELETE and some IDEs may not allow it. When deleting multiple objects, pass the IDs as a list: [block:code] { "codes": [ { "code": "curl -X DELETE \"[host]/rest/user\" -b cookies.txt -d '{\"user_id\":[1,2,3]}'", "language": "curl" } ] } [/block] [block:api-header] { "type": "delete", "title": "Multiple Object Deletes" } [/block] When deleting multiple objects the http status and messaging will vary depending on whether all, none, or some of the objects were successfully deleted as shown below: [block:parameters] { "data": { "h-0": "Successful Updates", "h-1": "HTTP status", "h-2": "Message", "0-0": "All", "0-1": "200", "0-2": "Success message", "1-0": "Partial", "1-1": "200", "1-2": "WARNING message. The \"payload\" object will provide details on why some deletes failed.", "2-0": "None", "2-1": "406 or other error code as appropriate", "2-2": "ERROR message. The \"payload\" object will provide details on why deletes failed." }, "cols": 3, "rows": 3 } [/block] When using "Strict mode" the API will treat any errors as fatal and will not delete any objects. This may be useful if your application wishes to avoid partial deletes.