openapi: 3.0.0
info:
  title: Webhooks
  description:
    "fabric **Self Service Webhooks** is a centralized API service that enables
    merchants to subscribe to and manage webhooks using fabric events. With this
    service, you can subscribe to one or more events that are configured to a
    single URL, manage your webhook subscriptions, view event schemas, and send
    test events to your URL. In addition, you can access your events logs to
    gain historical context for analyzing data trends and de-bugging issues. <br
    /> **Note**: The events can also be managed through fabric Copilot UI."
  version: 3.0.0
  x-audience: external-public
  termsOfService: https://fabric.inc/terms-of-use
  contact:
    name: Integrations team
    email: support@fabric.inc
  license:
    name: fabric API License
    url: https://fabric.inc/api-license
externalDocs:
  description: Find out more about Integrations
  url: https://developer.fabric.inc/docs/self-service-events-overview

servers:
  - url: https://api.fabric.inc/v3
    description: Production environment
tags:
  - name: Event
    description: This endpoint is used to get the details of an available event.
  - name: Single Subscription Management
    description:
      These endpoints are used to create and manage a single subscription.
  - name: Bulk Subscription Management
    description:
      These endpoints are used for bulk action, such as creation, update, and
      deletion of subscriptions.
  - name: Event Logs
    description:
      This endpoint gets a summary of events triggered for one or more
      subscriptions.
  - name: Resend
    description: This endpoint is used to resend selected events.
  - name: Replay
    description:
      This endpoint is used to replay events for a specific date range. Replay
      resends all events from a given date range.
  - name: Test
    description:
      This endpoint is used to test whether events are successfully sent to the
      specified `targetUrl`.
paths:
  /events:
    get:
      tags:
        - Event
      summary: Get events
      description:
        With this endpoint, you can get a list of events, such as product
        creation and update events for Product Catalog, order confirmation events for OMS
        and more. <br /> 1. You can request for all events. Alternatively, you
        can specify the query parameters fabric `product` and the event `type`
        to narrow down the search results. <br /> 3. You can also specify the
        query parameters `offset` and `limit` to refine the search results. When
        no query parameters are specified, the system returns up to 10 events.
      operationId: getEvents
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: product
          in: query
          description: fabric product
          required: false
          schema:
            type: string
            default: PIM
            enum: [Product Catalog, Offers, Cart, Checkout]
        - name: type
          in: query
          description: Subscribed event type
          required: false
          schema:
            type: string
            example: pim:product:created
            pattern: "^(products|pim|offers|cart|checkout)$"
        - name: service
          in: query
          description: fabric product service
          required: false
          schema:
            type: string
            default: Product
            enum:
              [
                Product,
                Category & Collection,
                Attribute,
                Price,
                Price List,
                Promotions,
                Coupons,
                Global Exclusion,
                Offers Jobs,
                Checkout,
              ]
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/getEventsResponse"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "404":
          description: Event not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/eventNotFound"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
  /event-subscriptions/batch:
    post:
      tags:
        - Bulk Subscription Management
      summary: Create subscriptions
      description:
        With this endpoint, you can create up to 25 new webhook subscriptions in
        a single request.
      operationId: postBulkSubscriptions
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/bulkCreateSubscriptionRequest"
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/bulkCreateSubscriptionResponse"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "409":
          description: Duplicate subscription name
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/duplicateSubscriptionName"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
  /event-subscriptions:
    post:
      tags:
        - Single Subscription Management
      summary: Create subscription
      description:
        "This endpoint is used to create a new webhook subscription. By
        subscribing to one or more events, you can get product updates on key
        activities such as product creation, product updates, and order
        confirmations to a single URL. <br />**Note**: When the `deliveryType`
        is `WEBHOOK`, which is the default option, the subscribed events are
        delivered real-time to the specified targetUrl through a HTTP webhook."
      operationId: postSubscriptions
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/createSubscriptionRequest"
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/subscriptionResponse"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "409":
          description: Duplicate subscription name
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/duplicateSubscriptionName"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
    get:
      tags:
        - Bulk Subscription Management
      summary: Search and filter subscriptions
      description:
        This endpoint is used to search and filter webhook subscriptions by
        `name`, `targetUrl`, `id`, or `type`. When they're not specified, the
        system returns a paginated response of all subscriptions. Using the
        query parameters `offset`, `limit`, and `sort` you can refine the search
        results. When no query parameters are specified, by default, the system
        returns up to 10 results.
      operationId: searchSubscriptions
      parameters:
        - $ref: "#/components/parameters/offset"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: sort
          in: query
          description:
            "Sort criteria  **Note**: `-` refers to descending and `+` refers to
            ascending order"
          required: false
          schema:
            type: string
            default: -updatedAt
            enum:
              - -updatedAt
              - +updatedAt
              - -createdAt
              - +createdAt
              - -name
              - +name
              - -targetUrl
              - +targetUrl
        - name: name
          in: query
          description: The name of the subscription.
          required: false
          schema:
            type: string
            example: fabricUpdates
        - name: targetUrl
          in: query
          description: The URL to which the event details is being delivered.
          required: false
          schema:
            type: string
            example: https://www.example.com
        - name: id
          in: query
          description: The subscription ID.
          required: false
          schema:
            type: string
            example: 72e60e75-017a-4304-b5ea-e33bfd37b84a
        - name: type
          in: query
          description: A comma-separated list of events.
          required: false
          schema:
            type: string
            example: pim:product:created,offers:price:created
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/getSubscriptionResponse"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
    put:
      tags:
        - Bulk Subscription Management
      summary: Update subscriptions in bulk
      description:
        "With this endpoint, you can update up to 25 webhook subscriptions in a
        single request. You can update details such as `name`, `description`,
        `deliveryType`, `targetUrl`, `authorizationDetails`, and  subscribed
        `events`."
      operationId: bulkPutSubscriptions
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/bulkUpdateSubscriptionRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/bulkUpdateSubscriptionResponse"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
    delete:
      tags:
        - Bulk Subscription Management
      summary: Delete subscriptions in bulk
      description:
        With this endpoint, you can delete up to 25 webhook subscriptions and
        their associated events in a single request. This stops all associated
        events.
      operationId: bulkDeleteSubscriptions
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: ids
          in: query
          description: A comma-separated list of subscription IDs to be deleted.
          required: true
          schema:
            type: string
            example: "72e60e75-017a-4304-b5ea-e33bfd37b84a,e474a2ae-71fe-4507-983b-1007cc3641de"
      responses:
        "204":
          description: No Content
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "404":
          description: Subscription not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/subscriptionNotFound"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
  /event-subscriptions/{id}:
    put:
      tags:
        - Single Subscription Management
      summary: Update subscription
      description:
        "With this endpoint, you can update details of an existing webhook
        subscription, such as `name`, `description`, `deliveryType`,
        `targetUrl`, `authorizationDetails`, and subscribed `events`."
      operationId: putSubscriptions
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: id
          in: path
          description: The UUID of subscription.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/updateSubscriptionRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/subscriptionResponse"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "404":
          description: Subscription not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/subscriptionNotFound"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
    delete:
      tags:
        - Single Subscription Management
      summary: Delete subscription
      description:
        This endpoint is used to delete an existing webhook subscription. This
        stops all associated events.
      operationId: deleteSubscriptions
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: id
          in: path
          description: Subscription UUID
          required: true
          schema:
            type: string
      responses:
        "204":
          description: No Content
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "404":
          description: Subscription not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/subscriptionNotFound"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
    get:
      tags:
        - Single Subscription Management
      summary: Get subscription
      description:
        "This endpoint is used to get the details of a single webhook
        subscription, such as `id`, `name`, `description`, `targetUrl`,
        `authorizationDetails`, `createdAt`, `updatedAt`, and all subscribed
        events."
      operationId: getSubscriptions
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: id
          in: path
          description: The UUID of subscription.
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/getSingleSubscriptionResponse"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "404":
          description: Subscription not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/subscriptionNotFound"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
  /event-logs:
    get:
      tags:
        - Event Logs
      summary: Get event logs
      description:
        "With this endpoint, you can get a summary of events triggered based on
        the given conditions. If logs aren't specified, the system returns a
        paginated response, where you can specify `offset`, `limit`, and `sort`
        to refine the search results. When pagination criteria isn't specified,
        by default, the system returns up to 10 results. You can search for and
        filter event logs by using the following options - `id`, `eventType`,
        `subscriptionId`, `status`, `subscriptionName`, `product`, `version`,
        `retryCount`, `eventId`, `triggeredAt`, and `deliveredAt`. <br />
        **Note**: Logs are only available for the last seven days."
      operationId: getEventLogs
      security:
        - AuthorizationToken: []
      parameters:
        - $ref: "#/components/parameters/offset"
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: sort
          in: query
          description:
            "The criteria to sort data. **Note**: `-` refers to descending and
            `+` refers to ascending order"
          required: false
          schema:
            type: string
            default: -triggeredAt
            enum:
              - -triggeredAt
              - +triggeredAt
              - -deliveredAt
              - +deliveredAt
        - name: id
          in: query
          description: The UUID of the log.
          required: false
          schema:
            type: string
            example: 54b09338-df79-11ed-b5ea-0242ac120002
        - name: subscriptionId
          in: query
          description: The subscription ID.
          required: false
          schema:
            type: string
            example: 72e60e75-017a-4304-b5ea-e33bfd37b84a
        - name: status
          in: query
          description: The HTTP response code for the status.
          required: false
          schema:
            type: number
            example: 201
        - name: subscriptionName
          in: query
          description: The subscriptions name.
          required: false
          schema:
            type: string
            example: fabricUpdates
        - name: product
          in: query
          description: Represent the fabric product or service.
          required: false
          schema:
            type: string
            default: PIM
            enum:
              - PIM
              - Offers
              - Cart
              - Checkout
            example: pim
        - name: eventType
          in: query
          description: The subscriptions event type.
          required: false
          schema:
            type: string
            example: pim:product:created
        - name: eventId
          in: query
          description: The UUID of the event.
          required: false
          schema:
            type: string
            example: 23232dfdfds-121323-122dscdscds
        - name: version
          in: query
          description: The event version.
          required: false
          schema:
            type: string
            example: v1
        - name: retryCount
          in: query
          description: The number of retry.
          required: false
          schema:
            type: number
            example: 2
        - name: startTriggeredAt
          in: query
          description:
            The starting timestamp for the `triggeredAt` filter range, in UTC
            format.
          required: false
          schema:
            type: string
            format: date-time
            example: "2023-03-29T07:08:07.446Z"
        - name: endTriggeredAt
          in: query
          description:
            The ending timestamp for the `triggeredAt` filter range, in UTC
            format.
          required: false
          schema:
            type: string
            format: date-time
            example: "2023-03-30T07:08:07.446Z"
        - name: startDeliveredAt
          in: query
          description:
            The starting timestamp for the `deliveredAt` filter range, in UTC
            format.
          required: false
          schema:
            type: string
            format: date-time
            example: "2023-03-29T07:08:07.446Z"
        - name: endDeliveredAt
          in: query
          description:
            The ending timestamp for the `deliveredAt` filter range, in UTC
            format.
          required: false
          schema:
            type: string
            format: date-time
            example: "2023-03-30T07:08:07.446Z"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/eventLogs"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
  /event-subscriptions/{id}/actions/replay:
    post:
      tags:
        - Replay
      summary: Replay events
      description:
        "By using this endpoint, if there was delivery failure of one or more
        events or you encountered some other issue, you can replay all events
        recorded during that time frame. <br /> **Note**: You can only replay
        events for the last seven days."
      operationId: replayEvents
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: id
          in: path
          description: The UUID of subscription.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/replayEventsRequest"
      responses:
        "202":
          description: Accepted
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "404":
          description: Subscription/Event type  not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/subscriptionNotFound"
                  - $ref: "#/components/schemas/eventNotFound"
        "409":
          description: Conflicting replay
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/conflictingReplay"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
  /event-subscriptions/{id}/actions/resend/batch:
    post:
      tags:
        - Resend
      summary: Resend events
      description:
        "Using this endpoint, if there was delivery failure of one or more
        events or you encountered some other issue, you can resend selected
        events for a given subscription. <br /> **Note**: You can only resend
        events for the last seven days."
      operationId: bulkResendEvent
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: id
          in: path
          description: The UUID of subscription.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/bulkResendEventsRequest"
      responses:
        "202":
          description:
            Accepted (The resent events will be eventually delivered to
            target)
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "404":
          description: Subscription not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/subscriptionNotFound"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
  /event-subscriptions/{id}/actions/test:
    post:
      tags:
        - Test
      summary: Test event
      description:
        This endpoint is used to test whether the events are successfully sent
        to your specified `targetUrl`.
      operationId: testEvents
      parameters:
        - $ref: "#/components/parameters/xFabricTenantId"
        - $ref: "#/components/parameters/xFabricChannelId"
        - $ref: "#/components/parameters/xFabricRequestId"
        - name: id
          in: path
          description: The UUID of subscription.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/testEventRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/testEventResponse"
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
        "400":
          description: Bad request
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/badRequest"
        "401":
          description: Unauthorized
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/notAuthorized"
        "404":
          description: Subscription/Event type  not found
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/subscriptionNotFound"
                  - $ref: "#/components/schemas/eventNotFound"
        "500":
          description: Internal Server Error
          headers:
            x-fabric-request-id:
              $ref: "#/components/headers/xFabricRequestIdResponseHeader"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/internalServerError"
components:
  securitySchemes:
    AuthorizationToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
  parameters:
    limit:
      in: query
      name: limit
      description: The maximum number of records per page.
      schema:
        type: number
        example: 20
        default: 10
      required: false
    offset:
      in: query
      name: offset
      description:
        "The number of records to skip before returning records.<br />For
        example, When offset is 20 and limit's 10, the system returns records
        from 21-30."
      schema:
        type: number
        example: 2
        default: 0
      required: false
    xFabricTenantId:
      name: x-fabric-tenant-id
      in: header
      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.
      required: true
      schema:
        type: string
      example: 5f328bf0b5f328bf0b5f328b
    xFabricChannelId:
      name: x-fabric-channel-id
      in: header
      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.
      required: true
      schema:
        type: string
      example: "12"
    xFabricRequestId:
      name: x-fabric-request-id
      in: header
      description: Unique request ID
      required: false
      schema:
        type: string
      example: 263e731c-45c8-11ed-b878-0242ac120002
  schemas:
    notAuthorized:
      type: object
      description: Unauthorized error
      properties:
        type:
          description: Error type
          type: string
          example: UNAUTHORIZED
        message:
          description: Error description
          type: string
          example: Invalid credentials
    badRequest:
      type: object
      description: The request is invalid or malformed
      properties:
        type:
          description: Error type
          type: string
          example: BAD_REQUEST
        message:
          description: Error description
          type: string
          example: Bad Request
    internalServerError:
      type: object
      description: Internal server error
      properties:
        type:
          description: Error type
          type: string
          example: INTERNAL_SERVER_ERROR
        message:
          description: Error description
          type: string
          example: Internal server error
    subscriptionNotFound:
      type: object
      description: Subscription not found
      properties:
        type:
          description: Error type
          type: string
          example: SUBSCRIPTION_NOT_FOUND
        message:
          description: Error description
          type: string
          example: Subscription not found
    eventNotFound:
      type: object
      description: Event not found
      properties:
        type:
          description: Error type
          type: string
          example: EVENT_NOT_FOUND
        message:
          description: Error description
          type: string
          example: Event pim:product:ordered not found
    duplicateSubscriptionName:
      type: object
      description: Duplicate subscription name
      properties:
        type:
          description: Error type
          type: string
          example: DUPLICATE_SUBSCRIPTION_NAME
        message:
          description: Error description
          type: string
          example: Duplicate subscription name fabricUpdates
    paginatedResultMeta:
      description: Metadata related to pagination
      type: object
      properties:
        offset:
          type: integer
          format: int32
          default: 0
          example: 2
          description:
            "The number of records to skip before returning records.<br />For
            example, When offset is 20 and limit's 10, the system returns
            records from 21-30."
        limit:
          type: integer
          format: int32
          default: 10
          example: 20
          description: The maximum number of records per page.
        count:
          type: integer
          format: int32
          example: 100
          description: The total number of records in the response.
    events:
      type: array
      items:
        type: object
        description: The details of an event.
        properties:
          type:
            type: string
            description: The type of event.
            pattern: "^(products|pim|offers|cart|checkout)$"
            example: pim:product:created
          description:
            type: string
            description: A brief description of the event.
            example: Item created in Prouct Catalog
          product:
            type: string
            description: The event product.
            enum: [Product Catalog, Offers, Cart, Checkout]
            example: PIM
          service:
            type: string
            description: The event service.
            enum:
              [
                Product,
                Category & Collection,
                Attribute,
                Price,
                Price List,
                Promotions,
                Coupons,
                Global Exclusion,
                Offers Jobs,
                Checkout,
              ]
            example: Product
          version:
            type: string
            description: The version of the event.
            example: v1
        required:
          - type
          - product
          - service
          - version
      example:
        - type: pim:product:created
          description: An event is triggered when a product is created.
          product: PIM
          version: v2
        - type: pim:product:updated
          description: An event is triggered when a product is updated.
          product: PIM
          version: v2
        - type: offers:price:created
          description: An event is triggered when a price is created.
          product: Offers
          version: v1
    eventLogs:
      type: object
      description: The logs info.
      properties:
        query:
          $ref: "#/components/schemas/paginatedResultMeta"
        data:
          type: array
          items:
            $ref: "#/components/schemas/eventLog"
    eventLog:
      type: object
      description: The details of a single event log.
      properties:
        id:
          type: string
          description: The UUID of the delivery log.
          example: 54b09338-df79-11ed-b5ea-0242ac120002
        tenantId:
          type: string
          description: Merchant's tenant ID
          example: 614bacaa4a74a70009d69d33
        subscriptionId:
          type: string
          description: The UUID of the subscription.
          example: 72e60e75-017a-4304-b5ea-e33bfd37b84a
        subscriptionName:
          type: string
          description: The subscription name.
          example: fabricUpdates
        type:
          type: string
          description: The type of event.
          enum: [LIVE, TEST]
          example: TEST
        eventId:
          type: string
          description: The UUID of the event log.
          example: 23232dfdfds-121323-122dscdscds
        eventType:
          type: string
          description: The type of event.
          example: offers:price:created
        product:
          type: string
          description: The fabric product or service to which an event belongs.
          example: offers
        version:
          type: string
          description: The version of the event.
          example: v1
        c:
          type: number
          description: The number of retry.
          example: 2
        triggeredAt:
          type: string
          format: date-time
          description: The time at which the event was triggered, in UTC format.
          example: "2023-03-29T07:08:07.446Z"
        deliveredAt:
          type: string
          description: Time at which the event was delivered
          example: "2023-03-29T07:08:08.117Z"
        deliveryStatus:
          type: number
          description: The HTTP status code for the event delivery.
          example: 200
        data:
          $ref: "#/components/schemas/data"
        logs:
          type: array
          description: The details of event logs.
          items:
            $ref: "#/components/schemas/logInfo"
      required:
        - type
        - product
        - version
        - eventRequestId
        - name
        - triggeredAt
        - deliveredAt
        - deliveryStatus
    authorizationDetails:
      type: object
      description: The authorization details.
      properties:
        type:
          type: string
          enum: [API_KEY]
          description:
            Type of authentication mechanism to use for the subscription
          example: API_KEY
        config:
          $ref: "#/components/schemas/config"
      required:
        - type
        - config
    config:
      type: object
      description: The configuration details.
      properties:
        apiKeyHeaderName:
          type: string
          description: API key header name
          example: x-api-key
        apiKeyValue:
          type: string
          description: API key header value
          example: uAtYeyuS9c3UdpJRejF9PA==
      required:
        - apiKeyHeaderName
        - apiKeyValue
    getEventsResponse:
      type: object
      description: The details of events.
      properties:
        data:
          $ref: "#/components/schemas/events"
    createSubscriptionRequest:
      type: object
      description: The request to create subscription.
      properties:
        name:
          type: string
          description: Subscription name
          example: fabricUpdates
        description:
          type: string
          description: Brief description of subscription
          example: Subscription for fabric updates
        deliveryType:
          type: string
          enum: [WEBHOOK]
          description: Delivery mechanism for the subscription
          example: WEBHOOK
        targetUrl:
          type: string
          description: Target URL to which the subscription sends the events
          example: https://www.example.com
        authorizationDetails:
          $ref: "#/components/schemas/authorizationDetails"
        events:
          $ref: "#/components/schemas/events"
      required:
        - name
        - deliveryType
        - targetUrl
        - events
    subscriptionResponse:
      type: object
      description: The details of a single subscription.
      properties:
        id:
          type: string
          description: The UUID of subscription.
          example: 72e60e75-017a-4304-b5ea-e33bfd37b84a
        name:
          type: string
          description: The subscription name.
          example: fabricUpdates
        description:
          type: string
          description: A brief description of the subscription.
          example: Subscription for fabric updates
        targetUrl:
          type: string
          description:
            The target URL to which the subscription sends the events.
          example: https://www.example.com
        deliveryType:
          type: string
          enum: [WEBHOOK]
          description: The type of subscription delivery mechanism.
          example: WEBHOOK
        createdAt:
          type: string
          format: date-time
          description:
            The time at which the subscription was created, in UTC format.
          example: "2022-07-11T15:03:14.642Z"
        updatedAt:
          type: string
          format: date-time
          description:
            The time at which the subscription was last updated, in UTC format.
          example: "2022-07-11T15:03:14.642Z"
        events:
          $ref: "#/components/schemas/events"
      required:
        - id
        - targetUrl
        - events
    getSubscriptionResponse:
      type: object
      description: The subscription details.
      properties:
        query:
          $ref: "#/components/schemas/paginatedResultMeta"
        data:
          type: array
          nullable: true
          items:
            $ref: "#/components/schemas/subscriptionResponse"
    updateSubscriptionRequest:
      type: object
      description: The request to update subscription.
      properties:
        name:
          type: string
          description: The subscription name.
          example: fabricUpdates
        description:
          type: string
          description: A brief description of the subscription.
          example: Subscription for fabric updates
        deliveryType:
          type: string
          enum: [WEBHOOK]
          description: The type of subscription delivery mechanism.
          example: WEBHOOK
        targetUrl:
          type: string
          description:
            The target URL to which the subscription sends the events.
          example: https://www.example2.com
        authorizationDetails:
          $ref: "#/components/schemas/authorizationDetails"
        events:
          $ref: "#/components/schemas/events"
      required:
        - name
        - deliveryType
        - targetUrl
        - events
    getSingleSubscriptionResponse:
      type: object
      description: The details of a single subscription.
      properties:
        id:
          type: string
          description: The UUID of subscription.
          example: 72e60e75-017a-4304-b5ea-e33bfd37b84a
        name:
          type: string
          description: The subscription name.
          example: fabricUpdates
        description:
          type: string
          description: A brief description of subscription.
          example: Subscription for fabric updates
        targetUrl:
          type: string
          description:
            The target URL to which the subscription sends the events.
          example: https://www.example2.com
        authorizationDetails:
          $ref: "#/components/schemas/authorizationDetails"
        createdAt:
          type: string
          format: date-time
          description:
            The time at which the subscription was created, in UTC format.
          example: "2022-07-11T15:03:14.642Z"
        updatedAt:
          type: string
          format: date-time
          description:
            The time at which the subscription was last updated, UTC format.
          example: "2022-07-11T15:03:14.642Z"
        events:
          $ref: "#/components/schemas/events"
      required:
        - id
        - targetUrl
        - events
    bulkCreateSubscriptionRequest:
      type: object
      description: The request to create multiple subscriptions.
      properties:
        data:
          type: array
          minItems: 1
          maxItems: 25
          items:
            $ref: "#/components/schemas/createSubscriptionRequest"
      required:
        - data
    bulkCreateSubscriptionResponse:
      type: object
      description: The response of creating a new subscriptions.
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/subscriptionResponse"
    bulkUpdateSubscriptionRequest:
      type: object
      description: The request to update multiple subscriptions.
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/updateSubscriptionRequest"
      required:
        - data
    bulkUpdateSubscriptionResponse:
      type: object
      description: The response to update multiple subscriptions.
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/subscriptionResponse"
    logInfo:
      type: object
      description: The details of a log.
      properties:
        id:
          type: string
          description: The UUID of the log.
          example: 54b09338-df79-11ed-b5ea-0242ac120002
        createdAt:
          type: string
          format: date-time
          description: The time at which the log was created, in UTC format.
          example: "2022-07-11T15:03:14.642Z"
        status:
          type: number
          description: The HTTP status code for the response.
          example: 201
        message:
          type: string
          description: The log message
          example: Success
    data:
      $ref: "#/components/schemas/logData"
    logData:
      type: object
      description: The log details.
      properties:
        specversion:
          type: string
          description: The version of the event.
          example: v1
        type:
          type: string
          description: The type of event.
          example: offers:price:created
        tenantid:
          type: string
          description: Merchant's tenant ID
          example: 614bacaa4a74a70009d69d33
        events:
          $ref: "#/components/schemas/logEventMetadata"
    logEventMetadata:
      type: array
      items:
        type: object
        description: Additional information related to event log.
        properties:
          id:
            type: string
            description: The UUID of the event.
            example: 0076064a-695e-43ac-b004-17802ed186ac
          time:
            type: string
            format: date-time
            description:
              The time at which the event was triggered, in UTC format.
            example: "2023-03-29T07:08:07.446Z"
          source:
            type: string
            description: The source of the event.
            example: offers:business-layer
          subject:
            type: string
            description: The subject of the event.
            example: add-example
          data:
            $ref: "#/components/schemas/logEventData"
    logEventData:
      type: object
      description: The event log data.
      properties:
        eventName:
          type: string
          description: The event name
          example: PRICE
        status:
          type: string
          description: The event status
          example: CREATED
        itemId:
          type: integer
          description: The item ID.
          example: 1684471584
        itemSku:
          type: string
          description: The Stock Keeping Unit (SKU) of the item.
          example: DSSDS
        priceListId:
          type: integer
          description: The Price List ID.
          example: 100001
        callbackUrls:
          type: array
          items:
            type: string
            description: Callback URLs
            example: https://stg02.copilot.fabric.inc/api-offers/price/DSSDS/priceList/100001?type=itemSku
    replayEventsRequest:
      type: object
      description: The request to replay events.
      properties:
        startTime:
          type: string
          format: date-time
          description: The starting time for replaying events, in UTC format.
          example: "2023-07-07T06:33:57Z"
        endTime:
          type: string
          format: date-time
          description: The ending time for replaying events, in UTC format.
          example: "2023-07-11T06:33:57Z"
      required:
        - startTime
        - endTime
    conflictingReplay:
      type: object
      description: The details of conflicting replay
      properties:
        code:
          type: string
          description: Error type
          example: REPLAY_IN_PROGRESS
        message:
          type: string
          description: Error description
          example:
            Replay already in progress for 72e60e75-017a-4304-b5ea-e33bfd37b84a
      required:
        - code
        - message
    bulkResendEventsRequest:
      type: object
      description: The request to resent multiple events.
      properties:
        data:
          type: array
          items:
            type: string
            description: Event UUID
            format: uuid
            example: 30975c62-a578-4ecc-b39f-c3cb121779bf
      required:
        - data
    testEventRequest:
      type: object
      description: The request to test events.
      properties:
        type:
          type: string
          description: Event type
          example: "pim:product:created"
        domain:
          type: string
          description: Event domain
          example: pim
        version:
          type: string
          description: Event version
          example: v1
      required:
        - type
        - domain
        - version
    testEventResponse:
      $ref: "#/components/schemas/eventLog"
  headers:
    xFabricRequestIdResponseHeader:
      description: Unique request ID
      required: false
      schema:
        type: string
      example: 263e731c-45c8-11ed-b878-0242ac120002
