# Confirm a subscription POST https://api.prolific.com/api/v1/hooks/subscriptions/{subscription_id}/ Content-Type: application/json Confirm a subscription to an event type Reference: https://beta-docs.prolific.com/api-reference/webhooks/confirm-subscription ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Confirm a subscription version: endpoint_webhooks.ConfirmSubscription paths: /api/v1/hooks/subscriptions/{subscription_id}/: post: operationId: confirm-subscription summary: Confirm a subscription description: Confirm a subscription to an event type tags: - - subpackage_webhooks parameters: - name: subscription_id in: path description: Subscription id required: true schema: type: string - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '200': description: Confirmed content: application/json: schema: $ref: '#/components/schemas/SubscriptionDetail' '400': description: Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/SubscriptionConfirmation' components: schemas: SubscriptionConfirmation: type: object properties: secret: type: string description: >- The secret that was generated when the subscription was created and returned as the `X-Hook-Secret` header. required: - secret SubscriptionDetail: type: object properties: id: type: string description: The ID of the subscription. event_type: type: string description: The name of the event type associated to the subscription. target_url: type: string description: >- The URL that the subscription will notify when your event type is triggered. is_enabled: type: boolean description: Whether the subscription is enabled or not. workspace_id: type: string description: The ID of the workspace we will create the subscription in. required: - event_type - target_url - workspace_id ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/" payload = { "secret": "a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef" } headers = { "Authorization": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"secret":"a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/" payload := strings.NewReader("{\n \"secret\": \"a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "") 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 require 'uri' require 'net/http' url = URI("https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"secret\": \"a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"secret\": \"a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/', [ 'body' => '{ "secret": "a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"secret\": \"a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = ["secret": "a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx1234567890abcdef"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/hooks/subscriptions/subscription_id/")! 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() ```