openapi: 3.0.0
info:
  description: >-
    This is the OAS 3.0 specification for the Account Management API in Sophos
    Central.
  version: 1.8.0
  contact:
    name: Sophos Central APIs
    email: apis@sophos.com
    url: 'https://developer.sophos.com'
  title: Account Management API
tags:
  - name: Token Management
    description: Manage access tokens.
servers:
  - url: 'https://api.central.sophos.com/accounts/v1'
    description: Global service in the production environment.
security:
  - bearerAuth: []
paths:
  /access-tokens:
    get:
      x-soph-permissions: 'download-token-management:read'
      tags:
        - Token Management
      summary: Get tokens
      description: Get all access tokens for a tenant.
      operationId: listTokensByTenantId
      parameters:
        - name: X-Tenant-ID
          in: header
          description: Tenant ID.
          required: true
          schema:
            type: string
            format: uuid
        - in: query
          name: page
          required: false
          schema:
            type: integer
            default: 1
          description: 'Page number to fetch, starting with 1.'
        - in: query
          name: pageSize
          description: Size of the page requested.
          required: false
          schema:
            type: integer
            default: 50
            maximum: 50
            minimum: 1
        - in: query
          name: pageTotal
          required: false
          schema:
            type: boolean
            default: false
          description: >-
            Whether the number of pages should be calculated and returned in the
            response.
      responses:
        '200':
          description: Access tokens.
          content:
            application/json:
              schema:
                type: object
                description: List of access tokens.
                required:
                  - items
                  - pages
                properties:
                  items:
                    type: array
                    description: List of access tokens.
                    items:
                      type: object
                      required:
                        - id
                        - token
                        - type
                        - createdAt
                        - expiresAt
                        - url
                        - createdBy
                      description: Tells the caller about the token.
                      properties:
                        id:
                          description: Unique token ID.
                          type: string
                          format: uuid
                        token:
                          description: Access token.
                          type: string
                        type:
                          type: string
                          enum:
                            - sophosLinuxSensor
                          description: >-
                            Token type. * sophosLinuxSensor - Token that you can
                            use to authenticate downloads of Sophos Linux
                            Sensor.
                        label:
                          description: Token description.
                          type: string
                        createdAt:
                          description: Token created.
                          type: string
                          format: datetime
                        expiresAt:
                          description: Token expires on.
                          type: string
                          format: datetime
                        url:
                          description: URL that the token gives access to.
                          type: string
                        createdBy:
                          type: object
                          required:
                            - id
                            - type
                          properties:
                            id:
                              description: Principal ID.
                              type: string
                            type:
                              description: Type of entity that made this change.
                              type: string
                              format: enum
                              enum:
                                - user
                                - service
                            name:
                              description: Principal name.
                              type: string
                            accountType:
                              type: string
                              description: Account type for this principal.
                              enum:
                                - partner
                                - tenant
                                - organization
                                - distributor
                            accountId:
                              description: Account ID.
                              type: string
                              format: uuid
                  pages:
                    type: object
                    required:
                      - current
                      - size
                      - maxSize
                    properties:
                      current:
                        type: integer
                        description: The 1-based page number being returned.
                      size:
                        type: integer
                        description: The size of the page being returned.
                      total:
                        type: integer
                        description: >-
                          (Optional) The total number of pages that exist, if
                          pageTotal=true in the request.
                      items:
                        type: integer
                        description: (Optional) The total number of items across all pages.
                      maxSize:
                        type: integer
                        description: The maximum page size that can be requested.
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
    post:
      x-soph-permissions: 'download-token-management:write'
      tags:
        - Token Management
      summary: Create token
      description: Create access token for a tenant.
      operationId: createToken
      parameters:
        - name: X-Tenant-ID
          in: header
          description: Tenant ID.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: Create an access token.
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Request to create a token.
              required:
                - label
                - type
              properties:
                label:
                  description: >-
                    Token label. Must be between 0 and 50 characters long and
                    only contain alphanumeric characters, commas, hyphens and
                    periods. Special characters are not allowed.
                  type: string
                  pattern: '^[a-zA-Z\d,\s\-.]{0,50}$'
                type:
                  type: string
                  enum:
                    - sophosLinuxSensor
                  description: >-
                    Token type. * sophosLinuxSensor - Token that you can use to
                    authenticate downloads of Sophos Linux Sensor.
                expiresAt:
                  description: Token expires on.
                  type: string
                  format: datetime
            examples:
              NewTokenRequest:
                value:
                  label: Test Token
                  type: sophosLinuxSensor
                  expiresAt: '2021-04-29T15:32:28.482Z'
      responses:
        '201':
          description: Access token.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - token
                  - type
                  - createdAt
                  - expiresAt
                  - url
                  - createdBy
                description: Tells the caller about the token.
                properties:
                  id:
                    description: Unique token ID.
                    type: string
                    format: uuid
                  token:
                    description: Access token.
                    type: string
                  type:
                    type: string
                    enum:
                      - sophosLinuxSensor
                    description: >-
                      Token type. * sophosLinuxSensor - Token that you can use
                      to authenticate downloads of Sophos Linux Sensor.
                  label:
                    description: Token description.
                    type: string
                  createdAt:
                    description: Token created.
                    type: string
                    format: datetime
                  expiresAt:
                    description: Token expires on.
                    type: string
                    format: datetime
                  url:
                    description: URL that the token gives access to.
                    type: string
                  createdBy:
                    type: object
                    required:
                      - id
                      - type
                    properties:
                      id:
                        description: Principal ID.
                        type: string
                      type:
                        description: Type of entity that made this change.
                        type: string
                        format: enum
                        enum:
                          - user
                          - service
                      name:
                        description: Principal name.
                        type: string
                      accountType:
                        type: string
                        description: Account type for this principal.
                        enum:
                          - partner
                          - tenant
                          - organization
                          - distributor
                      accountId:
                        description: Account ID.
                        type: string
                        format: uuid
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
        '403':
          description: Request is incompatible with tenant's current licenses.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
  '/access-tokens/{tokenId}':
    delete:
      x-soph-permissions: 'download-token-management:write'
      tags:
        - Token Management
      summary: Revoke token
      description: Revoke access token for a tenant.
      operationId: revokeToken
      parameters:
        - name: X-Tenant-ID
          in: header
          description: Tenant ID.
          required: true
          schema:
            type: string
            format: uuid
        - name: tokenId
          in: path
          description: Token ID.
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Token deleted.
          content:
            application/json:
              schema:
                type: object
                description: Response to a previous request to delete an item.
                required:
                  - deleted
                properties:
                  deleted:
                    type: boolean
              example:
                deleted: true
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
    patch:
      x-soph-permissions: 'download-token-management:write'
      tags:
        - Token Management
      summary: Update token
      description: Update access token for a tenant.
      operationId: updateToken
      parameters:
        - name: X-Tenant-ID
          in: header
          description: Tenant ID.
          required: true
          schema:
            type: string
            format: uuid
        - name: tokenId
          in: path
          description: Token ID.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: Update access token.
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Renew a token.
              properties:
                label:
                  description: >-
                    Token label. Must be between 0 and 50 characters long and
                    only contain alphanumeric characters, commas, hyphens and
                    periods. Special characters are not allowed.
                  type: string
                  pattern: '^[a-zA-Z\d,\s\-.]{0,50}$'
                expiresAt:
                  description: Token expires on.
                  type: string
                  format: datetime
            examples:
              RenewTokenRequest:
                value:
                  label: Test Token
                  expiresAt: '2021-04-29T15:32:28.482Z'
      responses:
        '200':
          description: Access token.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - token
                  - type
                  - createdAt
                  - expiresAt
                  - url
                  - createdBy
                description: Tells the caller about the token.
                properties:
                  id:
                    description: Unique token ID.
                    type: string
                    format: uuid
                  token:
                    description: Access token.
                    type: string
                  type:
                    type: string
                    enum:
                      - sophosLinuxSensor
                    description: >-
                      Token type. * sophosLinuxSensor - Token that you can use
                      to authenticate downloads of Sophos Linux Sensor.
                  label:
                    description: Token description.
                    type: string
                  createdAt:
                    description: Token created.
                    type: string
                    format: datetime
                  expiresAt:
                    description: Token expires on.
                    type: string
                    format: datetime
                  url:
                    description: URL that the token gives access to.
                    type: string
                  createdBy:
                    type: object
                    required:
                      - id
                      - type
                    properties:
                      id:
                        description: Principal ID.
                        type: string
                      type:
                        description: Type of entity that made this change.
                        type: string
                        format: enum
                        enum:
                          - user
                          - service
                      name:
                        description: Principal name.
                        type: string
                      accountType:
                        type: string
                        description: Account type for this principal.
                        enum:
                          - partner
                          - tenant
                          - organization
                          - distributor
                      accountId:
                        description: Account ID.
                        type: string
                        format: uuid
        '400':
          description: Bad request.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
        '403':
          description: Request is incompatible with tenant's current licenses.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
        '404':
          description: Access token not found.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  correlationId:
                    type: string
                    format: uuid
                  code:
                    type: string
                  createdAt:
                    type: string
                    format: datetime
                  requestId:
                    type: string
                    format: uuid
                  docUrl:
                    type: string
                    format: uri
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
