OnyxMetric
Sites

Update Private Link Config

Generates or revokes a private link key for sharing analytics without authentication. Requires the editor role or above on the site.

POST /api/sites/:siteId/private-link-config

Generates or revokes a private link key for sharing analytics without authentication. Requires the editor role or above on the site.

Path Parameters

Prop

Type

Request Body

Prop

Type

Response

Prop

Type

Data Object

Prop

Type

Request
curl -X POST "https://app.onyxmetric.com/api/sites/123/private-link-config" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"action": "generate_private_link_key"}'
Request
const response = await fetch(
  'https://app.onyxmetric.com/api/sites/123/private-link-config',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      action: 'generate_private_link_key'
    })
  }
);

const data = await response.json();
Request
import requests

response = requests.post(
    'https://app.onyxmetric.com/api/sites/123/private-link-config',
    json={
        'action': 'generate_private_link_key'
    },
    headers={
        'Authorization': 'Bearer your_api_key_here'
    }
)

data = response.json()
Request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.onyxmetric.com/api/sites/123/private-link-config');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'action' => 'generate_private_link_key'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer your_api_key_here',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
Request
require 'net/http'
require 'json'

uri = URI('https://app.onyxmetric.com/api/sites/123/private-link-config')
req = Net::HTTP::Post.new(uri)
req['Authorization'] = 'Bearer your_api_key_here'
req['Content-Type'] = 'application/json'
req.body = { action: 'generate_private_link_key' }.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
data = JSON.parse(res.body)
Request
body := bytes.NewBuffer([]byte(`{"action": "generate_private_link_key"}`))
req, _ := http.NewRequest("POST", "https://app.onyxmetric.com/api/sites/123/private-link-config", body)
req.Header.Set("Authorization", "Bearer your_api_key_here")
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()

var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
Request
let client = reqwest::Client::new();
let res = client
    .post("https://app.onyxmetric.com/api/sites/123/private-link-config")
    .header("Authorization", "Bearer your_api_key_here")
    .json(&serde_json::json!({
        "action": "generate_private_link_key"
    }))
    .send()
    .await?;

let data: serde_json::Value = res.json().await?;
Request
HttpClient client = HttpClient.newHttpClient();
String json = "{\"action\": \"generate_private_link_key\"}";
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://app.onyxmetric.com/api/sites/123/private-link-config"))
    .header("Authorization", "Bearer your_api_key_here")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
Request
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer your_api_key_here");

var content = new StringContent(
    "{\"action\": \"generate_private_link_key\"}",
    Encoding.UTF8,
    "application/json"
);

var response = await client.PostAsync("https://app.onyxmetric.com/api/sites/123/private-link-config", content);
var data = await response.Content.ReadAsStringAsync();
Response
{
  "success": true,
  "data": {
    "privateLinkKey": "f6e5d4c3b2a1"
  }
}