# Toggle Bookmark POST /api/v1/publications/blogs/{blog_id}/bookmark/ Content-Type: application/json Adds or removes a bookmark for a specific blog. Reference: https://docs.aisquare.studio/api-reference/ai-square-studio-api/publications/toggle-bookmark ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: AISquare Studio API version: 1.0.0 paths: /api/v1/publications/blogs/{blog_id}/bookmark/: post: operationId: toggle-bookmark summary: Toggle Bookmark description: Adds or removes a bookmark for a specific blog. tags: - subpackage_publications parameters: - name: blog_id in: path description: The ID of the blog to bookmark/unbookmark required: true schema: type: integer responses: '200': description: Bookmark removed successfully content: application/json: schema: $ref: '#/components/schemas/publications_toggle_bookmark_Response_200' '400': description: Invalid blog ID content: application/json: schema: $ref: '#/components/schemas/Toggle_bookmarkRequestBadRequestError' '401': description: Unauthorized content: application/json: schema: description: Any type '404': description: Blog not found content: application/json: schema: $ref: '#/components/schemas/Toggle_bookmarkRequestNotFoundError' requestBody: content: application/json: schema: $ref: '#/components/schemas/BookmarkResponse' components: schemas: BookmarkResponse: type: object properties: message: type: string error: type: string required: - message description: Serializer for bookmark response title: BookmarkResponse publications_toggle_bookmark_Response_200: type: object properties: message: type: string title: publications_toggle_bookmark_Response_200 Toggle_bookmarkRequestBadRequestError: type: object properties: error: type: string title: Toggle_bookmarkRequestBadRequestError Toggle_bookmarkRequestNotFoundError: type: object properties: error: type: string title: Toggle_bookmarkRequestNotFoundError ``` ## SDK Code Examples ```python Bookmark Removed Example import requests url = "https://api.example.com/api/v1/publications/blogs/1/bookmark/" payload = { "message": "Toggle bookmark status for blog ID 1" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Bookmark Removed Example const url = 'https://api.example.com/api/v1/publications/blogs/1/bookmark/'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"message":"Toggle bookmark status for blog ID 1"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Bookmark Removed Example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/api/v1/publications/blogs/1/bookmark/" payload := strings.NewReader("{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Bookmark Removed Example require 'uri' require 'net/http' url = URI("https://api.example.com/api/v1/publications/blogs/1/bookmark/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}" response = http.request(request) puts response.read_body ``` ```java Bookmark Removed Example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v1/publications/blogs/1/bookmark/") .header("Content-Type", "application/json") .body("{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}") .asString(); ``` ```php Bookmark Removed Example request('POST', 'https://api.example.com/api/v1/publications/blogs/1/bookmark/', [ 'body' => '{ "message": "Toggle bookmark status for blog ID 1" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Bookmark Removed Example using RestSharp; var client = new RestClient("https://api.example.com/api/v1/publications/blogs/1/bookmark/"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Bookmark Removed Example import Foundation let headers = ["Content-Type": "application/json"] let parameters = ["message": "Toggle bookmark status for blog ID 1"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v1/publications/blogs/1/bookmark/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ```python Bookmark Added Example import requests url = "https://api.example.com/api/v1/publications/blogs/1/bookmark/" payload = { "message": "Toggle bookmark status for blog ID 1" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Bookmark Added Example const url = 'https://api.example.com/api/v1/publications/blogs/1/bookmark/'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"message":"Toggle bookmark status for blog ID 1"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Bookmark Added Example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/api/v1/publications/blogs/1/bookmark/" payload := strings.NewReader("{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Bookmark Added Example require 'uri' require 'net/http' url = URI("https://api.example.com/api/v1/publications/blogs/1/bookmark/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}" response = http.request(request) puts response.read_body ``` ```java Bookmark Added Example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v1/publications/blogs/1/bookmark/") .header("Content-Type", "application/json") .body("{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}") .asString(); ``` ```php Bookmark Added Example request('POST', 'https://api.example.com/api/v1/publications/blogs/1/bookmark/', [ 'body' => '{ "message": "Toggle bookmark status for blog ID 1" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Bookmark Added Example using RestSharp; var client = new RestClient("https://api.example.com/api/v1/publications/blogs/1/bookmark/"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"message\": \"Toggle bookmark status for blog ID 1\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Bookmark Added Example import Foundation let headers = ["Content-Type": "application/json"] let parameters = ["message": "Toggle bookmark status for blog ID 1"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v1/publications/blogs/1/bookmark/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```