Authenticated partner API guide
Retrieve completed visibility scores, review historical trends, or list the brands your partner token is authorized to access.
Endpoint reference
| HTTP method | Path |
|---|---|
| GET | /api/partner/brands |
| GET | /api/partner/brands/:brandId/visibility |
| GET | /api/partner/brands/:brandId/visibility/history |
Choosing an endpoint
- Use
GET /api/partner/brandsto find brands explicitly scoped to the authenticated partner token and inspect each brand'slatest_visibility_at. - Use
GET /api/partner/brands/:brandId/visibilityfor one brand's latest completed weekly report. - Use
GET /api/partner/brands/:brandId/visibility/historyfor completed reports over report-week date ranges.fromandtoare inclusive report-week filters;limitis a maximum result count, and the response has no continuation metadata.
Result and pagination contracts
| Endpoint | Successful result | Pagination contract |
|---|---|---|
| GET /api/partner/brands | { "brands": [...] }, all scoped brands ordered by brand_id. | No supported pagination parameters or metadata. |
| GET /api/partner/brands/:brandId/visibility | One object for the latest completed report. | No supported pagination parameters or metadata. |
| GET /api/partner/brands/:brandId/visibility/history | A newest-first array filtered by inclusive report-week dates. | limit caps results (default 12, range 1–100); no page continuation or total count. |
Versioning and compatibility
The partner API has no version selector: its endpoints use unversioned /api/partner/... paths, and no path, header, or query parameter selects an API version. The OpenAPI document's info.version value, 1.0.0, identifies the OpenAPI document; it is not an endpoint version and does not version these request URLs or negotiate a version.
This guide and the OpenAPI document describe the current contract. No general backward-compatibility window or deprecation or sunset schedule is documented or promised.
Quickstart
partner_... describes the generated token format; it is not a separate authentication method. Send your provisioned token in the required HTTP Authorization header as Bearer <partner-token>, starting with the brand listing endpoint:
curl https://aisearchstackhub.ai/api/partner/brands \
-H 'Authorization: Bearer <partner-token>'
JavaScript fetch (server-side)
This server-side example uses PARTNER_API_TOKEN as a caller-defined secret name; the app does not create or supply that environment variable.
(async () => {
const apiOrigin = 'https://aisearchstackhub.ai';
// Run this on your server only; never bundle the token into browser code.
const partnerToken = process.env.PARTNER_API_TOKEN;
if (!partnerToken) throw new Error('Configure your server-side partner token secret');
const response = await fetch(apiOrigin + '/api/partner/brands', {
headers: {
Authorization: 'Bearer ' + partnerToken,
},
});
const body = await response.json();
if (!response.ok) {
throw new Error(body.error && body.error.message);
}
for (const brand of body.brands) {
console.log(brand.brand_id, brand.name);
}
})().catch((error) => console.error(error.message));
Expected 200 OK response
{
"brands": [
{
"brand_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Example Brand",
"monitoring_enabled": true,
"latest_visibility_at": "2026-09-01T09:30:00.000Z"
}
]
}
Use a returned brand_id with the visibility endpoints to retrieve the latest or historical visibility data.
Authentication
Every partner operation requires an HTTP Authorization header in this form:
Authorization: Bearer <partner-token>
The Bearer scheme name is case-insensitive. After parsing, the credential must be a single non-whitespace value. Authentication succeeds only when token lookup resolves to an active, unrevoked token whose expiry is in the future; a null expiry is allowed. The partner_ prefix is generated by the provisioner; it is not a separate authentication method or a prefix-based check. Visibility requests additionally require an explicit scope for the requested brand; the collection endpoint returns only brands explicitly scoped to that token. The middleware reads only the HTTP Authorization header. Query-string tokens, cookies, Basic authentication, and alternate API-key headers are not accepted.
Troubleshooting authentication. A missing or unparsable Authorization: Bearer <token> header returns 401 partner_token_required. A parsed but malformed, unknown, inactive, revoked, or expired token returns 401 partner_token_invalid. Token lookup failures use that same response; there is no separate availability status for them. A valid token without access to the requested brand returns 403 brand_access_denied. Unexpected route errors return endpoint-specific 500 internal_error responses. 404 visibility_not_found applies only to latest visibility when an authorized brand has no completed weekly report; history returns 200 with [] when no reports match.
Keep tokens secure. Raw partner tokens are issued once when provisioned. Store the value in a secrets manager and never commit it, place it in a URL, or expose it in client-side code or logs.
Credential provisioning and handling
The public app exposes no self-service endpoint or UI for creating, listing, rotating, revoking, or changing brand scopes for partner tokens. Use a token provisioned outside these documented GET endpoints, and do not infer a provisioning workflow from the partner_... format.
The internal provisioning helper returns the raw token only at provisioning time. Authentication hashes the presented value for lookup; the raw token is not returned by the documented API. Store the received value in a secrets manager, transmit it only over HTTPS, and keep it out of URLs, cookies, browser/client bundles, logs, and diagnostics. Redact it from troubleshooting output.
If authentication returns 401 partner_token_invalid, replace the credential rather than retrying unchanged credentials. This public API does not provide a self-service creation, listing, rotation, revocation, or brand-scope management process.
Rate limits
The three partner operations—GET /api/partner/brands, GET /api/partner/brands/:brandId/visibility, and GET /api/partner/brands/:brandId/visibility/history—share one fixed-window bucket per authenticated token ID within a Node process. The production allowance is 60 requests per 60-second window per authenticated token. The window starts when the first request for that token reaches the limiter and expires 60 seconds after that start; later requests do not move the reset time. A burst can consume the whole allowance.
The bucket is process-local and in-memory, not a deployment-wide or IP-based quota. Separate Node processes or instances can therefore have separate buckets, and restarting a process clears its bucket. Only requests that pass authentication reach the limiter; scoped visibility routes validate the UUID before authentication. Missing or invalid credentials and malformed UUIDs do not consume quota. Once a valid-UUID request reaches the limiter, it is counted before the route checks brand scope or history filters, so it can consume quota even when it later returns 403 brand_access_denied or a history-filter 400. An over-limit request returns 429 Too Many Requests before the route handler runs.
A throttled response includes Retry-After and JSON error.retry_after. Both contain the same runtime-calculated number of seconds until the current fixed window expires; wait at least that long before retrying the same GET. The 12-second value shown below is illustrative only, not a guaranteed response value. The implementation does not emit remaining-quota, absolute-reset, or X-RateLimit-* headers, and it provides no separate reset timestamp or reset endpoint.
Wait at least the indicated delay before retrying the same idempotent GET request. No retry behavior is documented for other statuses.
HTTP/1.1 429 Too Many Requests
Retry-After: 12
{
"error": {
"code": "rate_limited",
"message": "Too many partner API requests",
"retry_after": 12
}
}
This example's 12 is illustrative; use the actual Retry-After header and error.retry_after value returned at runtime.
Request
List accessible brands
/api/partner/brandsThis endpoint has no required path or query parameters and accepts no request body. It returns every brand explicitly scoped to the authenticated token in one response, ordered deterministically by brand_id ascending. For each latest_visibility_at, the selected completed visibility_weekly report is ranked by score_week descending, then score_timestamp descending; the implementation defines no further report tie-break when both values match. The response shape is { "brands": [...] }. It has no supported pagination parameters or pagination metadata, so callers do not make follow-up page requests.
curl https://aisearchstackhub.ai/api/partner/brands \
-H 'Authorization: Bearer <partner-token>'
Expected 200 OK response
{
"brands": [
{
"brand_id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Example Brand",
"monitoring_enabled": true,
"latest_visibility_at": "2026-09-01T09:30:00.000Z"
}
]
}
Endpoint error examples
This endpoint returns only the errors shown here.
401 Unauthorized — partner token required
curl https://aisearchstackhub.ai/api/partner/brands
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_required",
"message": "Authorization Bearer token required"
}
}
401 Unauthorized — invalid partner token
curl https://aisearchstackhub.ai/api/partner/brands -H 'Authorization: Bearer invalid-token'
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_invalid",
"message": "Partner token is invalid"
}
}
429 Too Many Requests — rate limited
curl https://aisearchstackhub.ai/api/partner/brands -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 429 Too Many Requests
Retry-After: 12
{
"error": {
"code": "rate_limited",
"message": "Too many partner API requests",
"retry_after": 12
}
}
500 Internal Server Error — internal failure
curl https://aisearchstackhub.ai/api/partner/brands -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 500 Internal Server Error
{
"error": {
"code": "internal_error",
"message": "Unable to list accessible brands"
}
}
Latest visibility
/api/partner/brands/:brandId/visibilitybrandId is the required UUID path parameter for the brand. The route validates it before checking authentication, so a malformed UUID can return 400 invalid_brand_id before a missing credential returns 401. The endpoint has no request body or query parameters in its documented contract.
curl --request GET 'https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility' \
-H 'Authorization: Bearer <partner-token>'
JavaScript fetch (server-side)
(async () => {
const apiOrigin = 'https://aisearchstackhub.ai';
// Run this on your server only; never bundle the token into browser code.
const partnerToken = process.env.PARTNER_API_TOKEN;
if (!partnerToken) throw new Error('Configure your server-side partner token secret');
const brandId = '<brand-uuid>'; // Use a brand_id from the listing response.
// No request body or query parameters are required.
const response = await fetch(
apiOrigin + '/api/partner/brands/' + encodeURIComponent(brandId) + '/visibility',
{
headers: {
Authorization: 'Bearer ' + partnerToken,
},
}
);
const body = await response.json();
if (!response.ok) {
throw new Error(body.error && body.error.message);
}
console.log(body.visibility_score, body.score_timestamp, body.score_week);
})().catch((error) => console.error(error.message));
One latest report. This endpoint returns a single object for the latest completed visibility_weekly report, ranked by score_week descending, then score_timestamp descending. If both values match, the implementation defines no further report tie-break. It has no supported pagination parameters or pagination metadata.
Expected 200 OK response
{
"brand_id": "123e4567-e89b-12d3-a456-426614174000",
"visibility_score": 74,
"score_timestamp": "2026-09-01T09:30:00.000Z",
"score_week": "2026-08-31",
"engine_breakdown": {
"ChatGPT": {
"visibility_pct": 80,
"position_avg": 2,
"share": {
"rival.example": 20
}
},
"Claude": {
"visibility_pct": 70,
"position_avg": 3,
"share": {}
},
"Perplexity": {
"visibility_pct": 75,
"position_avg": 2,
"share": {}
},
"Gemini": {
"visibility_pct": 71,
"position_avg": 4,
"share": {}
}
}
}
Endpoint error examples
This endpoint returns only the errors shown here.
400 Bad Request — invalid brand ID
curl https://aisearchstackhub.ai/api/partner/brands/not-a-uuid/visibility -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 400 Bad Request
{
"error": {
"code": "invalid_brand_id",
"message": "brandId must be a UUID"
}
}
401 Unauthorized — partner token required
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_required",
"message": "Authorization Bearer token required"
}
}
401 Unauthorized — invalid partner token
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility -H 'Authorization: Bearer invalid-token'
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_invalid",
"message": "Partner token is invalid"
}
}
403 Forbidden — brand access denied
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 403 Forbidden
{
"error": {
"code": "brand_access_denied",
"message": "Partner token cannot access this brand"
}
}
404 Not Found — visibility report not found
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 404 Not Found
{
"error": {
"code": "visibility_not_found",
"message": "No completed weekly visibility report found"
}
}
429 Too Many Requests — rate limited
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 429 Too Many Requests
Retry-After: 12
{
"error": {
"code": "rate_limited",
"message": "Too many partner API requests",
"retry_after": 12
}
}
500 Internal Server Error — internal failure
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 500 Internal Server Error
{
"error": {
"code": "internal_error",
"message": "Unable to fetch visibility data"
}
}
Historical visibility
/api/partner/brands/:brandId/visibility/historybrandId is the required UUID path parameter for the brand. The endpoint returns a direct JSON array of completed visibility_weekly reports, ordered by score_week descending, then score_timestamp descending, then report id descending. The id is used only as a tie-break and is not returned. Its documented filters are optional from, to, and limit. The date filters apply to report weeks (score_week): both are inclusive and must be real YYYY-MM-DD calendar dates, with from on or before to. limit is a maximum result count, not a page size: it defaults to 12 and accepts integers from 1 through 100.
The route validates brandId before authentication. For a valid UUID, authentication and rate limiting run before brand scope, which is checked before filter validation. An earlier 401, 429, or 403 can therefore precede a filter-validation 400.
The success body has no page, offset, or cursor continuation, total count, or next-page metadata. An array containing limit items does not reveal whether more reports match inside that date window. To retrieve older history, make bounded, non-overlapping report-week date-window requests small enough to fit the 100-result maximum, then combine the returned arrays. Because both date filters are inclusive, do not reuse a boundary date in adjacent windows.
curl 'https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history?from=2026-01-01&to=2026-09-01&limit=12' \
-H 'Authorization: Bearer <partner-token>'
Expected 200 OK response
[
{
"brand_id": "123e4567-e89b-12d3-a456-426614174000",
"visibility_score": 74,
"score_timestamp": "2026-09-01T09:30:00.000Z",
"score_week": "2026-08-31",
"engine_breakdown": {
"ChatGPT": {
"visibility_pct": 80,
"position_avg": 2,
"share": {
"rival.example": 20
}
},
"Claude": {
"visibility_pct": 70,
"position_avg": 3,
"share": {}
},
"Perplexity": {
"visibility_pct": 75,
"position_avg": 2,
"share": {}
},
"Gemini": {
"visibility_pct": 71,
"position_avg": 4,
"share": {}
}
}
}
]
Endpoint error examples
This endpoint returns only the errors shown here.
400 Bad Request — invalid brand ID
curl 'https://aisearchstackhub.ai/api/partner/brands/not-a-uuid/visibility/history?limit=12' -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 400 Bad Request
{
"error": {
"code": "invalid_brand_id",
"message": "brandId must be a UUID"
}
}
400 Bad Request — invalid from date
curl 'https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history?from=2026-02-30' -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 400 Bad Request
{
"error": {
"code": "invalid_from_date",
"message": "from must be a valid YYYY-MM-DD date"
}
}
400 Bad Request — invalid to date
curl 'https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history?to=2026-09-31' -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 400 Bad Request
{
"error": {
"code": "invalid_to_date",
"message": "to must be a valid YYYY-MM-DD date"
}
}
400 Bad Request — invalid date range
curl 'https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history?from=2026-09-01&to=2026-01-01' -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 400 Bad Request
{
"error": {
"code": "invalid_date_range",
"message": "from must be on or before to"
}
}
400 Bad Request — invalid limit
curl 'https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history?limit=0' -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 400 Bad Request
{
"error": {
"code": "invalid_limit",
"message": "limit must be an integer between 1 and 100"
}
}
401 Unauthorized — partner token required
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_required",
"message": "Authorization Bearer token required"
}
}
401 Unauthorized — invalid partner token
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history -H 'Authorization: Bearer invalid-token'
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_invalid",
"message": "Partner token is invalid"
}
}
403 Forbidden — brand access denied
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 403 Forbidden
{
"error": {
"code": "brand_access_denied",
"message": "Partner token cannot access this brand"
}
}
429 Too Many Requests — rate limited
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 429 Too Many Requests
Retry-After: 12
{
"error": {
"code": "rate_limited",
"message": "Too many partner API requests",
"retry_after": 12
}
}
500 Internal Server Error — internal failure
curl https://aisearchstackhub.ai/api/partner/brands/<brand-uuid>/visibility/history -H 'Authorization: Bearer <partner-token>'
HTTP/1.1 500 Internal Server Error
{
"error": {
"code": "internal_error",
"message": "Unable to fetch visibility history"
}
}
Successful response
Latest and history 200 OK visibility responses contain these five fields. The collection endpoint returns a { "brands": [...] } envelope described below.
brand_idType: string (UUID); always present. Example: 123e4567-e89b-12d3-a456-426614174000.
visibility_scoreType: integer from 0 to 100; always present. Example: 74.
score_timestampType: UTC ISO 8601 string; always present. Example: 2026-09-01T09:30:00.000Z.
score_weekType: string date in YYYY-MM-DD format; always present. Example: 2026-08-31.
engine_breakdownType: object keyed by engine name; always present. Example key: ChatGPT.
Engine fields
engine_breakdown is keyed by the engines included in the report—normally ChatGPT, Claude, Perplexity, and Gemini. Every returned engine item contains these three fields.
visibility_pctType: integer from 0 to 100; always present. Example: 80.
position_avgType: integer or null; always present, and null when no integer positions are available. Example: 2 or null.
shareType: object mapping competitor domains to numeric percentages; always present. Examples: {} or {"rival.example":20}.
Historical response
The history endpoint returns a direct array, including [] when the authorized brand has no matching reports. Each item uses the same five-field visibility-report shape and three engine fields as the latest endpoint. Items are ordered by score_week descending, then score_timestamp descending, then report id descending. The id is used only as a tie-break and is not returned.
Accessible brand collection
A successful collection response is 200 OK with a stable brands envelope. Each item contains the scoped brand's identity and monitoring status:
brandsType: array of brand objects; always present, including when empty. Example: [].
brand_idType: string (UUID); always present on each item. Example: 123e4567-e89b-12d3-a456-426614174000.
nameType: string or null; always present and nullable. Example: null.
monitoring_enabledType: boolean; always present. Example: true.
latest_visibility_atType: UTC ISO 8601 string or null; always present, and null when no report exists. It comes from the completed report ranked by score_week descending, then score_timestamp descending; the implementation defines no further report tie-break when both values match. Example: 2026-09-01T09:30:00.000Z or null.
A token with no scoped brands receives exactly { "brands": [] }.
Errors
Every error response has the shape { "error": { "code": "...", "message": "..." } }. Only 429 responses add error.retry_after and the Retry-After header; both contain the same runtime-calculated number of seconds until the current fixed window expires. Clients should wait at least that delay before retrying the same GET; other statuses do not include retry metadata.
For request context and endpoint-specific examples, see List accessible brands, Latest visibility, and Historical visibility above. The examples in each section are limited to errors that route can return.
For scoped endpoints, brandId validation runs before authentication, so a malformed UUID can return 400 invalid_brand_id before 401. History validates authentication and rate limits before brand scope, then validates its filters; an earlier 401, 429, or 403 can precede a filter-validation 400.
| Status | Code | Message | Applies to |
|---|---|---|---|
| 400 | invalid_brand_id | brandId must be a UUID | Latest and history: change the path parameter to a UUID. |
| 400 | invalid_from_date | from must be a valid YYYY-MM-DD date | History: change from to a real calendar date in YYYY-MM-DD format. |
| 400 | invalid_to_date | to must be a valid YYYY-MM-DD date | History: change to to a real calendar date in YYYY-MM-DD format. |
| 400 | invalid_date_range | from must be on or before to | History: change the inclusive range so from is not after to. |
| 400 | invalid_limit | limit must be an integer between 1 and 100 | History: change limit to an integer from 1 through 100. |
| 401 | partner_token_required | Authorization Bearer token required | All operations: the Authorization header is missing or does not contain a parseable Bearer token. |
| 401 | partner_token_invalid | Partner token is invalid | All operations: a parsed token is unknown, inactive, revoked, expired, or otherwise unusable. Token lookup failures return this same response. |
| 403 | brand_access_denied | Partner token cannot access this brand | Latest and history: use a brand within the token's scope. |
| 404 | visibility_not_found | No completed weekly visibility report found | Latest only: the authorized brand has no completed weekly report yet. |
| 429 | rate_limited | Too many partner API requests | All operations: wait at least the runtime-calculated seconds in Retry-After and error.retry_after before retrying the same GET. |
| 500 | internal_error | Unable to list accessible brands | List brands. |
| 500 | internal_error | Unable to fetch visibility data | Latest visibility. |
| 500 | internal_error | Unable to fetch visibility history | History. |
Request changes. Correct invalid inputs for 400, supply or replace credentials for 401, and check the requested brand scope for 403. The 404 applies only to latest visibility and means the authorized brand has no completed weekly report. For 429, honor the returned delay before retrying the same GET.
401 Unauthorized — partner token required
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_required",
"message": "Authorization Bearer token required"
}
}
A missing or unparsable Bearer header returns partner_token_required. A parsed token that is unknown, inactive, revoked, expired, or otherwise unusable returns partner_token_invalid; token lookup failures use that same invalid-token response. Supply a Bearer credential or replace an unusable one.
401 Unauthorized — invalid partner token
HTTP/1.1 401 Unauthorized
{
"error": {
"code": "partner_token_invalid",
"message": "Partner token is invalid"
}
}
A parsed Bearer token is unknown, inactive, revoked, expired, or otherwise unusable. Token lookup failures return the same response.
403 Forbidden — brand scope denied
HTTP/1.1 403 Forbidden
{
"error": {
"code": "brand_access_denied",
"message": "Partner token cannot access this brand"
}
}
The token is valid but is not scoped to the requested brand. Verify the requested brand scope before retrying.
404 Not Found — no completed report
HTTP/1.1 404 Not Found
{
"error": {
"code": "visibility_not_found",
"message": "No completed weekly visibility report found"
}
}
The brand is authorized, but no completed weekly report exists yet. Treat this as an authorized brand with no completed weekly report yet, not as an authentication or scope failure.
429 Too Many Requests — rate limited
HTTP/1.1 429 Too Many Requests
Retry-After: 12
{
"error": {
"code": "rate_limited",
"message": "Too many partner API requests",
"retry_after": 12
}
}
The 12-second values are illustrative only. The implementation supplies the current runtime-calculated delay; it does not supply remaining-quota or absolute-reset metadata, any X-RateLimit-* headers, or a separate reset timestamp or endpoint.