openapi: 3.2.0 info: title: Matomo Reporting API for plugin Annotations API version: 1.0.0 description: Provides API methods to create, update, delete, and query annotations. servers: - url: https://demo-proxy.innocraft.cloud/ description: Current Matomo instance security: - MatomoToken: [] tags: - name: Annotations description: Provides API methods to create, update, delete, and query annotations. paths: /index.php?module=API&method=Annotations.add: get: tags: - Annotations description: Creates a new annotation for a site. operationId: Annotations.add parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: The site ID to add the annotation to. required: true schema: type: integer example: 1 - name: date in: query description: The date the annotation is attached to. required: true schema: type: string example: yesterday - name: note in: query description: The text of the annotation (max 255 chars). required: true schema: type: string example: Investigate conversion spike from NZ campaign traffic. - name: starred in: query description: Whether the annotation should be starred. required: false schema: type: boolean default: false responses: '200': $ref: '#/components/responses/GenericArray' '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=Annotations.save: get: tags: - Annotations description: Updates an annotation for a site and returns the updated annotation. operationId: Annotations.save parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: The site ID to add the annotation to. required: true schema: type: integer example: 1 - name: idNote in: query description: The ID of the note. required: true schema: type: integer example: 12 - name: date in: query description: The date the annotation is attached to. If null, the annotation's date is not modified. required: false schema: type: string - name: note in: query description: The text of the annotation (max 255 chars). If null, the annotation's text is not modified. required: false schema: type: string - name: starred in: query description: Whether the annotation should be starred. If null, the annotation is not starred/un-starred, so the current state won't change. required: false schema: type: string responses: '200': $ref: '#/components/responses/GenericArray' '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=Annotations.delete: get: tags: - Annotations description: Removes an annotation from a site's list of annotations. operationId: Annotations.delete parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: The site ID to add the annotation to. required: true schema: type: integer example: 1 - name: idNote in: query description: The ID of the note to delete. required: true schema: type: integer example: 12 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=Annotations.deleteAll: get: tags: - Annotations description: Removes all annotations for a single site. Only superusers can use this method. operationId: Annotations.deleteAll parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: The ID of the site to remove annotations for. 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=Annotations.get: get: tags: - Annotations description: Returns a single annotation for one site. operationId: Annotations.get parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: The site ID the annotation is linked to. required: true schema: type: integer example: 1 - name: idNote in: query description: The ID of the annotation to get. required: true schema: type: integer example: 12 responses: '200': $ref: '#/components/responses/GenericArray' '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=Annotations.getAll: get: tags: - Annotations description: Returns every annotation for a specific site within a date range. operationId: Annotations.getAll parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: One site ID or a comma-separated list of site IDs. required: true schema: type: string example: '1' - name: date in: query description: The date of the period. required: false schema: type: string - name: period in: query description: The period type. required: false schema: type: string default: day enum: - day - week - month - year - range - name: lastN in: query description: Whether to include the last N periods in the date range. required: false schema: type: integer responses: '200': description: 'OK 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=Annotations.getAnnotationCountForDates: get: tags: - Annotations description: Returns the count of annotations for a list of periods, including the count of starred annotations. operationId: Annotations.getAnnotationCountForDates parameters: - $ref: '#/components/parameters/formatOptional' - name: idSite in: query description: The site ID(s) to get the annotation count for. required: true schema: type: string example: '1' - name: date in: query description: The date of the period. required: true schema: type: string example: yesterday - name: period in: query description: The period type. required: true schema: type: string enum: - day - week - month - year - range example: day - name: lastN in: query description: Whether to get counts for the last N number of periods or not. required: false schema: type: integer - name: getAnnotationText in: query description: Whether to include the note text when exactly one annotation exists for a date. required: false schema: type: boolean default: false responses: '200': description: 'OK Example responses require Super User access. Use Try it out to see a live response.' content: text/xml: [] application/json: [] '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' GenericArray: description: Generic 200 response with array body content: text/plain: schema: type: string text/html: schema: type: string application/json: schema: type: array items: [] application/xml: schema: type: array items: [] 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/