# Unsubscribe from Publication POST /api/v2/publications/{id}/unsubscribe/ Unsubscribes the authenticated user from a publication. Reference: https://docs.aisquare.studio/api-reference/ai-square-studio-api/publications/publication-unsubscribe-create ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: AISquare Studio API version: 1.0.0 paths: /api/v2/publications/{id}/unsubscribe/: post: operationId: unsubscribe-create summary: Unsubscribe from Publication description: Unsubscribes the authenticated user from a publication. tags: - subpackage_publications parameters: - name: id in: path required: true schema: type: integer responses: '200': description: '' content: application/json: schema: $ref: >- #/components/schemas/publications_unsubscribeCreate_Response_200 components: schemas: publications_unsubscribeCreate_Response_200: type: object properties: detail: type: string title: publications_unsubscribeCreate_Response_200 ``` ## SDK Code Examples ```python User successfully unsubscribed import requests url = "https://api.example.com/api/v2/publications/1/unsubscribe/" response = requests.post(url) print(response.json()) ``` ```javascript User successfully unsubscribed const url = 'https://api.example.com/api/v2/publications/1/unsubscribe/'; const options = {method: 'POST'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go User successfully unsubscribed package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/api/v2/publications/1/unsubscribe/" req, _ := http.NewRequest("POST", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby User successfully unsubscribed require 'uri' require 'net/http' url = URI("https://api.example.com/api/v2/publications/1/unsubscribe/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) response = http.request(request) puts response.read_body ``` ```java User successfully unsubscribed import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v2/publications/1/unsubscribe/") .asString(); ``` ```php User successfully unsubscribed request('POST', 'https://api.example.com/api/v2/publications/1/unsubscribe/'); echo $response->getBody(); ``` ```csharp User successfully unsubscribed using RestSharp; var client = new RestClient("https://api.example.com/api/v2/publications/1/unsubscribe/"); var request = new RestRequest(Method.POST); IRestResponse response = client.Execute(request); ``` ```swift User successfully unsubscribed import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v2/publications/1/unsubscribe/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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 User was already unsubscribed import requests url = "https://api.example.com/api/v2/publications/1/unsubscribe/" response = requests.post(url) print(response.json()) ``` ```javascript User was already unsubscribed const url = 'https://api.example.com/api/v2/publications/1/unsubscribe/'; const options = {method: 'POST'}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go User was already unsubscribed package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.example.com/api/v2/publications/1/unsubscribe/" req, _ := http.NewRequest("POST", url, nil) res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby User was already unsubscribed require 'uri' require 'net/http' url = URI("https://api.example.com/api/v2/publications/1/unsubscribe/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) response = http.request(request) puts response.read_body ``` ```java User was already unsubscribed import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.example.com/api/v2/publications/1/unsubscribe/") .asString(); ``` ```php User was already unsubscribed request('POST', 'https://api.example.com/api/v2/publications/1/unsubscribe/'); echo $response->getBody(); ``` ```csharp User was already unsubscribed using RestSharp; var client = new RestClient("https://api.example.com/api/v2/publications/1/unsubscribe/"); var request = new RestRequest(Method.POST); IRestResponse response = client.Execute(request); ``` ```swift User was already unsubscribed import Foundation let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/api/v2/publications/1/unsubscribe/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ```