openapi: 3.0.0
x-mint:
  mcp:
    enabled: true
info:
  title: Offers - Add-ons API
  description: >-
    fabric Add-ons are additional items that shoppers can buy while placing an
    order. These endpoints let you create, update, and delete details of
    add-ons, including their prices and currency types.
  version: 3.0.0
  x-audience: external-public
  termsOfService: https://fabric.inc/terms-of-use
  contact:
    name: Offers support
    email: support@fabric.inc
  license:
    name: fabric API License
    url: https://fabric.inc/api-license
externalDocs:
  description: Find out more about Offers
  url: https://developer.fabric.inc/docs/offers-overview
servers:
  - url: https://api.fabric.inc/v3
    description: Production environment
paths:
  /addons:
    get:
      tags:
        - Add-ons
      summary: Get all add-ons
      description: Get a paginated list of all the created add-ons.
      operationId: getAddons
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: '#/components/parameters/xFabricTenantId'
        - $ref: '#/components/parameters/xFabricChannelId'
        - $ref: '#/components/parameters/xClientId'
        - $ref: '#/components/parameters/xFabricRequestId'
        - $ref: '#/components/parameters/queryParameterSize'
        - $ref: '#/components/parameters/queryParameterOffset'
        - name: sort
          in: query
          description: >-
            The criteria to sort the results. Use the format {sort order}{field
            name}, where `-` refers to a descending order and `+` refers to an
            ascending order.
          required: false
          schema:
            type: string
            default: '-updatedAt'
            enum:
              - '-updatedAt'
              - +updatedAt
              - '-id'
              - +id
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getAddonsResponse'
        '400':
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/badSizeError'
                  - $ref: '#/components/schemas/badSortingError'
                  - $ref: '#/components/schemas/missingTenantHeader'
                  - $ref: '#/components/schemas/error400'
        '401':
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error401'
        '500':
          description: Internal server error
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error500'
    post:
      tags:
        - Add-ons
      summary: Create add-on
      description: >-
        Create an add-on with its price and currency details. By creating
        add-ons, you can enhance customer experience by allowing them to choose
        personalized products while placing an order.
      operationId: createAddon
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: '#/components/parameters/xFabricTenantId'
        - $ref: '#/components/parameters/xFabricChannelId'
        - $ref: '#/components/parameters/xClientId'
        - $ref: '#/components/parameters/xFabricRequestId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createAddonRequest'
      responses:
        '201':
          description: Created
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createAddonResponse'
        '400':
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/addonNameExist'
                  - $ref: '#/components/schemas/addonCannotBeEmpty'
                  - $ref: '#/components/schemas/priceEqualOrGreaterThanZero'
                  - $ref: '#/components/schemas/invalidCurrencyCode'
                  - $ref: '#/components/schemas/missingTenantHeader'
                  - $ref: '#/components/schemas/error400'
        '401':
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error401'
        '500':
          description: Internal server error
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error500'
  /addons/{id}:
    put:
      tags:
        - Add-ons
      summary: Update a specific add-on
      description: Update a specific add-on by ID.
      operationId: updateAddon
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: '#/components/parameters/xFabricTenantId'
        - $ref: '#/components/parameters/xFabricChannelId'
        - $ref: '#/components/parameters/xClientId'
        - $ref: '#/components/parameters/xFabricRequestId'
        - name: id
          in: path
          required: true
          description: Add-on ID
          schema:
            type: integer
            format: int32
            example: 100004
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateAddonRequest'
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/updateAddonResponse'
        '400':
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/addonNameExist'
                  - $ref: '#/components/schemas/addonCannotBeEmpty'
                  - $ref: '#/components/schemas/priceEqualOrGreaterThanZero'
                  - $ref: '#/components/schemas/invalidCurrencyCode'
                  - $ref: '#/components/schemas/addonInvalidId'
                  - $ref: '#/components/schemas/missingTenantHeader'
                  - $ref: '#/components/schemas/error400'
        '401':
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error401'
        '404':
          description: Not Found
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/addonNotFound'
        '500':
          description: Internal server error
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error500'
    get:
      tags:
        - Add-ons
      summary: Get a specific add-on
      description: Get a specific add-on by ID.
      operationId: getAddon
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: '#/components/parameters/xFabricTenantId'
        - $ref: '#/components/parameters/xFabricChannelId'
        - $ref: '#/components/parameters/xClientId'
        - $ref: '#/components/parameters/xFabricRequestId'
        - in: path
          name: id
          schema:
            type: integer
            format: int32
          required: true
          description: Add-on ID
          example: 100004
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getAddonResponse'
        '400':
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/addonInvalidId'
                  - $ref: '#/components/schemas/missingTenantHeader'
                  - $ref: '#/components/schemas/error400'
        '401':
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error401'
        '404':
          description: Not Found
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/addonNotFound'
        '500':
          description: Internal server error
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error500'
    delete:
      tags:
        - Add-ons
      summary: Delete a specific add-on
      description: Delete an add-on by ID.
      operationId: deleteAddon
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: '#/components/parameters/xFabricTenantId'
        - $ref: '#/components/parameters/xFabricChannelId'
        - $ref: '#/components/parameters/xClientId'
        - $ref: '#/components/parameters/xFabricRequestId'
        - name: id
          in: path
          required: true
          description: Add-on ID
          schema:
            type: integer
            format: int32
          example: 100004
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/deleteAddonResponse'
              example:
                id: 100004
                priceListId: 100000
                name: Tablet
                channelId: '12'
                currency: USD
                price: 458.87
                createdAt: '2019-08-20T14:15:22Z'
                updatedAt: '2019-08-20T14:15:22Z'
                isDeleted: true
        '400':
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/addonInvalidId'
                  - $ref: '#/components/schemas/missingTenantHeader'
                  - $ref: '#/components/schemas/error400'
        '401':
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error401'
        '404':
          description: Not Found
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/addonNotFound'
        '500':
          description: Internal server error
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error500'
components:
  securitySchemes:
    AuthorizationToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    missingTenantHeader:
      type: object
      description: Tenant header is missing
      properties:
        type:
          description: The error code.
          type: string
          example: TENANT_HEADER_REQUIRED
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: x-fabric-tenant-id header is required
    error400:
      type: object
      description: Bad request error
      properties:
        type:
          description: The error code.
          type: string
          example: BAD_REQUEST
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Bad request
    error401:
      type: object
      description: Unauthorized error
      properties:
        type:
          description: The error code.
          type: string
          example: UNAUTHORIZED
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Invalid credentials
    error500:
      type: object
      description: Internal server error
      properties:
        type:
          description: The error code.
          type: string
          example: INTERNAL_SERVER_ERROR
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Internal server error
    createdAt:
      type: string
      format: date-time
      description: Record's creation time
      example: 2019-08-20T14:15:22.000Z
    updatedAt:
      type: string
      format: date-time
      description: Record's last updated time
      example: 2019-08-20T14:15:22.000Z
    isDeleted:
      type: boolean
      description: 'true: Record is deleted<br>false: Record isn''t deleted'
      example: false
    offsetQuery:
      type: object
      description: Provides pagination data.
      properties:
        size:
          type: integer
          format: int32
          example: 10
          minimum: 1
          maximum: 100
          default: 10
          description: The maximum number of records per page.
        offset:
          type: integer
          format: int32
          example: 10
          minimum: 0
          default: 0
          description: >-
            The number of records to skip before returning records. For example,
            with an offset of 20 and limit of 10, you will get records from 21
            to 30.
        count:
          type: integer
          format: int32
          example: 50
          description: The total number of available records.
    badSizeError:
      type: object
      description: Pagination size error, an invalid value was sent
      properties:
        type:
          description: The error code.
          type: string
          example: REQUEST_VALIDATION
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Size should be a valid number
    badSortingError:
      type: object
      description: Invalid sorting values sent
      properties:
        type:
          description: The error code.
          type: string
          example: REQUEST_VALIDATION
        message:
          description: >-
            An error message corresponding to the `type`. In this case. an
            invalid sorting value was sent.
          type: string
          example: Sorting value must be one of the allowed values
    addon:
      type: object
      description: The details of add on.
      required:
        - id
        - name
        - price
        - isDeleted
        - currency
        - createdAt
        - updatedAt
      properties:
        id:
          description: The ID of the add-on.
          type: integer
          format: int32
          example: 100004
        name:
          description: The name of the add-on.
          type: string
          example: Tablet
        channelId:
          description: The sales channel where the add-on is used for business.
          type: string
          example: '12'
        currency:
          description: The currency type of add-on as defined by ISO-4217.
          type: string
          example: USD
        price:
          description: The price of an add-on.
          type: number
          format: double
          example: 458.87
        createdAt:
          $ref: '#/components/schemas/createdAt'
        updatedAt:
          $ref: '#/components/schemas/updatedAt'
        isDeleted:
          $ref: '#/components/schemas/isDeleted'
    addonRequest:
      type: object
      description: The inputs to create or update an add-on.
      required:
        - name
        - currency
        - price
      properties:
        name:
          description: The name of the add-on.
          type: string
          example: Tablet
        currency:
          description: The currency value for add-on.
          type: string
          example: USD
        price:
          description: The add-on price.
          type: number
          format: double
          example: 458.87
    getAddonResponse:
      $ref: '#/components/schemas/addon'
    getAddonsResponse:
      type: object
      description: A paginated response of add-ons.
      properties:
        query:
          $ref: '#/components/schemas/offsetQuery'
        data:
          description: The list of add-ons.
          type: array
          items:
            $ref: '#/components/schemas/addon'
    createAddonResponse:
      $ref: '#/components/schemas/addon'
    updateAddonResponse:
      $ref: '#/components/schemas/addon'
    deleteAddonResponse:
      $ref: '#/components/schemas/addon'
    createAddonRequest:
      $ref: '#/components/schemas/addonRequest'
    updateAddonRequest:
      $ref: '#/components/schemas/addonRequest'
    addonNameExist:
      type: object
      description: Duplicated add-on name error
      properties:
        type:
          description: The error code.
          type: string
          example: ADDON_NAME_EXISTS
        message:
          description: TAn error message corresponding to the `type`.
          type: string
          example: Add-on name already exists
    addonNotFound:
      type: object
      description: Add-on not found error
      properties:
        type:
          description: The error code.
          type: string
          example: ADDON_NOT_FOUND
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Add-on not found
    addonInvalidId:
      type: object
      description: Invalid add-on ID error
      properties:
        type:
          description: The error code.
          type: string
          example: ADDON_ID_NOT_VALID
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Add-on ID must be a valid integer
    addonCannotBeEmpty:
      type: object
      description: Empty add-on name error
      properties:
        type:
          description: The error code.
          type: string
          example: ADDON_NAME_CANNOT_BE_EMPTY
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Add-on name can't be empty
    priceEqualOrGreaterThanZero:
      type: object
      description: Invalid price error
      properties:
        type:
          description: The error code.
          type: string
          example: PRICE_EQUAL_OR_GREATER_THAN_ZERO
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Price should be equal to or greater than zero
    invalidCurrencyCode:
      type: object
      description: The invalid price error.
      properties:
        type:
          description: The error code.
          type: string
          example: INVALID_CURRENCY_CODE
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Invalid currency code added
  parameters:
    xFabricTenantId:
      in: header
      name: x-fabric-tenant-id
      schema:
        type: string
        minLength: 24
        maxLength: 24
      required: true
      example: 5f328bf0b5f328bf0b5f328b
      description: >-
        A header used by fabric to identify the tenant making the request. You
        must include tenant id in the authentication header for an API request
        to access any of fabric’s endpoints. You can retrieve the tenant id ,
        which is also called account id, from
        [Copilot](/v3/platform/settings/account-details/getting-the-account-id).
        This header is required.
    xFabricChannelId:
      in: header
      name: x-fabric-channel-id
      schema:
        type: string
        example: '12'
      description: >-
        x-fabric-channel-id identifies the sales channel where the API request
        is being made; primarily for multichannel use cases. The channel ids are
        12 corresponding to US and 13 corresponding to Canada. The default
        channel id is 12. This field is required.
    xClientId:
      in: header
      name: x-client-id
      schema:
        type: string
      required: false
      example: copilot
      description: >-
        A unique identifier obtained from
        [Copilot](/v3/platform/settings/api-apps/getting-system-app-credentials)
        for the System app in the fabric ecosystem, essential for OpenID Connect
        authentication flows.
    xFabricRequestId:
      in: header
      name: x-fabric-request-id
      description: A unique request ID.
      required: false
      schema:
        type: string
        example: 263e731c-45c8-11ed-b878-0242ac120002
    queryParameterSize:
      name: size
      in: query
      description: The maximum number of records per page.
      required: false
      schema:
        type: integer
        format: int32
        minimum: 1
        default: 10
        maximum: 100
    queryParameterOffset:
      name: offset
      in: query
      description: >-
        The number of records to skip before returning records. For example,
        with an offset of 20 and limit of 10, you will get records from 21 to
        30.
      required: false
      schema:
        type: integer
        format: int32
        minimum: 0
        example: 0
        default: 0
  headers:
    xFabricRequestIdResponse:
      description: Unique request ID
      schema:
        type: string
        example: 263e731c-45c8-11ed-b878-0242ac120002
