POST · Configurer
Rédigé par Red Blue
Mis à jour le
POST /api/v1/analytics/commands
operationId : analytics_command
Accès | Permission | Consentements OAuth |
|---|---|---|
OAuth : délégation d’un équipier pour l’API | analytics.write | api:connect, analytics:write |
KHONY_ORIGIN est l’origine HTTPS de votre application Khony, sans chemin final. Remplacez les identifiants de l’exemple par ceux de vos ressources autorisées. Les données de réponse ci-dessous illustrent le format ; elles ne sont pas le résultat d’un appel à votre organisation.
Champs du corps JSON
Nom | Emplacement | Requis | Type et contraintes |
|---|---|---|---|
productId | JSON | Oui | string |
request | JSON | Oui | object |
idempotencyKey | JSON | Oui | string ; uuid |
Variantes de la requête
Sélecteur | Valeur | Autres champs requis dans request |
|---|---|---|
request.type | "save_view" | name, view, visibility, definition |
request.type | "save_subscription" | savedViewId, expectedRevision, cadence, timezone, nextRunAt, status |
request.type | "save_alert" | name, metricId, operator, definition, status |
request.type | "acknowledge_alert" | eventId, expectedRevision |
request.type | "configure" | timezone, currency, expectedRevision |
request.type | "save_sla" | name, timezone, responseActor, pauseWhenSnoozed, businessHours |
request.type | "save_theme" | name |
request.type | "assign_theme" | themeId |
request.type | "unassign_theme" | assignmentId, expectedRevision |
request.type | "save_currency_rate" | sourceCurrency, targetCurrency, rate, source, effectiveDate, expectedRevision |
request.type | "record_ai_outcome" | clientEventId, outcomeType, status |
Choisissez une variante et respectez son schéma complet : les contraintes des champs optionnels et les unions imbriquées restent applicables.
Exemple de requête
curl --request POST "$KHONY_ORIGIN/api/v1/analytics/commands" \
--header "Authorization: Bearer $KHONY_ACCESS_TOKEN" \
--header 'X-Khony-Confirmation: 0198f886-9f71-7000-8000-000000000011' \
--header 'Idempotency-Key: 0198f886-9f71-7000-8000-000000000010' \
--header 'Content-Type: application/json' \
--data-raw '{
"productId": "product_01k3w8d7vhe008000000000001",
"idempotencyKey": "0198f886-9f71-7000-8000-000000000010",
"request": {
"type": "save_view",
"name": "Weekly feedback",
"view": "feedback",
"visibility": "private",
"definition": {
"periodDays": 7
}
}
}'Réponse de succès · HTTP 200
{
"data": {
"id": "analytics_saved_view_01k3w8d7vhe008000000000001"
}
}Schéma complet du corps JSON
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"productId": {
"type": "string",
"pattern": "^product_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"request": {
"oneOf": [
{
"$ref": "#/$defs/__schema0"
},
{
"$ref": "#/$defs/__schema5"
},
{
"$ref": "#/$defs/__schema7"
},
{
"$ref": "#/$defs/__schema10"
},
{
"$ref": "#/$defs/__schema11"
},
{
"$ref": "#/$defs/__schema13"
},
{
"$ref": "#/$defs/__schema22"
},
{
"$ref": "#/$defs/__schema23"
},
{
"$ref": "#/$defs/__schema25"
},
{
"$ref": "#/$defs/__schema26"
},
{
"$ref": "#/$defs/__schema27"
}
]
},
"idempotencyKey": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
}
},
"required": [
"productId",
"request",
"idempotencyKey"
],
"additionalProperties": false,
"$defs": {
"__schema0": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "save_view"
},
"savedViewId": {
"type": "string",
"pattern": "^analytics_saved_view_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"expectedRevision": {
"$ref": "#/$defs/__schema1"
},
"name": {
"$ref": "#/$defs/__schema2"
},
"view": {
"type": "string",
"enum": [
"overview",
"feedback",
"support",
"audience",
"business",
"delivery",
"ai_automations",
"changelog",
"reliability"
]
},
"visibility": {
"type": "string",
"enum": [
"private",
"product"
]
},
"definition": {
"type": "object",
"propertyNames": {
"$ref": "#/$defs/__schema3"
},
"additionalProperties": {
"$ref": "#/$defs/__schema4"
}
}
},
"required": [
"type",
"name",
"view",
"visibility",
"definition"
],
"additionalProperties": false
},
"__schema1": {
"type": "string",
"pattern": "^[a-f0-9]{32}$"
},
"__schema2": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"__schema3": {
"type": "string"
},
"__schema4": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"type": "array",
"items": {
"$ref": "#/$defs/__schema4"
}
},
{
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/$defs/__schema4"
}
}
]
},
"__schema5": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "save_subscription"
},
"savedViewId": {
"type": "string",
"pattern": "^analytics_saved_view_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"expectedRevision": {
"anyOf": [
{
"$ref": "#/$defs/__schema1"
},
{
"type": "null"
}
]
},
"cadence": {
"type": "string",
"enum": [
"daily",
"weekly",
"monthly"
]
},
"timezone": {
"$ref": "#/$defs/__schema6"
},
"nextRunAt": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
},
"status": {
"type": "string",
"enum": [
"active",
"paused"
]
}
},
"required": [
"type",
"savedViewId",
"expectedRevision",
"cadence",
"timezone",
"nextRunAt",
"status"
],
"additionalProperties": false
},
"__schema6": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"__schema7": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "save_alert"
},
"ruleId": {
"type": "string",
"pattern": "^analytics_alert_rule_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"expectedRevision": {
"$ref": "#/$defs/__schema1"
},
"name": {
"$ref": "#/$defs/__schema2"
},
"metricId": {
"type": "string",
"minLength": 1,
"maxLength": 160
},
"operator": {
"type": "string",
"enum": [
"above",
"below",
"increase_by",
"decrease_by",
"anomaly",
"no_data"
]
},
"threshold": {
"$ref": "#/$defs/__schema8"
},
"definition": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/$defs/__schema9"
}
},
"status": {
"type": "string",
"enum": [
"active",
"paused"
]
}
},
"required": [
"type",
"name",
"metricId",
"operator",
"definition",
"status"
],
"additionalProperties": false
},
"__schema8": {
"type": "string",
"maxLength": 40,
"pattern": "^-?\\d+(\\.\\d+)?$"
},
"__schema9": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"type": "array",
"items": {
"$ref": "#/$defs/__schema9"
}
},
{
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/$defs/__schema9"
}
}
]
},
"__schema10": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "acknowledge_alert"
},
"eventId": {
"type": "string",
"pattern": "^analytics_alert_event_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"expectedRevision": {
"$ref": "#/$defs/__schema1"
}
},
"required": [
"type",
"eventId",
"expectedRevision"
],
"additionalProperties": false
},
"__schema11": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "configure"
},
"timezone": {
"$ref": "#/$defs/__schema6"
},
"currency": {
"$ref": "#/$defs/__schema12"
},
"expectedRevision": {
"$ref": "#/$defs/__schema1"
}
},
"required": [
"type",
"timezone",
"currency",
"expectedRevision"
],
"additionalProperties": false
},
"__schema12": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"__schema13": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "save_sla"
},
"name": {
"$ref": "#/$defs/__schema2"
},
"policyId": {
"type": "string",
"pattern": "^sla_policy_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"expectedRevision": {
"$ref": "#/$defs/__schema1"
},
"timezone": {
"$ref": "#/$defs/__schema6"
},
"firstResponseMinutes": {
"$ref": "#/$defs/__schema14"
},
"nextResponseMinutes": {
"$ref": "#/$defs/__schema14"
},
"resolutionMinutes": {
"$ref": "#/$defs/__schema14"
},
"responseActor": {
"type": "string",
"enum": [
"human",
"any"
]
},
"pauseWhenSnoozed": {
"type": "boolean"
},
"businessHours": {
"type": "object",
"properties": {
"weekdays": {
"minItems": 1,
"maxItems": 7,
"type": "array",
"items": {
"$ref": "#/$defs/__schema15"
}
},
"start": {
"$ref": "#/$defs/__schema16"
},
"end": {
"$ref": "#/$defs/__schema17"
},
"holidays": {
"maxItems": 366,
"type": "array",
"items": {
"$ref": "#/$defs/__schema18"
}
},
"weekly": {
"type": "object",
"propertyNames": {
"type": "string",
"pattern": "^[1-7]$"
},
"additionalProperties": {
"maxItems": 4,
"type": "array",
"items": {
"$ref": "#/$defs/__schema19"
}
}
},
"exceptions": {
"type": "object",
"propertyNames": {
"$ref": "#/$defs/__schema20"
},
"additionalProperties": {
"$ref": "#/$defs/__schema21"
}
}
},
"required": [
"weekdays",
"start",
"end"
]
}
},
"required": [
"type",
"name",
"timezone",
"responseActor",
"pauseWhenSnoozed",
"businessHours"
],
"additionalProperties": false
},
"__schema14": {
"type": "integer",
"exclusiveMinimum": 0,
"maximum": 525600
},
"__schema15": {
"type": "integer",
"minimum": 1,
"maximum": 7
},
"__schema16": {
"type": "string",
"pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
},
"__schema17": {
"type": "string",
"pattern": "^(([01]\\d|2[0-3]):[0-5]\\d|24:00)$"
},
"__schema18": {
"type": "string",
"format": "date",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
},
"__schema19": {
"type": "object",
"properties": {
"start": {
"$ref": "#/$defs/__schema16"
},
"end": {
"$ref": "#/$defs/__schema17"
}
},
"required": [
"start",
"end"
]
},
"__schema20": {
"type": "string",
"format": "date",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
},
"__schema21": {
"maxItems": 4,
"type": "array",
"items": {
"$ref": "#/$defs/__schema19"
}
},
"__schema22": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "save_theme"
},
"themeId": {
"type": "string",
"pattern": "^feedback_theme_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"expectedRevision": {
"$ref": "#/$defs/__schema1"
},
"name": {
"$ref": "#/$defs/__schema2"
},
"description": {
"type": "string",
"maxLength": 1000
},
"parentId": {
"type": "string",
"pattern": "^feedback_theme_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
}
},
"required": [
"type",
"name"
],
"additionalProperties": false
},
"__schema23": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "assign_theme"
},
"themeId": {
"type": "string",
"pattern": "^feedback_theme_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"postId": {
"type": "string",
"pattern": "^post_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"conversationId": {
"type": "string",
"pattern": "^support_conversation_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"confidenceBps": {
"type": "integer",
"minimum": 0,
"maximum": 10000
},
"evidence": {
"maxItems": 20,
"type": "array",
"items": {
"$ref": "#/$defs/__schema24"
}
}
},
"required": [
"type",
"themeId"
],
"additionalProperties": false
},
"__schema24": {
"type": "object",
"properties": {
"excerpt": {
"type": "string",
"maxLength": 2000
},
"messageId": {
"type": "string",
"pattern": "^support_message_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"postId": {
"type": "string",
"pattern": "^post_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
}
},
"additionalProperties": false
},
"__schema25": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "unassign_theme"
},
"assignmentId": {
"type": "string",
"pattern": "^feedback_theme_assignment_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"expectedRevision": {
"$ref": "#/$defs/__schema1"
}
},
"required": [
"type",
"assignmentId",
"expectedRevision"
],
"additionalProperties": false
},
"__schema26": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "save_currency_rate"
},
"sourceCurrency": {
"$ref": "#/$defs/__schema12"
},
"targetCurrency": {
"$ref": "#/$defs/__schema12"
},
"rate": {
"$ref": "#/$defs/__schema8"
},
"source": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"effectiveDate": {
"type": "string",
"format": "date",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
},
"expectedRevision": {
"anyOf": [
{
"$ref": "#/$defs/__schema1"
},
{
"type": "null"
}
]
}
},
"required": [
"type",
"sourceCurrency",
"targetCurrency",
"rate",
"source",
"effectiveDate",
"expectedRevision"
],
"additionalProperties": false
},
"__schema27": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "record_ai_outcome"
},
"clientEventId": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"aiUsageEventId": {
"type": "string",
"pattern": "^ai_usage_event_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
},
"entityType": {
"type": "string",
"minLength": 1,
"maxLength": 80
},
"entity": {
"type": "object",
"properties": {
"kind": {
"$ref": "#/$defs/__schema28"
},
"id": {
"$ref": "#/$defs/__schema29"
}
},
"required": [
"kind",
"id"
],
"additionalProperties": false
},
"outcomeType": {
"type": "string",
"enum": [
"answer_proposed",
"answer_inserted",
"answer_copied",
"answer_sent",
"answer_sent_unedited",
"answer_edited",
"answer_rejected",
"resolution_confirmed",
"escalated",
"classification_reviewed",
"classification_corrected",
"grounded_answer",
"action_proposed",
"action_confirmed",
"action_rejected",
"workflow_useful_action"
]
},
"status": {
"type": "string",
"enum": [
"succeeded",
"failed",
"abandoned"
]
},
"value": {
"type": "string",
"maxLength": 500
},
"metadata": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/$defs/__schema30"
}
}
},
"required": [
"type",
"clientEventId",
"outcomeType",
"status"
],
"additionalProperties": false
},
"__schema28": {
"type": "string",
"enum": [
"organization",
"product",
"board",
"post",
"comment",
"tag",
"vote",
"roadmap",
"roadmapItem",
"changelog",
"attachment",
"entitlement",
"outboxEvent",
"helpCollection",
"helpArticle",
"knowledgeSource",
"knowledgeDocument",
"knowledgeChunk",
"savedReply",
"statusIncident",
"supportConversation",
"supportMessage",
"supportNote",
"supportCopilotMessage",
"supportTeam",
"supportSavedView",
"supportConversationEvent",
"supportEmail",
"supportOutgoing",
"ticketType",
"ticketField",
"ticketStatus",
"ticketUpdate",
"contact",
"company",
"ticket",
"feedbackSavedView",
"feedbackMerge",
"feedbackSuggestionDecision",
"workflow",
"workflowDraft",
"workflowVersion",
"workflowApproval",
"personTag",
"customField",
"segment",
"contactBlock",
"integrationConnection",
"webhookAttempt",
"dataImport",
"exportJob",
"workflowRun",
"webhookSubscription",
"webhookDelivery",
"statusComponent",
"statusUpdate",
"statusTemplate",
"statusSubscription",
"analyticsSavedView",
"analyticsSubscription",
"analyticsAlertRule",
"analyticsAlertEvent",
"slaPolicy",
"feedbackTheme",
"feedbackThemeAssignment",
"currencyRateSnapshot",
"aiProductOutcome",
"aiUsageEvent",
"organizationMember",
"organizationInvitation",
"organizationApiKey",
"user",
"productDomain",
"productPurchaseIntent"
]
},
"__schema29": {
"type": "string",
"maxLength": 160
},
"__schema30": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"type": "array",
"items": {
"$ref": "#/$defs/__schema30"
}
},
{
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/$defs/__schema30"
}
}
]
}
}
}Schéma complet de la réponse
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"data": {
"$ref": "#/$defs/__schema0"
}
},
"required": [
"data"
],
"additionalProperties": false,
"$defs": {
"__schema0": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"type": "array",
"items": {
"$ref": "#/$defs/__schema0"
}
},
{
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/$defs/__schema0"
}
}
]
}
}
}Refus et reprise
Les statuts documentés pour cette opération sont 400, 401, 402, 403, 404, 409, 428, 429, 500, 503. Identifiez la cause avec error.code et, lorsqu’il est présent, error.reason. Une réponse 409 peut demander une relecture de révision ou signaler une commande incompatible ; une réponse 428 demande une confirmation humaine. Ne rejouez une écriture que selon son contrat.
Notes du contrat
{
"description": "Verified human confirmation (HTTP 428) and current product member with native administrator authority for shared views and global settings/facts. Commands save_view, save_subscription, save_alert, acknowledge_alert, configure, save_sla, save_theme, assign_theme, unassign_theme, save_currency_rate and record_ai_outcome. Stable idempotencyKey binds actor, transport and exact input; replay rechecks authorities and billing. Updates require inspected expectedRevision; subscription/currency null means absent. Native owners, SLA versions, alert windows, theme evidence and transaction effects are preserved. An active subscription schedules future native work; no email delivery is implied."
}