openapi: 3.0.0
info:
  title: smartpublisher
  version: 1.0.0
  license:
    name: ISC
  contact: {}
servers:
  - url: /customer-api/v1
paths:
  /subscriptions:
    get:
      operationId: GetSubscriptions
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiSubscriptionsPage'
      tags:
        - Subscriptions
      security:
        - personalAccessToken:
            - subscriptions:read
        - serviceToken:
            - subscriptions:read
      parameters:
        - in: query
          name: page
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: pageSize
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: accountId
          required: false
          schema:
            type: string
        - in: query
          name: publicationId
          required: false
          schema:
            type: string
        - in: query
          name: status
          required: false
          schema:
            type: string
        - in: query
          name: includeDeleted
          required: false
          schema:
            type: boolean
  /subscriptions/{subscriptionId}:
    get:
      operationId: GetSubscriptionById
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiSubscription'
      tags:
        - Subscriptions
      security:
        - personalAccessToken:
            - subscriptions:read
        - serviceToken:
            - subscriptions:read
      parameters:
        - in: path
          name: subscriptionId
          required: true
          schema:
            type: string
  /publications:
    get:
      operationId: GetPublications
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiPublicationsPage'
      tags:
        - Publications
      security:
        - personalAccessToken:
            - publications:read
        - serviceToken:
            - publications:read
      parameters:
        - in: query
          name: page
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: pageSize
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: search
          required: false
          schema:
            type: string
        - in: query
          name: isActive
          required: false
          schema:
            type: boolean
  /publications/{publicationId}:
    get:
      operationId: GetPublicationById
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiPublication'
      tags:
        - Publications
      security:
        - personalAccessToken:
            - publications:read
        - serviceToken:
            - publications:read
      parameters:
        - in: path
          name: publicationId
          required: true
          schema:
            type: string
  /invoices:
    get:
      operationId: GetInvoices
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiInvoicesPage'
      tags:
        - Invoices
      security:
        - personalAccessToken:
            - invoices:read
        - serviceToken:
            - invoices:read
      parameters:
        - in: query
          name: page
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: pageSize
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: accountId
          required: false
          schema:
            type: string
        - in: query
          name: publicationId
          required: false
          schema:
            type: string
        - in: query
          name: status
          required: false
          schema:
            type: string
  /invoices/{invoiceId}:
    get:
      operationId: GetInvoiceById
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiInvoice'
      tags:
        - Invoices
      security:
        - personalAccessToken:
            - invoices:read
        - serviceToken:
            - invoices:read
      parameters:
        - in: path
          name: invoiceId
          required: true
          schema:
            type: string
  /contacts:
    get:
      operationId: GetContacts
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiContactsPage'
      tags:
        - Contacts
      security:
        - personalAccessToken:
            - contacts:read
        - serviceToken:
            - contacts:read
      parameters:
        - in: query
          name: page
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: pageSize
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: accountId
          required: false
          schema:
            type: string
        - in: query
          name: search
          required: false
          schema:
            type: string
        - in: query
          name: includeHidden
          required: false
          schema:
            type: boolean
        - in: query
          name: includeSubsOnly
          required: false
          schema:
            type: boolean
        - in: query
          name: includeDeleted
          required: false
          schema:
            type: boolean
    post:
      operationId: CreateContactRecord
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiContact'
      tags:
        - Contacts
      security:
        - personalAccessToken:
            - contacts:write
        - serviceToken:
            - contacts:write
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerApiContactInput'
  /contacts/{contactId}:
    get:
      operationId: GetContactById
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiContact'
      tags:
        - Contacts
      security:
        - personalAccessToken:
            - contacts:read
        - serviceToken:
            - contacts:read
      parameters:
        - in: path
          name: contactId
          required: true
          schema:
            type: string
    patch:
      operationId: UpdateContactRecord
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiContact'
      tags:
        - Contacts
      security:
        - personalAccessToken:
            - contacts:write
        - serviceToken:
            - contacts:write
      parameters:
        - in: path
          name: contactId
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerApiContactInput'
    delete:
      operationId: DeleteContactRecord
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiContact'
      tags:
        - Contacts
      security:
        - personalAccessToken:
            - contacts:write
        - serviceToken:
            - contacts:write
      parameters:
        - in: path
          name: contactId
          required: true
          schema:
            type: string
  /contacts/{contactId}/restore:
    post:
      operationId: RestoreContactRecord
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiContact'
      tags:
        - Contacts
      security:
        - personalAccessToken:
            - contacts:write
        - serviceToken:
            - contacts:write
      parameters:
        - in: path
          name: contactId
          required: true
          schema:
            type: string
  /accounts:
    get:
      operationId: GetAccounts
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiAccountsPage'
      tags:
        - Accounts
      security:
        - personalAccessToken:
            - accounts:read
        - serviceToken:
            - accounts:read
      parameters:
        - in: query
          name: page
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: pageSize
          required: false
          schema:
            format: double
            type: number
        - in: query
          name: search
          required: false
          schema:
            type: string
        - in: query
          name: status
          required: false
          schema:
            type: string
  /accounts/{accountId}:
    get:
      operationId: GetAccountById
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerApiAccount'
      tags:
        - Accounts
      security:
        - personalAccessToken:
            - accounts:read
        - serviceToken:
            - accounts:read
      parameters:
        - in: path
          name: accountId
          required: true
          schema:
            type: string
components:
  examples: {}
  headers: {}
  parameters: {}
  requestBodies: {}
  responses: {}
  schemas:
    CustomerApiSubscription:
      properties:
        id:
          type: string
        subscriptionId:
          type: string
          nullable: true
        accountId:
          type: string
        publicationId:
          type: string
        renewedFromSubsId:
          type: string
          nullable: true
        renewalDate:
          type: string
          nullable: true
        status:
          type: string
          nullable: true
        startDate:
          type: string
          nullable: true
        endDate:
          type: string
          nullable: true
        expireDate:
          type: string
          nullable: true
        firstRunDate:
          type: string
          nullable: true
        subscriptionNumber:
          type: string
          nullable: true
        copies:
          type: string
          nullable: true
        autoReschedule:
          type: boolean
          nullable: true
        autoInvoice:
          type: boolean
          nullable: true
        notes:
          type: string
          nullable: true
        totalNetCharge:
          type: string
          nullable: true
        totalApplied:
          type: string
          nullable: true
        totalDue:
          type: string
          nullable: true
        createdAt:
          type: string
        updatedAt:
          type: string
        deletedAt:
          type: string
          nullable: true
      required:
        - id
        - subscriptionId
        - accountId
        - publicationId
        - renewedFromSubsId
        - renewalDate
        - status
        - startDate
        - endDate
        - expireDate
        - firstRunDate
        - subscriptionNumber
        - copies
        - autoReschedule
        - autoInvoice
        - notes
        - totalNetCharge
        - totalApplied
        - totalDue
        - createdAt
        - updatedAt
        - deletedAt
      type: object
      additionalProperties: false
    CustomerApiSubscriptionsPage:
      properties:
        items:
          items:
            $ref: '#/components/schemas/CustomerApiSubscription'
          type: array
        page:
          type: number
          format: double
        pageSize:
          type: number
          format: double
        total:
          type: number
          format: double
          nullable: true
      required:
        - items
        - page
        - pageSize
        - total
      type: object
      additionalProperties: false
    CustomerApiPublication:
      properties:
        id:
          type: string
        code:
          type: string
        name:
          type: string
          nullable: true
        isActive:
          type: boolean
          nullable: true
        frequency:
          type: string
          nullable: true
        issFrequency:
          type: string
          nullable: true
        issueDecimals:
          type: number
          format: double
          nullable: true
        createdAt:
          type: string
        updatedAt:
          type: string
      required:
        - id
        - code
        - name
        - isActive
        - frequency
        - issFrequency
        - issueDecimals
        - createdAt
        - updatedAt
      type: object
      additionalProperties: false
    CustomerApiPublicationsPage:
      properties:
        items:
          items:
            $ref: '#/components/schemas/CustomerApiPublication'
          type: array
        page:
          type: number
          format: double
        pageSize:
          type: number
          format: double
        total:
          type: number
          format: double
          nullable: true
      required:
        - items
        - page
        - pageSize
        - total
      type: object
      additionalProperties: false
    CustomerApiInvoice:
      properties:
        id:
          type: string
        accountId:
          type: string
        publicationId:
          type: string
          nullable: true
        issueId:
          type: string
          nullable: true
        status:
          type: string
        issueDate:
          type: string
          nullable: true
        dueDate:
          type: string
          nullable: true
        terms:
          type: string
          nullable: true
        total:
          type: string
          nullable: true
        totalDue:
          type: string
          nullable: true
        balanceCents:
          type: number
          format: double
        gross:
          type: string
          nullable: true
        net:
          type: string
          nullable: true
        invoiceType:
          type: string
          nullable: true
        invoiceDescription:
          type: string
          nullable: true
        invCharges:
          type: string
          nullable: true
        invInvoiced:
          type: string
          nullable: true
        invApplied:
          type: string
          nullable: true
        invDiscount:
          type: string
          nullable: true
        invTax:
          type: string
          nullable: true
        datePaid:
          type: string
          nullable: true
        isOpen:
          type: number
          format: double
          nullable: true
        notes:
          type: string
          nullable: true
        createdAt:
          type: string
        updatedAt:
          type: string
      required:
        - id
        - accountId
        - publicationId
        - issueId
        - status
        - issueDate
        - dueDate
        - terms
        - total
        - totalDue
        - balanceCents
        - gross
        - net
        - invoiceType
        - invoiceDescription
        - invCharges
        - invInvoiced
        - invApplied
        - invDiscount
        - invTax
        - datePaid
        - isOpen
        - notes
        - createdAt
        - updatedAt
      type: object
      additionalProperties: false
    CustomerApiInvoicesPage:
      properties:
        items:
          items:
            $ref: '#/components/schemas/CustomerApiInvoice'
          type: array
        page:
          type: number
          format: double
        pageSize:
          type: number
          format: double
        total:
          type: number
          format: double
          nullable: true
      required:
        - items
        - page
        - pageSize
        - total
      type: object
      additionalProperties: false
    CustomerApiContact:
      properties:
        id:
          type: string
        accountId:
          type: string
        ownerId:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
        firstName:
          type: string
          nullable: true
        lastName:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
        phone2:
          type: string
          nullable: true
        extension:
          type: string
          nullable: true
        hideContact:
          type: boolean
          nullable: true
        subsOnly:
          type: boolean
          nullable: true
        doNotEmail:
          type: boolean
          nullable: true
        email:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        notes:
          type: string
          nullable: true
        deletedAt:
          type: string
          nullable: true
        createdAt:
          type: string
          nullable: true
        updatedAt:
          type: string
          nullable: true
      required:
        - id
        - accountId
        - ownerId
        - name
        - firstName
        - lastName
        - phone
        - phone2
        - extension
        - hideContact
        - subsOnly
        - doNotEmail
        - email
        - title
        - notes
        - deletedAt
        - createdAt
        - updatedAt
      type: object
      additionalProperties: false
    CustomerApiContactsPage:
      properties:
        items:
          items:
            $ref: '#/components/schemas/CustomerApiContact'
          type: array
        page:
          type: number
          format: double
        pageSize:
          type: number
          format: double
        total:
          type: number
          format: double
          nullable: true
      required:
        - items
        - page
        - pageSize
        - total
      type: object
      additionalProperties: false
    CustomerApiContactInput:
      properties:
        accountId:
          type: string
        name:
          type: string
          nullable: true
        firstName:
          type: string
          nullable: true
        lastName:
          type: string
          nullable: true
        phone:
          type: string
          nullable: true
        phone2:
          type: string
          nullable: true
        extension:
          type: string
          nullable: true
        hideContact:
          type: boolean
          nullable: true
        subsOnly:
          type: boolean
          nullable: true
        doNotEmail:
          type: boolean
          nullable: true
        email:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        notes:
          type: string
          nullable: true
        deletedAt:
          type: string
          nullable: true
      required:
        - accountId
      type: object
      additionalProperties: false
    CustomerApiAccount:
      properties:
        id:
          type: string
        accountId:
          type: string
        company:
          type: string
          nullable: true
        address:
          type: string
          nullable: true
        suite:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        state:
          type: string
          nullable: true
        zip:
          type: string
          nullable: true
        country:
          type: string
          nullable: true
        webAddress:
          type: string
          nullable: true
        status:
          type: string
          nullable: true
        billingEmail:
          type: string
          nullable: true
        invoiceEmailEnabled:
          type: boolean
          nullable: true
        invoicePrintEnabled:
          type: boolean
          nullable: true
        doNotEmail:
          type: boolean
          nullable: true
        createdAt:
          type: string
        updatedAt:
          type: string
      required:
        - id
        - accountId
        - company
        - address
        - suite
        - city
        - state
        - zip
        - country
        - webAddress
        - status
        - billingEmail
        - invoiceEmailEnabled
        - invoicePrintEnabled
        - doNotEmail
        - createdAt
        - updatedAt
      type: object
      additionalProperties: false
    CustomerApiAccountsPage:
      properties:
        items:
          items:
            $ref: '#/components/schemas/CustomerApiAccount'
          type: array
        page:
          type: number
          format: double
        pageSize:
          type: number
          format: double
        total:
          type: number
          format: double
          nullable: true
      required:
        - items
        - page
        - pageSize
        - total
      type: object
      additionalProperties: false
  securitySchemes:
    personalAccessToken:
      type: http
      scheme: bearer
      description: Personal access token generated for a tenant user.
    serviceToken:
      type: http
      scheme: bearer
      description: Service token generated for a tenant-managed integration.
