Create Audience Profile
Create a new audience profile to control content access for a client segment.
Path Parameters
The project ID.
Request Body
Display name for the profile. Example: "Acme Corporation".
URL-safe identifier for the profile. Must be unique within the project. Cannot be changed after creation.
Format: lowercase letters, numbers, and hyphens only. Example: acme-corp.
Optional description of the profile or client.
Array of audience tags this profile grants access to. These tags correspond to the audience field in page frontmatter.
Example: ["otc", "virtual-accounts"]
Response
Returns the created audience profile object.
Example
curl -X POST https://api.syntext.dev/v1/projects/proj_abc123/audiences \
-H "Authorization: Bearer stx_abc12345_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corporation",
"slug": "acme-corp",
"description": "Enterprise partner with OTC and VA access",
"audiences": ["otc", "virtual-accounts"]
}'
import { Syntext } from '@syntext/sdk'
const client = new Syntext('stx_abc12345_...')
const profile = await client.audiences.create('proj_abc123', {
name: 'Acme Corporation',
slug: 'acme-corp',
description: 'Enterprise partner with OTC and VA access',
audiences: ['otc', 'virtual-accounts'],
})
from syntext import Syntext
client = Syntext("stx_abc12345_...")
profile = client.audiences.create(
"proj_abc123",
name="Acme Corporation",
slug="acme-corp",
description="Enterprise partner with OTC and VA access",
audiences=["otc", "virtual-accounts"],
)
Response
{
"id": "aud_xyz789",
"name": "Acme Corporation",
"slug": "acme-corp",
"description": "Enterprise partner with OTC and VA access",
"audiences": ["otc", "virtual-accounts"],
"createdAt": "2024-03-15T10:30:00Z",
"updatedAt": "2024-03-15T10:30:00Z"
}
Error Responses
400 Bad Request
Returned when the slug contains invalid characters.
{
"error": {
"code": "invalid_slug",
"message": "Slug must contain only lowercase letters, numbers, and hyphens"
}
}
409 Conflict
Returned when a profile with this slug already exists.
{
"error": {
"code": "slug_exists",
"message": "A profile with this slug already exists"
}
}
422 Unprocessable Entity
Returned when the request is missing required data.
{
"error": {
"code": "empty_audiences",
"message": "At least one audience tag is required"
}
}