# Create/replace a secret POST https://api.prolific.com/api/v1/hooks/secrets/ Content-Type: application/json Generate a secret for verifying the request signature header of the subscription payload. If a secret already exists, this call will delete the old secret and create a new one. Reference: https://beta-docs.prolific.com/api-reference/webhooks/create-secret ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create/replace a secret version: endpoint_webhooks.CreateSecret paths: /api/v1/hooks/secrets/: post: operationId: create-secret summary: Create/replace a secret description: >- Generate a secret for verifying the request signature header of the subscription payload. If a secret already exists, this call will delete the old secret and create a new one. tags: - - subpackage_webhooks parameters: - name: Authorization in: header description: Header authentication of the form `undefined ` required: true schema: type: string responses: '201': description: Generated content: application/json: schema: $ref: '#/components/schemas/SecretDetail' '400': description: Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/CreateSecret' components: schemas: CreateSecret: type: object properties: workspace_id: type: string description: The ID of the workspace you are creating the secret in SecretDetail: type: object properties: id: type: string description: The ID of the secret. value: type: string description: The secret value. workspace_id: type: string description: The ID of the workspace that the secret belongs to. ``` ## SDK Code Examples ```python import requests url = "https://api.prolific.com/api/v1/hooks/secrets/" payload = { "workspace_id": "63519c1d5b139662f8cde482" } 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/secrets/'; const options = { method: 'POST', headers: {Authorization: '', 'Content-Type': 'application/json'}, body: '{"workspace_id":"63519c1d5b139662f8cde482"}' }; 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/secrets/" payload := strings.NewReader("{\n \"workspace_id\": \"63519c1d5b139662f8cde482\"\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/secrets/") 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 \"workspace_id\": \"63519c1d5b139662f8cde482\"\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.prolific.com/api/v1/hooks/secrets/") .header("Authorization", "") .header("Content-Type", "application/json") .body("{\n \"workspace_id\": \"63519c1d5b139662f8cde482\"\n}") .asString(); ``` ```php request('POST', 'https://api.prolific.com/api/v1/hooks/secrets/', [ 'body' => '{ "workspace_id": "63519c1d5b139662f8cde482" }', 'headers' => [ 'Authorization' => '', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.prolific.com/api/v1/hooks/secrets/"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"workspace_id\": \"63519c1d5b139662f8cde482\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "", "Content-Type": "application/json" ] let parameters = ["workspace_id": "63519c1d5b139662f8cde482"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolific.com/api/v1/hooks/secrets/")! 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() ```