Create a sub-account
Create an account for one of your end customers.
POST
/
v1
/
sub-accounts
Create a sub-account
curl --request POST \
--url https://api.querying.ai/v1/sub-accounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme",
"externalId": "cust_acme",
"monthlyCreditLimit": 200000,
"concurrencyLimit": 50
}
'import requests
url = "https://api.querying.ai/v1/sub-accounts"
payload = {
"name": "Acme",
"externalId": "cust_acme",
"monthlyCreditLimit": 200000,
"concurrencyLimit": 50
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Acme',
externalId: 'cust_acme',
monthlyCreditLimit: 200000,
concurrencyLimit: 50
})
};
fetch('https://api.querying.ai/v1/sub-accounts', 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.querying.ai/v1/sub-accounts",
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' => 'Acme',
'externalId' => 'cust_acme',
'monthlyCreditLimit' => 200000,
'concurrencyLimit' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.querying.ai/v1/sub-accounts"
payload := strings.NewReader("{\n \"name\": \"Acme\",\n \"externalId\": \"cust_acme\",\n \"monthlyCreditLimit\": 200000,\n \"concurrencyLimit\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.querying.ai/v1/sub-accounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Acme\",\n \"externalId\": \"cust_acme\",\n \"monthlyCreditLimit\": 200000,\n \"concurrencyLimit\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.querying.ai/v1/sub-accounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Acme\",\n \"externalId\": \"cust_acme\",\n \"monthlyCreditLimit\": 200000,\n \"concurrencyLimit\": 50\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "0199d2a4-5b10-7000-8000-000000000001",
"name": "Acme",
"externalId": "cust_acme",
"status": "active",
"monthlyCreditLimit": 200000,
"concurrencyLimit": 50,
"createdAt": "2026-10-09T09:00:00.000Z",
"suspendedAt": null,
"usage": {
"month": "2026-10",
"credits": 0,
"tasks": 0,
"reservedCredits": 0
}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "unknown field creditLimit; allowed: name, externalId, monthlyCreditLimit, concurrencyLimit",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}{
"success": false,
"error": {
"code": "MISSING_API_KEY",
"message": "Missing or invalid API key",
"timestamp": "2026-07-09T04:12:00.000Z"
}
}{
"success": false,
"error": {
"code": "SUB_ACCOUNT_FORBIDDEN",
"message": "Managing sub-accounts needs an API key without an engine scope or a daily credit limit",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}{
"success": false,
"error": {
"code": "SUB_ACCOUNT_EXISTS",
"message": "Another sub-account already has that externalId",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}Authorizations
Your API key, sent as Authorization: Bearer <key>.
Body
application/json
Required string length:
1 - 128Your id for this customer. A second create with the same value returns 409, so retries are safe.
Required string length:
1 - 128Credits it may be charged per UTC calendar month.
Required range:
0.01 <= x <= 20000000Must be a multiple of 0.01Its queued and running tasks, inside your own limit.
Required range:
1 <= x <= 100000⌘I
Create a sub-account
curl --request POST \
--url https://api.querying.ai/v1/sub-accounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme",
"externalId": "cust_acme",
"monthlyCreditLimit": 200000,
"concurrencyLimit": 50
}
'import requests
url = "https://api.querying.ai/v1/sub-accounts"
payload = {
"name": "Acme",
"externalId": "cust_acme",
"monthlyCreditLimit": 200000,
"concurrencyLimit": 50
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Acme',
externalId: 'cust_acme',
monthlyCreditLimit: 200000,
concurrencyLimit: 50
})
};
fetch('https://api.querying.ai/v1/sub-accounts', 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.querying.ai/v1/sub-accounts",
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' => 'Acme',
'externalId' => 'cust_acme',
'monthlyCreditLimit' => 200000,
'concurrencyLimit' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.querying.ai/v1/sub-accounts"
payload := strings.NewReader("{\n \"name\": \"Acme\",\n \"externalId\": \"cust_acme\",\n \"monthlyCreditLimit\": 200000,\n \"concurrencyLimit\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.querying.ai/v1/sub-accounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Acme\",\n \"externalId\": \"cust_acme\",\n \"monthlyCreditLimit\": 200000,\n \"concurrencyLimit\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.querying.ai/v1/sub-accounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Acme\",\n \"externalId\": \"cust_acme\",\n \"monthlyCreditLimit\": 200000,\n \"concurrencyLimit\": 50\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "0199d2a4-5b10-7000-8000-000000000001",
"name": "Acme",
"externalId": "cust_acme",
"status": "active",
"monthlyCreditLimit": 200000,
"concurrencyLimit": 50,
"createdAt": "2026-10-09T09:00:00.000Z",
"suspendedAt": null,
"usage": {
"month": "2026-10",
"credits": 0,
"tasks": 0,
"reservedCredits": 0
}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "unknown field creditLimit; allowed: name, externalId, monthlyCreditLimit, concurrencyLimit",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}{
"success": false,
"error": {
"code": "MISSING_API_KEY",
"message": "Missing or invalid API key",
"timestamp": "2026-07-09T04:12:00.000Z"
}
}{
"success": false,
"error": {
"code": "SUB_ACCOUNT_FORBIDDEN",
"message": "Managing sub-accounts needs an API key without an engine scope or a daily credit limit",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}{
"success": false,
"error": {
"code": "SUB_ACCOUNT_EXISTS",
"message": "Another sub-account already has that externalId",
"timestamp": "2026-10-09T09:00:00.000Z"
}
}