{
  "openapi": "3.0.0",
  "info": {
    "title": "Workato Event Streams API",
    "description": "Workato Event Streams Public API",
    "version": "1.7.1",
    "contact": {
      "name": "Workato Inc.",
      "url": "https://workato.com",
      "email": "info@workato.com"
    }
  },
  "servers": [
    {
      "url": "https://event-streams.workato.com/api/v1"
    }
  ],
  "tags": [
    {
      "name": "Topics"
    }
  ],
  "paths": {
    "/topics/{topic_id}/consume": {
      "post": {
        "tags": [
          "Topics"
        ],
        "summary": "Get messages.",
        "description": "Get messages from offset.",
        "parameters": [
          {
            "name": "AUTHORIZATION",
            "schema": {
              "type": "string"
            },
            "in": "header",
            "description": "Bearer {token}",
            "required": true,
            "deprecated": false,
            "explode": true
          },
          {
            "name": "topic_id",
            "schema": {
              "type": "integer",
              "format": "uint32"
            },
            "in": "path",
            "description": "topic_id - The identifier of topic",
            "required": true,
            "deprecated": false,
            "explode": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json; charset=utf-8": {
              "schema": {
                "$ref": "#/components/schemas/ConsumeMessageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Returns when batch is ready",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ReadMessagesResponseOk"
                }
              }
            }
          },
          "400": {
            "description": "Returns when bad request (e.g. schema mismatch)",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Bad authorization supplied",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient rights",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Returns when the topic or the user not found",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Returns when rate limit is exceeded",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "headers": {
              "RETRY-AFTER": {
                "required": true,
                "deprecated": false,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Returns when internal error occurs",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorResponse"
                }
              }
            }
          }
        },
        "operationId": "consume_messages"
      }
    },
    "/topics/{topic_id}/publish": {
      "post": {
        "tags": [
          "Topics"
        ],
        "summary": "Publish messages.",
        "description": "Publish messages to the topic.",
        "parameters": [
          {
            "name": "AUTHORIZATION",
            "schema": {
              "type": "string"
            },
            "in": "header",
            "description": "Bearer {token}",
            "required": true,
            "deprecated": false,
            "explode": true
          },
          {
            "name": "topic_id",
            "schema": {
              "type": "integer",
              "format": "uint32"
            },
            "in": "path",
            "description": "_topic_id_ - The identifier of the topic",
            "required": true,
            "deprecated": false,
            "explode": true
          }
        ],
        "requestBody": {
          "description": "_message_ - Message",
          "content": {
            "application/json; charset=utf-8": {
              "schema": {
                "type": "object",
                "additionalProperties": {},
                "example": {}
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Returns when the message is successfully published.",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/MessageCreatedResponse"
                }
              }
            }
          },
          "400": {
            "description": "Returns when request is invalid",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Bad authorization supplied",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient rights",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Returns when the topic or the user not found",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Returns when payload size is too large",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/SizeLimitErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Returns when rate limit is exceeded",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "headers": {
              "RETRY-AFTER": {
                "required": true,
                "deprecated": false,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Returns when internal error occurs",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorResponse"
                }
              }
            }
          }
        },
        "operationId": "publish_message"
      }
    },
    "/batch/topics/{topic_id}/publish": {
      "post": {
        "tags": [
          "Topics"
        ],
        "summary": "Publish messages batch to the topic.",
        "description": "This API call returns an array of published `message_id``s. This array can be shorter\nthan the number of provided messages. It means that not all messages have been saved\nto the storage, and the rest of messages need to be sent again.",
        "parameters": [
          {
            "name": "AUTHORIZATION",
            "schema": {
              "type": "string"
            },
            "in": "header",
            "description": "Bearer {token}",
            "required": true,
            "deprecated": false,
            "explode": true
          },
          {
            "name": "topic_id",
            "schema": {
              "type": "integer",
              "format": "uint32"
            },
            "in": "path",
            "description": "_topic_id_ - The identifier of the topic",
            "required": true,
            "deprecated": false,
            "explode": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json; charset=utf-8": {
              "schema": {
                "$ref": "#/components/schemas/CreateMessagesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Returns when some messages successfully published.",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/MessagesBatchCreatedResponse"
                }
              }
            }
          },
          "400": {
            "description": "Returns when request is invalid",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Bad authorization supplied",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient rights",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Returns when the topic or the user not found",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Returns when payload size is too large",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/SizeLimitErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Returns when rate limit is exceeded",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "headers": {
              "RETRY-AFTER": {
                "required": true,
                "deprecated": false,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Returns when internal error occurs",
            "content": {
              "application/json; charset=utf-8": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorResponse"
                }
              }
            }
          }
        },
        "operationId": "publish_messages_batch"
      }
    }
  },
  "components": {
    "schemas": {
      "ConsumeMessageRequest": {
        "type": "object",
        "title": "ConsumeMessageRequest",
        "properties": {
          "after_message_id": {
            "type": "string",
            "description": "Read messages after this `message_id`"
          },
          "since_time": {
            "type": "string",
            "format": "date-time",
            "description": "Read messages from this time"
          },
          "batch_size": {
            "type": "integer",
            "format": "uint32",
            "description": "Batch size. Default: configured limit. Maximum: configured limit"
          },
          "timeout_secs": {
            "type": "integer",
            "format": "uint64",
            "description": "Timeout (seconds). Maximum: 60"
          }
        }
      },
      "CreateMessagesRequest": {
        "type": "object",
        "title": "CreateMessagesRequest",
        "required": [
          "payloads"
        ],
        "properties": {
          "payloads": {
            "type": "array",
            "description": "Messages Payload",
            "items": {
              "type": "object",
              "additionalProperties": {},
              "example": {}
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "title": "Error",
        "required": [
          "details"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message (i.e human readable message)"
          },
          "details": {
            "description": "Error details",
            "allOf": [
              {
                "$ref": "#/components/schemas/ErrorDetails"
              },
              {
                "description": "Error details"
              }
            ]
          }
        }
      },
      "ErrorDetails": {
        "type": "object",
        "title": "ErrorDetails",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Internal code of error to identify the reason"
          }
        },
        "additionalProperties": {}
      },
      "ErrorResponse": {
        "type": "object",
        "title": "ErrorResponse",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "GeneralServerError": {
        "type": "object",
        "title": "GeneralServerError"
      },
      "InternalServerError": {
        "type": "object",
        "title": "InternalServerError",
        "required": [
          "details"
        ],
        "properties": {
          "details": {
            "$ref": "#/components/schemas/InternalServerErrorDetails"
          }
        }
      },
      "InternalServerErrorDetails": {
        "type": "object",
        "oneOf": [
          {
            "$ref": "#/components/schemas/InternalServerErrorDetails_RequestProcessingTimeout"
          },
          {
            "$ref": "#/components/schemas/InternalServerErrorDetails_GeneralServerError"
          }
        ],
        "discriminator": {
          "propertyName": "code",
          "mapping": {
            "TIMEOUT": "#/components/schemas/InternalServerErrorDetails_RequestProcessingTimeout",
            "INTERNAL_SERVER_ERROR": "#/components/schemas/InternalServerErrorDetails_GeneralServerError"
          }
        }
      },
      "InternalServerErrorDetails_GeneralServerError": {
        "allOf": [
          {
            "type": "object",
            "required": [
              "code"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "INTERNAL_SERVER_ERROR"
                ],
                "example": "INTERNAL_SERVER_ERROR"
              }
            }
          },
          {
            "$ref": "#/components/schemas/GeneralServerError"
          }
        ]
      },
      "InternalServerErrorDetails_RequestProcessingTimeout": {
        "allOf": [
          {
            "type": "object",
            "required": [
              "code"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "TIMEOUT"
                ],
                "example": "TIMEOUT"
              }
            }
          },
          {
            "$ref": "#/components/schemas/RequestProcessingTimeout"
          }
        ]
      },
      "InternalServerErrorResponse": {
        "type": "object",
        "title": "InternalServerErrorResponse",
        "description": "Typed representation of Internal Server Error response for Workato's web API",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/InternalServerError"
          }
        }
      },
      "MessageCreatedResponse": {
        "type": "object",
        "title": "MessageCreatedResponse",
        "required": [
          "message_id"
        ],
        "properties": {
          "message_id": {
            "type": "string",
            "description": "Message identifier",
            "example": "0"
          }
        }
      },
      "MessagePublishResult": {
        "type": "object",
        "anyOf": [
          {
            "$ref": "#/components/schemas/MessagePublishResult_MessagePublishResultMessageId"
          },
          {
            "$ref": "#/components/schemas/MessagePublishResult_MessagePublishResultError"
          }
        ],
        "discriminator": {
          "propertyName": "result",
          "mapping": {
            "success": "#/components/schemas/MessagePublishResult_MessagePublishResultMessageId",
            "failure": "#/components/schemas/MessagePublishResult_MessagePublishResultError"
          }
        }
      },
      "MessagePublishResultError": {
        "type": "object",
        "title": "MessagePublishResultError",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Error"
          }
        }
      },
      "MessagePublishResultMessageId": {
        "type": "object",
        "title": "MessagePublishResultMessageId",
        "required": [
          "message_id"
        ],
        "properties": {
          "message_id": {
            "type": "string",
            "description": "Message identifier",
            "example": "0"
          }
        }
      },
      "MessagePublishResult_MessagePublishResultError": {
        "allOf": [
          {
            "type": "object",
            "required": [
              "result"
            ],
            "properties": {
              "result": {
                "type": "string",
                "enum": [
                  "failure"
                ],
                "example": "failure"
              }
            }
          },
          {
            "$ref": "#/components/schemas/MessagePublishResultError"
          }
        ]
      },
      "MessagePublishResult_MessagePublishResultMessageId": {
        "allOf": [
          {
            "type": "object",
            "required": [
              "result"
            ],
            "properties": {
              "result": {
                "type": "string",
                "enum": [
                  "success"
                ],
                "example": "success"
              }
            }
          },
          {
            "$ref": "#/components/schemas/MessagePublishResultMessageId"
          }
        ]
      },
      "MessageResponse": {
        "type": "object",
        "title": "MessageResponse",
        "required": [
          "message_id",
          "payload",
          "time"
        ],
        "properties": {
          "message_id": {
            "type": "string",
            "description": "Message Identifier",
            "readOnly": true,
            "example": "0"
          },
          "payload": {
            "type": "object",
            "description": "Message Payload",
            "additionalProperties": {},
            "readOnly": true,
            "example": {}
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "Time when the message was created (RFC 3339)",
            "readOnly": true
          }
        }
      },
      "MessagesBatchCreatedResponse": {
        "type": "object",
        "title": "MessagesBatchCreatedResponse",
        "required": [
          "message_ids",
          "is_partial_error"
        ],
        "properties": {
          "message_ids": {
            "type": "object",
            "description": "Message identifiers (keyed by message number in the request).\n\nCan be an error if the message was not published successfully.\nNumber of `message_ids` may be less then the number of requested\nmessages. It means that fewer messages were successfully published.",
            "additionalProperties": {
              "$ref": "#/components/schemas/MessagePublishResult"
            }
          },
          "is_partial_error": {
            "type": "boolean",
            "description": "`true` if some messages were not saved"
          }
        },
        "example": {
          "is_partial_error": true,
          "message_ids": {
            "0": {
              "message_id": "A12",
              "result": "success"
            },
            "1": {
              "message_id": "A13",
              "result": "success"
            },
            "2": {
              "error": "error message",
              "result": "failure"
            }
          }
        }
      },
      "ReadMessagesResponseOk": {
        "type": "object",
        "title": "ReadMessagesResponseOk",
        "required": [
          "messages",
          "has_more"
        ],
        "properties": {
          "messages": {
            "type": "array",
            "description": "batch of messages",
            "items": {
              "$ref": "#/components/schemas/MessageResponse"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether there are more messages to retrieve"
          }
        }
      },
      "RequestProcessingTimeout": {
        "type": "object",
        "title": "RequestProcessingTimeout"
      },
      "SizeLimitErrorResponse": {
        "type": "object",
        "title": "SizeLimitErrorResponse",
        "required": [
          "error",
          "max_size",
          "current_size"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Error message"
          },
          "details": {
            "type": "string",
            "description": "Error details"
          },
          "max_size": {
            "type": "integer",
            "format": "uint64",
            "description": "Max allowed size"
          },
          "current_size": {
            "type": "integer",
            "format": "uint64",
            "description": "Current size"
          }
        }
      }
    }
  }
}