openapi: 3.2.0 info: title: Matomo Reporting API for plugin Segment Editor API version: 1.0.0 description: The SegmentEditor API lets you add, update, delete custom Segments, and list saved segments. servers: - url: https://demo-proxy.innocraft.cloud/ description: Current Matomo instance security: - MatomoToken: [] tags: - name: SegmentEditor description: The SegmentEditor API lets you add, update, delete custom Segments, and list saved segments. paths: /index.php?module=API&method=SegmentEditor.isUserCanAddNewSegment: get: tags: - SegmentEditor description: Returns whether the current user can create a new stored segment. operationId: SegmentEditor.isUserCanAddNewSegment parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: If supplied, checks permissions for this site; otherwise checks whether the user can create an all-websites segment. required: false schema: type: integer responses: '200': description: '`true` if the current user can add a segment for the requested scope, `false` otherwise. Example responses require Super User access. Use Try it out to see a live response.' content: text/xml: [] application/json: [] application/vnd.ms-excel: [] '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.delete: get: tags: - SegmentEditor description: Deletes a stored segment. operationId: SegmentEditor.delete parameters: - $ref: '#/components/parameters/formatOptional' - name: idSegment in: query description: The ID of the stored segment to delete. required: true schema: type: integer example: 1 responses: '200': $ref: '#/components/responses/GenericSuccess' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.update: get: tags: - SegmentEditor description: Modifies an existing stored segment. operationId: SegmentEditor.update parameters: - $ref: '#/components/parameters/formatOptional' - name: idSegment in: query description: The ID of the stored segment to modify. required: true schema: type: integer example: 1 - name: name in: query description: The new name of the segment. required: true schema: type: string example: Pricing - name: definition in: query description: The new definition of the segment. required: true schema: type: string example: countryCode==NZ - name: idSite in: query description: If supplied, associates the stored segment with a single site. required: false schema: type: integer - name: autoArchive in: query description: Whether to automatically archive data with the segment or not. required: false schema: type: boolean default: false - name: enabledAllUsers in: query description: Whether the stored segment is viewable by all users or just the one that created it. required: false schema: type: boolean default: false responses: '200': $ref: '#/components/responses/GenericSuccess' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.add: get: tags: - SegmentEditor description: Adds a new stored segment. operationId: SegmentEditor.add parameters: - $ref: '#/components/parameters/formatOptional' - name: name in: query description: The new name of the segment. required: true schema: type: string example: Pricing - name: definition in: query description: The new definition of the segment. required: true schema: type: string example: countryCode==NZ - name: idSite in: query description: If supplied, associates the stored segment with a single site. required: false schema: type: integer - name: autoArchive in: query description: Whether to automatically archive data with the segment or not. required: false schema: type: boolean default: false - name: enabledAllUsers in: query description: Whether the stored segment is viewable by all users or just the one that created it. required: false schema: type: boolean default: false responses: '200': description: 'The newly created segment ID. Example responses require Super User access. Use Try it out to see a live response.' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.star: get: tags: - SegmentEditor description: Stars a stored segment. operationId: SegmentEditor.star parameters: - $ref: '#/components/parameters/formatOptional' - name: idSegment in: query description: The ID of the stored segment to star. required: true schema: type: integer example: 1 responses: '200': description: 'The update result and new starred state. Example responses require Super User access. Use Try it out to see a live response.' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.unstar: get: tags: - SegmentEditor description: Unstars a stored segment. operationId: SegmentEditor.unstar parameters: - $ref: '#/components/parameters/formatOptional' - name: idSegment in: query description: The ID of the stored segment to unstar. required: true schema: type: integer example: 1 responses: '200': description: 'The update result and new starred state. Example responses require Super User access. Use Try it out to see a live response.' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.get: get: tags: - SegmentEditor description: Returns a stored segment by ID. operationId: SegmentEditor.get parameters: - $ref: '#/components/parameters/formatOptional' - name: idSegment in: query description: The ID of the stored segment to fetch. required: true schema: type: integer example: 1 responses: '200': description: 'The stored segment, or `null` if it does not exist. Example responses require Super User access. Use Try it out to see a live response.' content: text/xml: [] application/json: [] application/vnd.ms-excel: [] '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.getAll: get: tags: - SegmentEditor description: Returns all stored segments. operationId: SegmentEditor.getAll parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: If supplied, returns stored segments for one site only; otherwise returns all visible stored segments. required: false schema: type: integer responses: '200': description: 'Stored segments visible to the current user. Example responses require Super User access. Use Try it out to see a live response.' content: text/xml: [] application/json: [] application/vnd.ms-excel: [] '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' /index.php?module=API&method=SegmentEditor.getSegmentData: get: tags: - SegmentEditor description: Returns visit and action totals for a pre-processed segment together with visit evolution. operationId: SegmentEditor.getSegmentData parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: The numeric ID of the website to query. required: true schema: type: integer example: 1 - name: period in: query description: The period to process, processes data for the period containing the specified date. required: true schema: type: string enum: - day - week - month - year - range example: day - name: date in: query description: The date or date range to process. 'YYYY-MM-DD', magic keywords (today, yesterday, lastWeek, lastMonth, lastYear), or date range (ie, 'YYYY-MM-DD,YYYY-MM-DD', lastX, previousX). required: true schema: type: string example: yesterday - name: segment in: query description: 'Custom segment to filter the report. Example: "referrerName==example.com" Supports AND (;) and OR (,) operators.' required: true schema: type: string example: countryCode==NZ responses: '200': description: 'Visit totals, action totals, and visit evolution metadata for the segment. Example responses require Super User access. Use Try it out to see a live response.' '400': $ref: '#/components/responses/BadRequest' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/ServerError' default: $ref: '#/components/responses/DefaultError' components: schemas: GenericSuccessXml: description: Generic Matomo success payload in XML. required: - success properties: success: properties: message: type: string xml: attribute: true example: ok type: object xml: name: success type: object xml: name: result example: success: message: ok additionalProperties: true GenericSuccess: description: Generic Matomo success payload. required: - result - message properties: result: type: string example: success message: type: string example: ok code: type: integer example: '200' type: object example: result: success message: ok additionalProperties: true ErrorXml: description: Generic Matomo error payload in XML. properties: error: properties: message: type: string xml: attribute: true example: There was an error type: object xml: name: error type: object xml: name: result Error: description: Generic Matomo error payload. required: - result - message properties: result: type: string example: error message: type: string example: There was an error code: type: integer type: object additionalProperties: true responses: NotFound: description: Resource not found. content: text/plain: schema: type: string example: 'Error: The method is not available.' text/html: schema: type: string example: The method is not available. application/json: schema: $ref: '#/components/schemas/Error' application/xml: schema: $ref: '#/components/schemas/ErrorXml' ServerError: description: Unexpected server error. content: text/plain: schema: type: string example: 'Error: There was an error.' text/html: schema: type: string example: There was an error. application/json: schema: $ref: '#/components/schemas/Error' application/xml: schema: $ref: '#/components/schemas/ErrorXml' Unauthorized: description: Authentication failed or missing token. content: text/plain: schema: type: string example: 'Error: You must be logged in to access this functionality.' text/html: schema: type: string example: You must be logged in to access this functionality. application/json: schema: $ref: '#/components/schemas/Error' application/xml: schema: $ref: '#/components/schemas/ErrorXml' Forbidden: description: Authenticated but not allowed to access the resource. content: text/plain: schema: type: string example: 'Error: Not authorised.' text/html: schema: type: string example: Not authorised. application/json: schema: $ref: '#/components/schemas/Error' application/xml: schema: $ref: '#/components/schemas/ErrorXml' DefaultError: description: Default error response (any non-2xx). content: text/plain: schema: type: string example: 'Error: There was an error.' text/html: schema: type: string example: There was an error. application/json: schema: $ref: '#/components/schemas/Error' application/xml: schema: $ref: '#/components/schemas/ErrorXml' GenericSuccess: description: Generic 200 response content: text/plain: schema: type: string example: Success:ok text/html: schema: type: string example: '' application/json: schema: $ref: '#/components/schemas/GenericSuccess' application/xml: schema: $ref: '#/components/schemas/GenericSuccessXml' BadRequest: description: Bad request (validation or missing parameters). content: text/plain: schema: type: string example: 'Error: There was an error.' text/html: schema: type: string example: There was an error. application/json: schema: $ref: '#/components/schemas/Error' application/xml: schema: $ref: '#/components/schemas/ErrorXml' parameters: formatOptional: name: format in: query description: Response format. Defaults to `xml`. Use `original` to get the original PHP data structure. required: false schema: type: string default: xml enum: - xml - json - csv - tsv - html - rss - original securitySchemes: MatomoToken: type: http description: Paste your token generated from Personal > Security. Swagger will send it as a Bearer token. scheme: bearer externalDocs: description: Matomo Reporting API developer page url: https://developer.matomo.org/api-reference/reporting-api/