openapi: 3.1.0 info: title: Dexwize Campaign Service version: 1.0.0 description: > Surveys, notices and self-help prompts (E13). Management and results use user bearer tokens (tenant-scoped); /v1/device/* uses the enrollment device credential ("Authorization: Device "). Results and sentiment never describe fewer than 5 respondents; respondents are stored only as keyed pseudonyms. servers: - url: https://api.dexwize.example security: - bearer: [] paths: /v1/campaigns: get: operationId: listCampaigns responses: '200': description: OK content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/Campaign' } } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } post: operationId: createCampaign requestBody: required: true content: application/json: schema: { $ref: '#/components/schemas/CreateCampaign' } responses: '201': description: Draft created content: application/json: schema: { $ref: '#/components/schemas/Campaign' } '400': { description: Invalid campaign } '403': description: "Missing permission, or the tenant is not entitled to campaigns (and digital_adoption for guides) (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/campaigns/{id}: get: operationId: getCampaign parameters: [{ $ref: '#/components/parameters/Id' }] responses: '200': description: OK content: application/json: schema: { $ref: '#/components/schemas/Campaign' } '404': { description: Not found } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/campaigns/{id}/publish: post: operationId: publishCampaign description: Requires English and Arabic everywhere; free-text questions are refused in strict privacy mode. parameters: [{ $ref: '#/components/parameters/Id' }] responses: '200': description: Published content: application/json: schema: { $ref: '#/components/schemas/Campaign' } '400': { description: Publishing rule failed } '404': { description: Not found } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/campaigns/{id}/close: post: operationId: closeCampaign parameters: [{ $ref: '#/components/parameters/Id' }] responses: '200': description: Closed content: application/json: schema: { $ref: '#/components/schemas/Campaign' } '400': { description: Not published } '404': { description: Not found } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/campaigns/{id}/results: get: operationId: getCampaignResults parameters: - { $ref: '#/components/parameters/Id' } - { name: byGroup, in: query, schema: { type: boolean } } responses: '200': description: k-anonymous results content: application/json: schema: { $ref: '#/components/schemas/Results' } '404': { description: Not found } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/sentiment: get: operationId: getSentiment summary: Group sentiment 0-100 for scoring-service (groups of at least 5 respondents) parameters: - { name: from, in: query, schema: { type: string, format: date-time } } - { name: to, in: query, schema: { type: string, format: date-time } } responses: '200': description: OK content: application/json: schema: type: object properties: fleet: { type: [number, 'null'] } fleetRespondents: { type: integer } groups: type: array items: type: object properties: group: { type: string } sentiment: { type: number } respondents: { type: integer, minimum: 5 } '400': { description: Period over 180 days } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/me/campaigns: get: operationId: myCampaigns parameters: [{ $ref: '#/components/parameters/Locale' }] responses: '200': description: Open campaigns for the signed-in employee, in their language content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/CampaignView' } } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/me/campaigns/{id}/responses: post: operationId: respondAsEmployee parameters: [{ $ref: '#/components/parameters/Id' }] requestBody: { $ref: '#/components/requestBodies/Response' } responses: '202': { description: Accepted } '400': { description: Invalid answers } '404': { description: Not open or not targeted } '409': { description: Already responded } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/device/campaigns: get: operationId: deviceCampaigns security: [{ device: [] }] parameters: [{ $ref: '#/components/parameters/Locale' }] responses: '200': description: Open campaigns targeting this device content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/CampaignView' } } '401': { description: Invalid device credential } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/device/campaigns/{id}/responses: post: operationId: respondAsDevice security: [{ device: [] }] parameters: [{ $ref: '#/components/parameters/Id' }] requestBody: { $ref: '#/components/requestBodies/Response' } responses: '202': { description: Accepted } '400': { description: Invalid answers } '401': { description: Invalid device credential } '404': { description: Not open or not targeted } '409': { description: Already responded } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/device/guides: get: operationId: deviceGuides description: >- Open digital adoption guides targeting this device (E30, ADR-0036), in English and Arabic. The agent caches them for the browser extension, which shows a guide only inside the allow-listed app it names. security: [{ device: [] }] responses: '200': description: Open guides targeting this device content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/GuideView' } } '401': { description: Invalid device credential } '403': description: "Missing permission, or the tenant is not entitled to digital_adoption (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/device/prompts: get: operationId: devicePrompts security: [{ device: [] }] parameters: [{ $ref: '#/components/parameters/Locale' }] responses: '200': description: Self-help prompts due for this device content: application/json: schema: type: array items: type: object properties: ruleId: { type: string, format: uuid } findingType: { type: string } actionId: { type: string } prompt: { type: string } consent: { type: string } locale: { type: string, enum: [en, ar] } '401': { description: Invalid device credential } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/device/prompts/{ruleId}/decision: post: operationId: decidePrompt security: [{ device: [] }] parameters: - { name: ruleId, in: path, required: true, schema: { type: string, format: uuid } } requestBody: required: true content: application/json: schema: type: object required: [decision] properties: decision: { type: string, enum: [Accepted, Declined] } locale: { type: string, enum: [en, ar] } responses: '200': description: Consent recorded; on acceptance the remediation request status is included content: application/json: schema: { $ref: '#/components/schemas/Consent' } '401': { description: Invalid device credential } '404': { description: Prompt not currently offered to this device } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/self-help/rules: get: operationId: listSelfHelpRules responses: '200': description: OK content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/SelfHelpRule' } } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } post: operationId: createSelfHelpRule requestBody: required: true content: application/json: schema: type: object required: [findingType, actionId, prompt, consent, cooldownHours] properties: findingType: { type: string } actionId: { type: string } prompt: { $ref: '#/components/schemas/LocalizedText' } consent: { $ref: '#/components/schemas/LocalizedText' } cooldownHours: { type: integer, minimum: 1, maximum: 720 } responses: '201': description: Created content: application/json: schema: { $ref: '#/components/schemas/SelfHelpRule' } '400': { description: Invalid rule } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/self-help/rules/{id}/enabled: put: operationId: setSelfHelpRuleEnabled parameters: [{ $ref: '#/components/parameters/Id' }] requestBody: required: true content: application/json: schema: { type: object, required: [enabled], properties: { enabled: { type: boolean } } } responses: '200': description: Updated content: application/json: schema: { $ref: '#/components/schemas/SelfHelpRule' } '404': { description: Not found } '403': description: "Missing permission, or the tenant is not entitled to campaigns (error feature_not_entitled)" content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } '503': { $ref: '#/components/responses/EntitlementsUnavailable' } /v1/self-help/consents: get: operationId: listConsents parameters: - { name: deviceId, in: query, required: true, schema: { type: string, format: uuid } } responses: '200': description: Consent records for a device (auditors) content: application/json: schema: { type: array, items: { $ref: '#/components/schemas/Consent' } } components: responses: EntitlementsUnavailable: description: The tenant's entitlements could not be confirmed and nothing usable was cached, so the paid feature is refused (fail closed, ADR-0053). Retry-After is set. content: { application/json: { schema: { $ref: '#/components/schemas/EntitlementRefusal' } } } securitySchemes: bearer: { type: http, scheme: bearer, bearerFormat: JWT } device: { type: apiKey, in: header, name: Authorization, description: '"Device "' } parameters: Id: { name: id, in: path, required: true, schema: { type: string, format: uuid } } Locale: { name: locale, in: query, schema: { type: string, enum: [en, ar] } } requestBodies: Response: required: true content: application/json: schema: type: object required: [answers] properties: answers: type: array items: type: object required: [questionId] properties: questionId: { type: string } number: { type: integer, description: 'Rating 1-5 or NPS 0-10' } choice: { type: integer } text: { type: string, maxLength: 1000, description: PII-scrubbed before storage } schemas: EntitlementRefusal: description: Module licensing refusal (ADR-0053). type: object required: [error, feature] properties: error: { type: string, enum: [feature_not_entitled, entitlements_unavailable] } feature: { type: string, description: Catalogue feature code, for example campaigns } LocalizedText: type: object properties: en: { type: [string, 'null'] } ar: { type: [string, 'null'] } Question: type: object properties: id: { type: string } type: { type: string, enum: [Rating, Nps, SingleChoice, FreeText] } prompt: { $ref: '#/components/schemas/LocalizedText' } options: { type: [array, 'null'], items: { $ref: '#/components/schemas/LocalizedText' } } required: { type: boolean } sentiment: { type: boolean } CreateCampaign: type: object required: [type, title, audienceKind, startsAt, endsAt] properties: type: { type: string, enum: [Survey, Notice, Guide] } title: { $ref: '#/components/schemas/LocalizedText' } body: { $ref: '#/components/schemas/LocalizedText' } questions: { type: array, maxItems: 20, items: { $ref: '#/components/schemas/Question' } } audienceKind: { type: string, enum: [All, DeviceGroups, Departments] } audienceValues: { type: array, items: { type: string } } startsAt: { type: string, format: date-time } endsAt: { type: string, format: date-time } guide: { $ref: '#/components/schemas/Guide' } Guide: type: object description: Required for type Guide and absent otherwise. required: [appId, steps] properties: appId: { type: string, pattern: '^[a-z0-9._-]{1,64}$', description: Tenant allow-list app id (never a URL) } steps: type: array minItems: 1 maxItems: 20 items: type: object required: [selector, title, body] properties: selector: { type: string, maxLength: 200, description: CSS selector subset (ids, classes, elements, attributes, structural pseudo-classes) } title: { $ref: '#/components/schemas/LocalizedText' } body: { $ref: '#/components/schemas/LocalizedText' } placement: { type: string, enum: [Bottom, Top, Start, End] } GuideView: type: object properties: id: { type: string, format: uuid } appId: { type: string } title: { $ref: '#/components/schemas/LocalizedText' } endsAt: { type: string, format: date-time } steps: type: array items: type: object properties: selector: { type: string } title: { $ref: '#/components/schemas/LocalizedText' } body: { $ref: '#/components/schemas/LocalizedText' } placement: { type: string, enum: [bottom, top, start, end] } Campaign: type: object properties: id: { type: string, format: uuid } type: { type: integer } title: { $ref: '#/components/schemas/LocalizedText' } status: { type: integer, description: '0 draft, 1 published, 2 closed' } startsAt: { type: string, format: date-time } endsAt: { type: string, format: date-time } questions: { type: array, items: { $ref: '#/components/schemas/Question' } } CampaignView: type: object properties: id: { type: string, format: uuid } type: { type: string } title: { type: string } body: { type: [string, 'null'] } endsAt: { type: string, format: date-time } questions: type: array items: type: object properties: id: { type: string } type: { type: string } prompt: { type: string } options: { type: [array, 'null'], items: { type: string } } required: { type: boolean } Results: type: object properties: campaignId: { type: string, format: uuid } audienceSize: { type: integer } responses: { type: integer } responseRate: { type: [number, 'null'] } suppressed: { type: boolean } groups: type: array items: type: object properties: group: { type: string } respondents: { type: integer, minimum: 5 } sentiment: { type: [number, 'null'] } questions: { type: array, items: { type: object, additionalProperties: true } } SelfHelpRule: type: object properties: id: { type: string, format: uuid } findingType: { type: string } actionId: { type: string } prompt: { $ref: '#/components/schemas/LocalizedText' } consentText: { $ref: '#/components/schemas/LocalizedText' } cooldown: { type: string } enabled: { type: boolean } Consent: type: object properties: id: { type: string, format: uuid } deviceId: { type: string, format: uuid } ruleId: { type: string, format: uuid } actionId: { type: string } decision: { type: integer, description: '0 accepted, 1 declined' } locale: { type: string } consentHash: { type: string } at: { type: string, format: date-time } remediationId: { type: [string, 'null'], format: uuid } remediationStatus: { type: [string, 'null'] }