openapi: 3.0.0
x-mint:
  mcp:
    enabled: true
info:
  title: Offers - Imports
  description: >-
    fabric Import endpoints let you import a CSV file to a secured Amazon S3 URL
    for bulk updating specific data and for retrieving information about the
    imports.
  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:
  /offers-imports/actions/generate-upload-url:
    post:
      tags:
        - Imports
      summary: Generate URL to import a CSV file
      description: >-
        Use this endpoint to create a secured S3 URL to import a CSV file,
        allowing for bulk data updates from the information within the file. For
        example, if the data in the file is price type, then only the price
        related data will be updated. Note that an error will be shown if the
        type of data included in the file doesn't match with the data type
        mentioned in the request body. You must upload only one single file,
        specifically in the CSV format, to the generated URL.
      operationId: generateUploadUrl
      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/generateUploadUrlRequest'
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/generateUploadUrlResponse'
        '400':
          description: Bad Request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $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'
  /offers-imports/actions/generate-error-file-download-url:
    post:
      tags:
        - Imports
      summary: Retrieve the download URL for an error file
      description: >-
        Use this endpoint to retrieve an AWS S3 URL to access the error data of
        a previously imported file. The URL is valid for five minutes. Make a
        GET request with this URL to download the error data  in a CSV format.
      operationId: generateErrorDownloadUrl
      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/generateErrorDownloadUrlRequest'
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/generateErrorDownloadUrlResponse'
        '400':
          description: Bad Request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $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'
  /offers-imports-jobs:
    get:
      tags:
        - Imports
      summary: Get import jobs
      description: Get a paginated list of import jobs.
      operationId: getImportJobs
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: '#/components/parameters/xFabricTenantId'
        - $ref: '#/components/parameters/xFabricChannelId'
        - $ref: '#/components/parameters/xClientId'
        - $ref: '#/components/parameters/xFabricRequestId'
        - $ref: '#/components/parameters/queryParameterSizeImportJobs'
        - $ref: '#/components/parameters/queryParameterOffset'
        - in: query
          name: type
          required: true
          description: The import job type for which you want to get import details.
          schema:
            type: string
            enum:
              - PRICE
              - PRICE_RANGE
              - PRICELIST
              - PROMOTION
              - COUPON
              - COUPON_CODE
              - REDEMPTION
            example: PRICE
        - in: query
          name: startAt
          required: false
          description: Filter records by when the import process began.
          schema:
            type: string
            format: date-time
            example: '2023-04-18T17:57:07.260Z'
        - in: query
          name: endAt
          required: false
          description: Filter records by when the import process ended.
          schema:
            type: string
            format: date-time
            example: '2023-04-18T17:57:07.260Z'
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getImportJobsResponse'
        '400':
          description: Bad Request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $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'
  /offers-imports-jobs/{jobId}:
    get:
      tags:
        - Imports
      summary: Get import job by ID
      description: Get details of a specific import job by job ID.
      operationId: getImportJob
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: '#/components/parameters/xFabricTenantId'
        - $ref: '#/components/parameters/xFabricChannelId'
        - $ref: '#/components/parameters/xClientId'
        - $ref: '#/components/parameters/xFabricRequestId'
        - in: path
          name: jobId
          required: true
          description: Import job ID that's created when the import process starts
          schema:
            type: string
            example: 606469bdf4fb7900085f1761
      responses:
        '200':
          description: OK
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getImportJobResponse'
        '400':
          description: Bad Request
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                anyOf:
                  - $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: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: '#/components/headers/xFabricRequestIdResponse'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/importJobNotFound'
        '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
    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.
    generateUploadUrlRequest:
      type: object
      description: >-
        A sample request containing file details be uploaded to the generated
        URL.
      required:
        - fileName
        - type
      properties:
        fileName:
          type: string
          example: file1.csv
          description: The name of the file to be uploaded.
        type:
          type: string
          enum:
            - PRICE
            - PROMOTION
            - COUPON
            - COUPON_CODE
            - REDEMPTION
            - PRICE_RANGE
            - PRICELIST
          description: >-
            Type of data in the file. The data provided in the file must match
            with type for successful processing of the file.
          example: PRICE
        additionalAttributes:
          type: object
          description: A placeholder for additional information.
          properties:
            key:
              type: string
              description: The attribute name.
              example: coupon_id
            value:
              type: string
              description: The value corresponding to the attribute `key`.
              example: '1234'
    generateUploadUrlResponse:
      type: object
      description: >-
        A sample response containing a generated URL and the file name to be
        processed.
      required:
        - url
        - fileName
      properties:
        url:
          type: string
          description: >-
            The AWS S3 URL used to download the data, in a CSV format, of a
            previous import. The URL is valid for five minutes.
          example: >-
            https://example.s3.amazonaws.com/pricelist/123/dev02/123-priceList1.csv?X-Amz-Algorithm...x-amz-meta-stage=dev02
        fileName:
          type: string
          description: The name of the error file.
          example: prices/1646680518524-file1.csv
    generateErrorDownloadUrlRequest:
      type: object
      description: >-
        A sample request to retrieve an AWS S3 URL used to download the error
        file of a previous import.
      required:
        - fileName
      properties:
        fileName:
          type: string
          example: price/error-file1.csv
          description: >-
            The name of the error file to be downloaded. You can get the
            `errorFileName` from the [Get import jobs
            endpoint](https://developer.fabric.inc/v3/offers/api-reference/offers/imports/get-import-jobs).
    generateErrorDownloadUrlResponse:
      type: object
      description: A sample response with an AWS S3 URL used to download the error file.
      required:
        - url
        - fileName
      properties:
        url:
          type: string
          description: >-
            The AWS S3 URL used to download an error file of a previous import,
            in a CSV format. The URL is valid for 5 minutes.
          example: >-
            https://example.s3.amazonaws.com/pricelist/123/dev02/123-priceList1.csv?X-Amz-Algorithm...x-amz-meta-stage=dev02
        fileName:
          type: string
          description: The name of the file.
          example: prices/1646680518524-file1.csv
    importJob:
      type: object
      description: The details of the import job.
      required:
        - id
        - startAt
        - fileName
        - type
        - details
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          description: A 24-character system-generated ID of the import job.
          example: 643eda1bd4c15c0008b4fb67
        startAt:
          type: string
          description: The start time of the import job, in UTC format.
          example: 2023-04-18T17:57:07.260Z
        endAt:
          type: string
          description: The end time of the import job, in UTC format.
          example: 2023-04-18T17:57:54.445Z
          nullable: true
        fileName:
          type: string
          description: The name of the uploaded file
          example: coupon/5f689caa4216e7000750d1ef/stg02/1681840413797-coupon.csv
        errorFileName:
          type: string
          description: Error file name if any error
          example: coupon/5f689caa4216e7000750d1ef/stg02/1681840413797-error-coupon.csv
          nullable: true
        type:
          type: string
          description: The import job type for which details are retrieved.
          enum:
            - PRICE
            - PRICE_RANGE
            - PRICELIST
            - PROMOTION
            - COUPON
            - COUPON_CODE
            - REDEMPTION
          example: PRICE
        details:
          type: array
          description: Represents the steps involved in the import process.
          items:
            type: object
            description: The details of a specific step.
            properties:
              timestamp:
                description: The time when the step was executed.
                type: string
                example: '2023-04-18T17:57:07.260Z'
              isSuccess:
                description: >-
                  `true` indicates the step was successful and `false` indicates
                  errors in the step.
                type: boolean
                example: true
              message:
                description: A description for the step.
                type: string
                example: >-
                  Import coupon codes job started: Tue Apr 18 2023 17:57:47
                  GMT+0000 (Coordinated Universal Time)
        errors:
          type: array
          description: The errors details.
          items:
            type: object
            description: Error description
            properties:
              message:
                type: string
                description: Error description
                example: Price should always be >= 0.00
              count:
                type: integer
                format: int32
                description: Error occurrences
                example: 8
        totalJob:
          type: integer
          format: int32
          description: >-
            Indicates the total number of processes required to upload the
            entire file. For internal processing only.
          example: 10
        completedJob:
          type: integer
          format: int32
          description: >-
            Indicates the total number of completed processes for uploading the
            entire file. For internal processing only.
          example: 5
        totalRowsCount:
          type: integer
          format: int32
          description: >-
            Indicates the total number of rows in the CSV file. For internal
            processing only.
          example: 100
        insertedRowsCount:
          type: integer
          format: int32
          description: >-
            Indicates the total number of rows in the CSV file that were
            processed successfully. For internal processing only.
          example: 60
        failedRowsCount:
          type: integer
          format: int32
          description: >-
            Indicates the total number of rows in the CSV file that failed to
            process. For internal processing only.
          example: 40
        createdAt:
          $ref: '#/components/schemas/createdAt'
        updatedAt:
          $ref: '#/components/schemas/updatedAt'
    importJobQuery:
      allOf:
        - $ref: '#/components/schemas/offsetQuery'
        - type: object
          properties:
            size:
              maximum: 10
    getImportJobResponse:
      $ref: '#/components/schemas/importJob'
    getImportJobsResponse:
      description: Import job list details
      type: object
      properties:
        query:
          $ref: '#/components/schemas/importJobQuery'
        data:
          type: array
          items:
            $ref: '#/components/schemas/importJob'
    importJobNotFound:
      type: object
      description: Import job not found.
      properties:
        type:
          description: The error code.
          type: string
          example: IMPORT_JOB_NOT_FOUND
        message:
          description: An error message corresponding to the `type`.
          type: string
          example: Import job not found.
  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: The sales channel ID.
    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
    queryParameterSizeImportJobs:
      name: size
      in: query
      description: The number of records to be returned on a single page.
      schema:
        type: integer
        format: int32
        minimum: 1
        default: 10
        maximum: 10
    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
