curl --request POST \
--url https://brew.new/api/v1/data \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"command": "db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'"
}
EOFimport requests
url = "https://brew.new/api/v1/data"
payload = { "command": "db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'" }
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({
command: 'db find audiences --fields name,cachedCount --limit 10 | jq -r \'.name\''
})
};
fetch('https://brew.new/api/v1/data', 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://brew.new/api/v1/data",
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([
'command' => 'db find audiences --fields name,cachedCount --limit 10 | jq -r \'.name\''
]),
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://brew.new/api/v1/data"
payload := strings.NewReader("{\n \"command\": \"db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'\"\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://brew.new/api/v1/data")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://brew.new/api/v1/data")
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 \"command\": \"db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'\"\n}"
response = http.request(request)
puts response.read_body{
"exitCode": 0,
"output": "Newsletter VIPs\nChurn risks\n\n[stderr]\n# 2 row(s)",
"truncated": false
}{
"error": {
"code": "INVALID_API_KEY",
"type": "authentication_error",
"message": "The provided API key is invalid.",
"suggestion": "Check the API key format and retry with a valid active key.",
"docs": "https://docs.brew.new/api-reference/api/authentication"
}
}{
"error": {
"code": "RATE_LIMITED",
"type": "rate_limit",
"message": "Too many requests.",
"suggestion": "Wait for the retry window before sending another request.",
"docs": "https://docs.brew.new/api-reference/api/rate-limits",
"retryAfter": 42
}
}{
"error": {
"code": "INTERNAL_ERROR",
"type": "internal_error",
"message": "An unexpected error occurred.",
"suggestion": "Retry the request. If it keeps failing, contact support.",
"docs": "https://docs.brew.new/api-reference/api/errors"
}
}Run a data command
One unified surface over the brand’s data: runs a sandboxed bash command with the db verbs (db ls / db schema <table> / db find / db agg / db get / db insert / db set / db del) plus jq/grep/sort/head pipes. find and agg take --since/--until time ranges (epoch ms, ISO, or relative like 7d) on every table; agg aggregates server-side (—fn count|sum:f|avg:f|min:f|max:f, —group-by, —bucket hour|day|week|month) — the same engine behind the MCP run_data_command tool and the in-app agent. Start with db ls (tables your credential may touch) and db schema <table>. find prints NDJSON on stdout; counts and the next-page cursor arrive on stderr. Tables are permission-scoped per credential; writes are policy-gated, and a refusal names the endpoint that owns the operation. A failed COMMAND is still HTTP 200 with exitCode != 0 and the message in output — read the output, adjust, retry.
curl --request POST \
--url https://brew.new/api/v1/data \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"command": "db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'"
}
EOFimport requests
url = "https://brew.new/api/v1/data"
payload = { "command": "db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'" }
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({
command: 'db find audiences --fields name,cachedCount --limit 10 | jq -r \'.name\''
})
};
fetch('https://brew.new/api/v1/data', 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://brew.new/api/v1/data",
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([
'command' => 'db find audiences --fields name,cachedCount --limit 10 | jq -r \'.name\''
]),
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://brew.new/api/v1/data"
payload := strings.NewReader("{\n \"command\": \"db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'\"\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://brew.new/api/v1/data")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://brew.new/api/v1/data")
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 \"command\": \"db find audiences --fields name,cachedCount --limit 10 | jq -r '.name'\"\n}"
response = http.request(request)
puts response.read_body{
"exitCode": 0,
"output": "Newsletter VIPs\nChurn risks\n\n[stderr]\n# 2 row(s)",
"truncated": false
}{
"error": {
"code": "INVALID_API_KEY",
"type": "authentication_error",
"message": "The provided API key is invalid.",
"suggestion": "Check the API key format and retry with a valid active key.",
"docs": "https://docs.brew.new/api-reference/api/authentication"
}
}{
"error": {
"code": "RATE_LIMITED",
"type": "rate_limit",
"message": "Too many requests.",
"suggestion": "Wait for the retry window before sending another request.",
"docs": "https://docs.brew.new/api-reference/api/rate-limits",
"retryAfter": 42
}
}{
"error": {
"code": "INTERNAL_ERROR",
"type": "internal_error",
"message": "An unexpected error occurred.",
"suggestion": "Retry the request. If it keeps failing, contact support.",
"docs": "https://docs.brew.new/api-reference/api/errors"
}
}Authorizations
Send your Brew API key as Authorization: Bearer brew_xxx.
Headers
The brand this request acts on. REQUIRED for organization-scoped credentials (otherwise 400 BRAND_ID_REQUIRED — there is no default brand); list ids with GET /v1/brands. Brand-scoped credentials may omit it, and sending a different brand returns 403 BRAND_SCOPE_MISMATCH. A brand outside your organization returns 404 BRAND_NOT_FOUND.
1 - 64Body
Bash command line, e.g.: db find audiences name=vip --fields name | jq -r '.name'
1 - 4000Response
Command result. exitCode 0 = success; non-zero = the command failed (message in output).
Was this page helpful?