openapi: 3.0.1
info:
  title: Audit log
  version: 1.0.0
  description:
    $ref: './md-partials/audit-log-intro.mdx'
servers:
  - url: "https://app.nobl9.com/api"
  - url: "https://us1.nobl9.com/api"
tags:
  - name: Audit log
paths:
  /audit/v1/logs/{kind}/{name}:
    get:
      summary: Get audit log for a specific object
      tags:
        - Audit log
      description: >-
        Retrieves audit logs for an SLO, project, and service.
        <hr/>
        Specify the required resource (`slo`, `service`, or `project`) using the `{kind}` path parameter.
        <p/>
        <div class='api-note'><b>AUTHENTICATION REQUIRED</b><br/>Authenticate API requests using an [access token](/api/access-token/generate-access-token). Include it in the Authorization header as <code>Bearer TOKEN</code>.</div>
      security:
        - bearerAuth: [ ]
      parameters:
        - in: header
          name: Project
          description: Project name, must conform to DNS (RFC 1123 format).
          required: true
          schema:
            type: string
        - in: header
          name: Organization
          description: Your organization ID. You can find it in the Nobl9 web application under your account settings.
          required: true
          schema:
            type: string
        - name: kind
          in: path
          required: true
          schema:
            type: string
            enum: [ slo, service, project ]
          description: The type of object for which to retrieve the audit log. Currently, only `slo`, `service`, and `project` are supported.
        - name: name
          in: path
          required: true
          schema:
            type: string
          description: The name of the object.
        - name: event
          in: query
          required: false
          schema:
            type: string
          description: The type of the event.
        - name: actorType
          in: query
          required: false
          schema:
            type: string
          description: The type of the actor.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 100
          description: The number of items to return.
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
          description: The starting point of the current page.
        - name: sortBy
          in: query
          required: false
          schema:
            type: string
            enum: [ timestamp ]
          description: Specifies the field to sort the results by.
        - name: sortOrder
          in: query
          required: false
          schema:
            type: string
            enum: [ asc, desc ]
          description: Determines the sorting order for the results.
      responses:
        '200':
          description: A list of audit log entries.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        timestamp:
                          type: string
                          format: date-time
                        actor:
                          type: object
                          properties:
                            clientId:
                              type: string
                            userId:
                              type: string
                            type:
                              type: string
                        event:
                          type: string
                  offset:
                    type: integer
                  limit:
                    type: integer
                  total:
                    type: integer
        '400':
          description: Invalid request parameters
        '500':
          description: Internal server error
  /audit/v1/logs:
    get:
      summary: Get all audit logs
      description: >-
        Retrieves audit logs for SLOs, projects, and services in your organization.
        <hr/>
        <p/>
        <div class='api-note'><b>AUTHENTICATION REQUIRED</b><br/>Authenticate API requests using an [access token](/api/access-token/generate-access-token). Include it in the Authorization header as <code>Bearer TOKEN</code>.</div>
      security:
        - bearerAuth: [ ]
      tags:
        - Audit log
      parameters:
        - $ref: '#/components/parameters/organization'
        - in: header
          name: Project
          description: Project name, must conform to DNS (RFC 1123 format).
          schema:
            type: string
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 100
          description: The number of items to return.
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            default: 0
          description: The starting point of the current page.
        - name: sortBy
          in: query
          required: false
          schema:
            type: string
            enum: [ timestamp ]
          description: The field to sort by.
        - name: sortOrder
          in: query
          required: false
          schema:
            type: string
            enum: [ asc, desc ]
          description: The order to sort by.
      responses:
        '200':
          description: A list of audit log entries.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        timestamp:
                          type: string
                          format: date-time
                        actor:
                          type: object
                          properties:
                            clientId:
                              type: string
                            userId:
                              type: string
                            type:
                              type: string
                        event:
                          type: string
                        data:
                          type: object
                  offset:
                    type: integer
                  limit:
                    type: integer
                  total:
                    type: integer
        '400':
          description: Invalid request parameters
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  responses:
    BadRequestError:
      description: Bad request
    UnauthorizedError:
      description: Unauthorized
      headers:
        WWW-Authenticate:
          schema:
            type: string
            description: 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate'
    ForbiddenError:
      description: Forbidden
    NotFoundError:
      description: One of the resources referenced in query or payload was not found.
    InternalServerError:
      description: Internal server error
    TooManyRequestsError:
      description: API call exceeded the rate limit
  parameters:
    organization:
      in: header
      name: Organization
      description: Your organization ID. You can find it in the Nobl9 web application under your account settings.
      required: true
      schema:
        type: string
  schemas:
    AccessToken:
      properties:
        access_token:
          type: string
      type: object
    Error:
      type: object
      description: >-
        Error always contains the status code and message.
        Additionally, the detailed description of the problem can be included.
      additionalProperties: true
      properties:
        message:
          type: string
        statusCode:
          type: integer
      required:
        - statusCode
        - message
