Matrix Generation API
The Matrix Generation API creates combinatorial audience topics by computing the cartesian product of multiple dimension value arrays. For example, crossing 52 US states with 6 age ranges generates 312 classified topics in a single request. Classification uses the local rule-based engine (no LLM calls), making this endpoint fast and cost-free for bulk generation.
POST /api/topics/generate-matrix
Generate topics from a cartesian product of dimensions.
Auth: API key with classify scope, or Clerk session
POST /api/topics/generate-matrix
Request Body
{
"dimensions": [
{
"name": "State",
"values": ["California", "Texas", "New York", "Florida"]
},
{
"name": "Age Range",
"values": ["18-24", "25-34", "35-44", "45-54", "55-64", "65+"]
}
],
"template": "{State} {Age Range} Audience",
"segmentType": "B2C",
"parentCategory": "Demographics"
}
| Field | Type | Required | Description |
|---|---|---|---|
dimensions | array | Yes | At least 2 dimensions, each with name and values |
dimensions[].name | string | Yes | Dimension name (e.g., "State", "Age Range") |
dimensions[].values | string[] | Yes | Dimension values (at least 1 per dimension) |
template | string | No | Topic name template using {DimensionName} placeholders. Defaults to joining values with spaces. |
segmentType | string | No | Override segment type for all generated topics |
parentCategory | string | No | Override parent category (41 types) for all generated topics |
taxonomyType | string | No | Override taxonomy type group (13 groups) for all generated topics |
Combination Limit
The total number of combinations (cartesian product) must not exceed 5,000 topics. For the example above: 4 states x 6 age ranges = 24 topics.
Response (200)
{
"batchId": "matrix_1740000000000_a3b7c9",
"totalTopics": 24,
"created": 22,
"duplicates": 0,
"errors": 2,
"topicIds": ["ot_01...", "ot_02...", "ot_03..."]
}
| Field | Type | Description |
|---|---|---|
batchId | string | Unique identifier for this generation batch |
totalTopics | number | Total combinations computed |
created | number | Topics successfully created |
duplicates | number | Topics skipped due to existing duplicates |
errors | number | Topics that failed classification |
topicIds | string[] | IDs of newly created topics |
curl Example
curl -X POST https://app.audiencegpt.com/api/topics/generate-matrix \
-H "Authorization: Bearer txadv_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"dimensions": [
{
"name": "Seniority",
"values": ["C-Suite", "VP", "Director", "Manager", "Individual Contributor"]
},
{
"name": "Department",
"values": ["Marketing", "Engineering", "Sales", "Finance", "HR"]
}
],
"template": "{Seniority} - {Department}",
"segmentType": "B2B"
}'
TypeScript Example
interface MatrixRequest {
dimensions: { name: string; values: string[] }[];
template?: string;
segmentType?: string;
parentCategory?: string;
taxonomyType?: string;
}
async function generateMatrix(request: MatrixRequest) {
const response = await fetch(
"https://app.audiencegpt.com/api/topics/generate-matrix",
{
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.error);
}
return response.json();
}
// Generate B2B firmographic matrix: 5 seniority x 15 departments = 75 topics
const result = await generateMatrix({
dimensions: [
{ name: "Seniority", values: ["C-Suite", "VP", "Director", "Manager", "IC"] },
{ name: "Department", values: ["Marketing", "Engineering", "Sales", "Finance", "HR",
"Operations", "Legal", "IT", "Product", "Design", "Customer Success",
"Business Development", "Data Science", "Security", "Procurement"] },
],
template: "{Seniority} {Department} Decision Makers",
segmentType: "B2B",
parentCategory: "Business Technology",
});
Known Dimension Sets
AudienceGPT includes 22 pre-built dimension value sets based on IAB, Experian, and Acxiom standards. When using the chatbot UI, natural language like "state by age" auto-resolves to the full US State and Age Range dimensions.
Demographic Dimensions
| Dimension | Values |
|---|---|
| Age Range | 18-24, 25-34, 35-44, 45-54, 55-64, 65+ |
| Gender | Male, Female, Non-Binary |
| Income Range | Under $25K, $25K-$50K, $50K-$75K, $75K-$100K, $100K-$150K, $150K-$200K, $200K-$300K, $300K-$500K, $500K+ |
| Net Worth | 13 ranges from Under $50K to $10M+ |
| Education Level | High School, Some College, Associate, Bachelor, Master, Doctorate |
| Marital Status | Single, Married, Divorced, Widowed, Separated |
| Homeownership | Owner, Renter, Other |
| Presence of Children | No Children, Has Children, Infant (0-2), Young (3-5), School Age (6-12), Teen (13-17) |
| Household Size | 1, 2, 3-4, 5+ |
| Ethnicity | 7 categories |
| Language | 10 languages |
| Life Stage | 9 stages |
| Home Value | 7 ranges |
| Length of Residence | 5 ranges |
| Employment Status | 6 statuses |
Geographic Dimensions
| Dimension | Values |
|---|---|
| US State | 50 states + DC + Puerto Rico (52 values) |
Firmographic Dimensions
| Dimension | Values |
|---|---|
| Seniority Level | C-Suite, VP, Director, Manager, Individual Contributor |
| Department | 15 departments |
| Company Size | 8 ranges (1-10 to 10,000+) |
| Company Revenue | 7 ranges (Under $1M to $10B+) |
| Company Industry | 15 industries |
| C-Suite Title | CEO, CFO, CTO, CMO, COO, CIO, CHRO, CDO |
Processing Details
- Classification: Each generated topic is classified using the local rule-based engine (7-layer pipeline)
- Chunking: Topics are processed in chunks of 500 for database insertion
- Deduplication: Standard embedding-based duplicate detection applies
- Source tracking: All generated topics are tagged with
_source: "matrix"for filtering
Error Responses
| Status | Body | Description |
|---|---|---|
| 400 | {"error": "At least 2 dimensions are required"} | Need minimum 2 dimensions |
| 400 | {"error": "Too many combinations (6000). Maximum is 5000."} | Exceeds combination limit |
| 400 | {"error": "Dimension \"?\" must have a name and at least one value"} | Invalid dimension |
| 401 | {"error": "Unauthorized"} | Invalid credentials |
| 429 | {"error": "Monthly classifications quota exceeded"} | Quota exceeded |
Next Steps
- Topics API -- View and manage generated topics
- Catalog API -- Browse pre-classified topics as an alternative
- Import API -- Import topics from external CSV files
- Activations API -- Push generated topics to DSP platforms