Create a Query API endpoint
Creates a Query API endpoint.
POST
/
v1
/
organizations
/
{organizationId}
/
services
/
{serviceId}
/
query-api-endpoints
Create a Query API endpoint
curl --request POST \
--url https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"sql": "<string>",
"database": "<string>",
"apiKeyIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"roles": [
"<string>"
],
"parameters": {},
"allowedOrigins": []
}
'import requests
url = "https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints"
payload = {
"name": "<string>",
"sql": "<string>",
"database": "<string>",
"apiKeyIds": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"roles": ["<string>"],
"parameters": {},
"allowedOrigins": []
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
sql: '<string>',
database: '<string>',
apiKeyIds: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
roles: ['<string>'],
parameters: {},
allowedOrigins: []
})
};
fetch('https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'sql' => '<string>',
'database' => '<string>',
'apiKeyIds' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'roles' => [
'<string>'
],
'parameters' => [
],
'allowedOrigins' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"sql\": \"<string>\",\n \"database\": \"<string>\",\n \"apiKeyIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"roles\": [\n \"<string>\"\n ],\n \"parameters\": {},\n \"allowedOrigins\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"sql\": \"<string>\",\n \"database\": \"<string>\",\n \"apiKeyIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"roles\": [\n \"<string>\"\n ],\n \"parameters\": {},\n \"allowedOrigins\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"sql\": \"<string>\",\n \"database\": \"<string>\",\n \"apiKeyIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"roles\": [\n \"<string>\"\n ],\n \"parameters\": {},\n \"allowedOrigins\": []\n}"
response = http.request(request)
puts response.read_body{
"status": 201,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"result": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"sql": "<string>",
"database": "<string>",
"parameters": {},
"apiKeyIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"roles": [
"<string>"
],
"allowedOrigins": [
"<string>"
],
"url": "https://queries.clickhouse.cloud/run/00000000-0000-0000-0000-000000000000",
"ownerType": "user"
}
}{
"error": "<string>",
"status": 400,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "<string>",
"status": 403,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "<string>",
"status": 404,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "<string>",
"status": 500,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}Creates a Query API endpoint.
Permission
The API key must have the
control-plane:service:manage-query-api-endpoints permission.인증
Use key ID and key secret obtained in ClickHouse Cloud console: https://clickhouse.com/docs/cloud/manage/openapi
경로 매개변수
ID of the requested organization.
Pattern:
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$ID of the requested service.
Pattern:
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$본문
application/json
Name of the Query API endpoint.
Minimum string length:
1Pattern:
\SSQL executed by the endpoint.
Maximum string length:
4194304Pattern:
\SDatabase used by the Query API endpoint.
Pattern:
\SAPI key IDs allowed to call the endpoint.
Minimum array length:
1Pattern:
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$Database roles used by the endpoint.
Minimum array length:
1Minimum string length:
1Default query parameters.
Show child attributes
Show child attributes
Origins allowed by the endpoint CORS policy.
응답
The Query API endpoint was created.
마지막 수정일 2026년 10월 3일
⌘I
Create a Query API endpoint
curl --request POST \
--url https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"sql": "<string>",
"database": "<string>",
"apiKeyIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"roles": [
"<string>"
],
"parameters": {},
"allowedOrigins": []
}
'import requests
url = "https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints"
payload = {
"name": "<string>",
"sql": "<string>",
"database": "<string>",
"apiKeyIds": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"roles": ["<string>"],
"parameters": {},
"allowedOrigins": []
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
sql: '<string>',
database: '<string>',
apiKeyIds: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
roles: ['<string>'],
parameters: {},
allowedOrigins: []
})
};
fetch('https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'sql' => '<string>',
'database' => '<string>',
'apiKeyIds' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'roles' => [
'<string>'
],
'parameters' => [
],
'allowedOrigins' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"sql\": \"<string>\",\n \"database\": \"<string>\",\n \"apiKeyIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"roles\": [\n \"<string>\"\n ],\n \"parameters\": {},\n \"allowedOrigins\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"sql\": \"<string>\",\n \"database\": \"<string>\",\n \"apiKeyIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"roles\": [\n \"<string>\"\n ],\n \"parameters\": {},\n \"allowedOrigins\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.clickhouse.cloud/v1/organizations/{organizationId}/services/{serviceId}/query-api-endpoints")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"sql\": \"<string>\",\n \"database\": \"<string>\",\n \"apiKeyIds\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"roles\": [\n \"<string>\"\n ],\n \"parameters\": {},\n \"allowedOrigins\": []\n}"
response = http.request(request)
puts response.read_body{
"status": 201,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"result": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"sql": "<string>",
"database": "<string>",
"parameters": {},
"apiKeyIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"roles": [
"<string>"
],
"allowedOrigins": [
"<string>"
],
"url": "https://queries.clickhouse.cloud/run/00000000-0000-0000-0000-000000000000",
"ownerType": "user"
}
}{
"error": "<string>",
"status": 400,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "<string>",
"status": 403,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "<string>",
"status": 404,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": "<string>",
"status": 500,
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}