{
  "openapi": "3.0.1",
  "info": {
    "title": "Webhook APIs",
    "description": "These APIs provides Webhook Managements like creating Webhook, modify, get and delete webhooks.",
    "version": "0.1"
  },
  "servers": [
    {
      "url": "https://api-sandbox.sendpro360.pitneybowes.com/webhook",
      "description": "Sandbox Server for Webhook API's"
    },
    {
      "url": "https://api.sendpro360.pitneybowes.com/webhook",
      "description": "Production Server for Webhook API's (uses live data)"
    }
  ],
  "tags": [
    {
      "name": "Webhook"
    }
  ],
  "paths": {
    "/api/v1/events": {
      "get": {
        "tags": [
          "Webhook"
        ],
        "summary": "Get Applicable Event list for Webhook configuration",
        "description": "This operation gets the events details",
        "operationId": "getEvents",
        "responses": {
          "200": {
            "description": "Successfully retrieved all applicable events on which webhook can be configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/webhookConfig": {
      "post": {
        "tags": [
          "Webhook"
        ],
        "summary": "Create Webhook configuration",
        "description": "Webhook provides the mechanism to push tracking events as they occur. With help of this user would be able to receive events as they are generated and is received to the end user. This operation creates a webhook configuration. It needs details of events for which webhook tracking is required also the URL with its authorization details to which the tracking events be pushed.",
        "operationId": "postWebhook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Webhook created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "Webhook"
        ],
        "summary": "Get All Webhooks",
        "description": "This operation gets all the configured webhook and its details.",
        "operationId": "getAllWebhook",
        "responses": {
          "200": {
            "description": "all Webhooks get successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponseAll"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/webhookConfig/{webHookConfigID}": {
      "put": {
        "tags": [
          "Webhook"
        ],
        "summary": "Update Webhook",
        "description": "This operation updates the webhook details",
        "operationId": "putWebhook",
        "parameters": [
          {
            "name": "webHookConfigID",
            "description": "This is unique id of webhook which will get from create webhook config api.",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Webhook update is successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "Webhook"
        ],
        "summary": "Get Webhook details by Id",
        "description": "This operation gets the webhook details",
        "operationId": "getWebhook",
        "parameters": [
          {
            "name": "webHookConfigID",
            "description": "This is unique id of webhook which will get from create webhook config api.",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook details retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Webhook"
        ],
        "summary": "Delete Webhook",
        "description": "This operation delete the webhook",
        "operationId": "deleteWebhook",
        "parameters": [
          {
            "name": "webHookConfigID",
            "description": "This is unique id of webhook which will get from create webhook config api.",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook deleted successful"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "responses": {
      "UnauthorizedError": {
        "description": "The request could not be authorized.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "CreateWebhookRequest": {
        "type": "object",
        "required": [
          "type",
          "name",
          "events",
          "url",
          "authParams"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "It indicates the desired name of the webhook <br /> `Max length = 50`.",
            "example": "webhook1"
          },
          "type": {
            "type": "string",
            "description": "It indicates the type of webhook. Currently it takes `tracking`  and `locker`as value. These event codes are supported for the defined type: \n| type     | supported events |\n|----------|----------------------------------------------------------------------------------|\n| locker   | reservation, cancelreservation, deposit, pickup, stalemailpickup                  |\n| tracking | Manifest, Acceptance, InTransit, DeliveryAttempt, OutForDelivery, Delivered,  Exception, ReturnToSender, ReadyForPickup, PickupMissed, PickedUp |\n",
            "enum": [
              "locker",
              "tracking"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Indicates the list of events for which notifications will be received.\n\n| type     | supported events                                                                 |\n|----------|----------------------------------------------------------------------------------|\n| locker   | reservation, cancelreservation, deposit, pickup, stalemailpickup                  |\n| tracking | Manifest, Acceptance, InTransit, DeliveryAttempt, OutForDelivery, Delivered, \n            Exception, ReturnToSender, ReadyForPickup, PickupMissed, PickedUp |\n"
            },
            "example": [
              "Manifest",
              "InTransit",
              "Delivered"
            ]
          },
          "url": {
            "type": "string",
            "description": "It indicates the customer url to which events should be sent.",
            "example": "https://webhook.com"
          },
          "timeOut": {
            "type": "number",
            "description": "It indicates the timeout value before system waits response from the customer url, here timeout indicates in seconds.",
            "example": 5
          },
          "status": {
            "type": "string",
            "description": "It indicates the status of the webhook. By default it takes `active`. To mark it inactive use `in-active`",
            "example": "active"
          },
          "authParams": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/custom"
              },
              {
                "$ref": "#/components/schemas/basic"
              },
              {
                "$ref": "#/components/schemas/OAuth"
              }
            ]
          }
        }
      },
      "custom": {
        "type": "object",
        "properties": {
          "authType": {
            "type": "string",
            "description": "It indicates the authoriation mechanism required to authenticate the customer url. here in this case authType is `custom`.",
            "example": "custom"
          },
          "apiKey": {
            "type": "string",
            "description": "It indicates api key for authentication",
            "example": "JsuG7jk"
          },
          "headerName": {
            "type": "string",
            "description": "It indicates header name for authentication",
            "example": "webhook1"
          }
        }
      },
      "basic": {
        "type": "object",
        "properties": {
          "authType": {
            "type": "string",
            "description": "It indicates the authoriation mechanism required to authenticate the customer url. here in this case authType is `basic`.",
            "example": "basic"
          },
          "clientID": {
            "type": "string",
            "description": "It indicates client id for authentication",
            "example": "JsuG7jk1fdjfh"
          },
          "secret": {
            "type": "string",
            "description": "It indicates secret key for authentication",
            "example": "nejhdsugduwinduwbduhsidn"
          }
        }
      },
      "OAuth": {
        "type": "object",
        "properties": {
          "authType": {
            "type": "string",
            "description": "It indicates the authoriation mechanism required to authenticate the customer url. here in this case authType is `basic`.",
            "example": "oauth"
          },
          "clientID": {
            "type": "string",
            "description": "It indicates client id for authentication",
            "example": "JsuG7jk1fdjfh"
          },
          "secret": {
            "type": "string",
            "description": "It indicates secret key for authentication",
            "example": "nejhdsugduwinduwbduhsidn"
          },
          "tokenUrl": {
            "type": "string",
            "description": "The URL for retrieving a token.",
            "example": "https//webhook1"
          }
        }
      },
      "WebhookResponse": {
        "type": "object",
        "properties": {
          "webHookConfigID": {
            "type": "string",
            "description": "It is unique id system generates for the created webhook",
            "example": "1Q86AvxyqmA"
          },
          "name": {
            "type": "string",
            "description": "name of the webhook",
            "example": "webhook1"
          },
          "type": {
            "type": "string",
            "description": "It indicates the type of webhook. Currently it takes `tracking`  and `locker`as value. These event codes are supported for the defined type: \n| type     | supported events |\n|----------|----------------------------------------------------------------------------------|\n| locker   | reservation, cancelreservation, deposit, pickup, stalemailpickup                  |\n| tracking | Manifest, Acceptance, InTransit, DeliveryAttempt, OutForDelivery, Delivered,  Exception, ReturnToSender, ReadyForPickup, PickupMissed, PickedUp |\n",
            "enum": [
              "locker",
              "tracking"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Indicates the list of events for which notifications will be received.\n\n| type     | supported Events |\n|----------|----------------------------------------------------------------------------------|\n| locker   | reservation, cancelreservation, deposit, pickup, stalemailpickup                  |\n| tracking | Manifest, Acceptance, InTransit, DeliveryAttempt, OutForDelivery, Delivered, \n            Exception, ReturnToSender, ReadyForPickup, PickupMissed, PickedUp |\n"
            },
            "example": [
              "Manifest",
              "InTransit",
              "Delivered"
            ]
          },
          "url": {
            "type": "string",
            "description": "URL to which events be pushed to",
            "example": "https://webhook.com"
          },
          "timeOut": {
            "type": "number",
            "description": "It shows the timeout value untill which it waits to receive response from the customer url, here timeout indicates in seconds.",
            "example": 5
          },
          "status": {
            "type": "string",
            "description": "status of the webhook",
            "example": "active"
          },
          "authParams": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/custom"
              },
              {
                "$ref": "#/components/schemas/basic"
              },
              {
                "$ref": "#/components/schemas/OAuth"
              }
            ]
          }
        }
      },
      "WebhookResponseAll": {
        "type": "object",
        "properties": {
          "webHookConfigID": {
            "type": "string",
            "description": "webhook config id of the webhook",
            "example": "1Q86AvxyqmA"
          },
          "name": {
            "type": "string",
            "description": "name of the webhook",
            "example": "webhook1"
          },
          "type": {
            "type": "string",
            "description": "It indicates the type of webhook. Currently it takes `tracking`  and `locker`as value. These event codes are supported for the defined type: \n| type     | supported events |\n|----------|----------------------------------------------------------------------------------|\n| locker   | reservation, cancelreservation, deposit, pickup, stalemailpickup                  |\n| tracking | Manifest, Acceptance, InTransit, DeliveryAttempt, OutForDelivery, Delivered,  Exception, ReturnToSender, ReadyForPickup, PickupMissed, PickedUp |\n",
            "enum": [
              "locker",
              "tracking"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Indicates the list of events for which notifications will be received.\n\n| type     | supported events                                                                 |\n|----------|----------------------------------------------------------------------------------|\n| locker   | reservation, cancelreservation, deposit, pickup, stalemailpickup                  |\n| tracking | Manifest, Acceptance, InTransit, DeliveryAttempt, OutForDelivery, Delivered, \n            Exception, ReturnToSender, ReadyForPickup, PickupMissed, PickedUp |\n"
            },
            "example": [
              "Manifest",
              "InTransit",
              "Delivered"
            ]
          },
          "url": {
            "type": "string",
            "description": "url of the webhook",
            "example": "https://webhook.com"
          },
          "timeOut": {
            "type": "number",
            "description": "timeout seconds",
            "example": 5
          },
          "status": {
            "type": "string",
            "description": "status of the webhook",
            "example": "active"
          },
          "authParams": {
            "type": "object",
            "properties": {
              "authType": {
                "type": "string",
                "description": "auth type of webhook authentication",
                "example": "custom"
              },
              "apiKey": {
                "type": "string",
                "description": "api key for webhook authentication",
                "example": "jsfjafhjfk"
              },
              "headerName": {
                "type": "string",
                "description": "header name if webhook has any header name",
                "example": "webhook1"
              }
            }
          }
        }
      },
      "EventResponse": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "eventId": {
              "type": "string",
              "description": "event id of an event"
            },
            "name": {
              "type": "string",
              "description": "name of an event"
            }
          }
        },
        "example": [
          {
            "eventId": "Manifest",
            "name": "Manifest"
          },
          {
            "eventId": "Acceptance",
            "name": "Acceptance"
          },
          {
            "eventId": "InTransit",
            "name": "InTransit"
          },
          {
            "eventId": "DeliveryAttempt",
            "name": "DeliveryAttempt"
          }
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        },
        "required": [
          "message",
          "code"
        ]
      },
      "Empty": {
        "title": "Empty Schema",
        "type": "object"
      }
    },
    "securitySchemes": {
      "basicAuth": {
        "type": "http",
        "scheme": "basic"
      },
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}