swagger: '2.0'
info:
  version: '1.0'
  title: "Webhook Relay"
  description: |
    # Introduction
    Fast, secure tunnels to your internal networks. [Webhook Relay](https://webhookrelay.com) allows you to expose your localhost 
    or any other server in private network to the public internet without configuring port forwarding 
    or firewalls. 
    This API is documented in **Swagger format**. Webhook Relay allows to dynamically configure your tunnels and webhook forwarding and request/response 
    transformation using serverless functions.
        
    # Available authentication methods
    Webhook Relay offers three forms of authentication:
      - **Basic Auth** - only available for non-OAuth accounts. Use your username and password.
      - **API Key** - available for all accounts, token pairs can be generated [here](https://my.webhookrelay.com/tokens)
      - **JWT** - mainly used by the [admin dashboard](https://my.webhookrelay.com) with a 'Authorization Bearer: token' 
    
    You can find Swagger and OpenAPI spec files here: [https://github.com/webhookrelay/swagger-webhookrelay](https://github.com/webhookrelay/swagger-webhookrelay).

  termsOfService: "https://webhookrelay.com/tos/"
  contact:
    email: "support@webhookrelay.com"
externalDocs:
  description: Find out more in the official documentation.
  url: 'https://webhookrelay.com/docs'
host: my.webhookrelay.com
basePath: /
schemes:
- "https"
consumes:
- application/json
produces:
- application/json
tags:
  - name: Tokens
    description: Token key & secret pairs are used to authenticate your API calls or for agents to subscribe to webhook forwarding or open tunnels.
  - name: Buckets
    description: Input and output grouping. Bucket allows to have multiple endpoints for the same destination or multiple destinations for fan-out style webhook forwarding.
  - name: Outputs
    description: Outputs are destinations, where your webhooks will be forwarded. Public destinations do not require agents to be running. Internal outputs will not work without an agent.
  - name: Inputs
    description: "Inputs are your public endpoints. Each input serves as an inbox that you can supply to your webhooks producer (ie: Github, Docker, IFTTT)"
  - name: Logs
    description: "Webhook logs hold the status of received and forwarded webhooks. You can use this API group to resend webhooks to one or more destinations"
  - name: Functions
    description: |
      Webhook Relay Functions provide an easy way to extract values from webhooks and transform HTTP 
      requests before passing them to their final destination. Function can be reused by any number 
      of Inputs and/or Outputs. Since user doesn’t have to run a server, this type of function service 
      is also known as FaaS (Function as a Service) or Serverless. 

      Read more about functions here: https://webhookrelay.com/docs/webhooks/functions/manipulating-json.

      Basic function examples can be found here: https://webhookrelay.com/docs/webhooks/functions/modify-request.
  - name: Tunnels
    description: |
      Tunnels allow remote access to internal web services such as local Wordpress, Jekyll or Hexo. Recommended `crypto` options are `flexible` or `tls-pass-through`.  
        
x-tagGroups:
  - name: Authentication
    tags:
      - Tokens
  - name: Webhook Forwarding
    tags:
      - Buckets
      - Outputs
      - Inputs
      - Logs
      - Functions
  - name: Tunneling
    tags:
      - Tunnels
paths:
  /v1/tunnels:
    x-summary: List and create tunnels
    get:
      tags:
        - "Tunnels"
      summary: List All Tunnels
      responses:
        200:
          description: Successful Response
          schema:
            type: array
            items:
              $ref: '#/definitions/Tunnel'
          examples:
            application/json:
              - id: 'b3237483-e96e-4f3a-905c-0d9603d66c1f'
                created_at: 1534409264
                updated_at: 1534409264
                name: 'tunnel-x'
                destination: 'http://localhost:4000'
                host: 'tunnelx.webrelay.io'
    post:
      tags:
        - "Tunnels"
      description: >-
        You may create your own tunnel using this action. It takes a JSON
        object containing a tunnel request with a specified destination. Paid plans
        have an option to specify either encryption, subdomain or full domain.
      summary: Create a New Tunnel
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Tunnel'
      responses:
        201:
          description: ''
          schema:
            $ref: '#/definitions/Tunnel'
          examples:
            description: "Create a tunnel with a custom subdomain"
            application/json:
                id: b3237483-e96e-4f3a-905c-0d9603d66c1f
                created_at: 1534409264
                updated_at: 1534409264
                name: 'tunnel-x'
                destination: 'http://localhost:4000'
                host: 'tunnelx.webrelay.io'
        400:
          description: "Invalid tunnel request supplied"
  /v1/tunnels/{tunnelID}:
    x-summary: Get, update and delete tunnels
    parameters:
      - name: "tunnelID"
        in: "path"
        description: "ID of tunnel to return"
        required: true
        type: "string"
    get:
      tags:
        - "Tunnels"
      summary: Get Tunnel Details
      responses:
        200:
          description: Successful Response
          schema:
             $ref: "#/definitions/Tunnel"
          examples:
            application/json:
              created_at: 1534409264
              updated_at: 1534409264
              id: b3237483-e96e-4f3a-905c-0d9603d66c1f
              destination: http://localhost:8090
              name: tunnel
              group: ''
              addr: ''
              host: tunnelx.webrelay.io
              mode: active
              protocol: http
              account_id: bd7e1dfc-54c8-408c-a885-7498bf1d8522
              description: ''
              features: 
              auth:
                created_at: 1534409264
                updated_at: 1534409264
                id: eb3fbc49-0713-48b1-8971-a7c4a9c64dfb
                type: none
              agent_id: ''
              ingress_rules: 
              crypto: 'off'
        404:
          description: Tunnel not found
    put:
      tags:
        - "Tunnels"
      summary: Update Tunnel Details
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Tunnel'
      responses:
        200:
          description: Successful Response
          schema:
             $ref: "#/definitions/Tunnel"
          examples:
            application/json:
              created_at: 1534409264
              updated_at: 1534409264
              id: b3237483-e96e-4f3a-905c-0d9603d66c1f
              destination: http://localhost:8090
              name: tunnel
              group: ''
              addr: ''
              host: tunnelx.webrelay.io
              mode: active
              protocol: http
              account_id: bd7e1dfc-54c8-408c-a885-7498bf1d8522
              description: ''
              features: 
              auth:
                created_at: 1534409264
                updated_at: 1534409264
                id: eb3fbc49-0713-48b1-8971-a7c4a9c64dfb
                type: none
              agent_id: ''
              ingress_rules: 
              crypto: 'off'
        404:
          description: Tunnel not found
        400:
          description: Bad request (check response message)
    delete:
      tags:
        - "Tunnels"
      summary: Delete Tunnel
      responses:
        200:
          description: Successful Response          
        404:
          description: Tunnel not found        
  # Token configuration
  /v1/tokens:
    x-summary: List and create tunnels
    get:
      tags:
        - "Tokens"
      summary: List All Authentication Tokens
      responses:
        200:
          description: Successful Response
          schema:
            type: array
            items:
              $ref: '#/definitions/Token'
          examples:
            application/json:
              - created_at: 1535232797
                updated_at: 1540394529
                last_login: 3 days ago
                id: 0a8dd8b4-aaaa-rrrr-dddd-ccc860e3005a
                description: linux cli
                scopes:
                  buckets: []
                  tunnels: []
                active: true
                api_access: enabled

          
    post:
      tags:
        - "Tokens"
      summary: Create a New Authentication Token
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Token'
      responses:
        201:
          description: 'Create a new token'
          schema:
            $ref: '#/definitions/TokenCreateResponse'
          examples:
            application/json:                          
              key: cc58c9ea-5fa7-466e-91dc-5c08d0b1127c
              secret: very-secret
        400:
          description: ''
  /v1/tokens/{tokenID}: 
    x-summary: Update and delete tokens
    parameters:
      - name: "tokenID"
        in: "path"
        description: "ID of token"
        required: true
        type: "string"
    put:
      tags:
        - "Tokens"
      summary: Update Token Details
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Token'
      responses:
        200:
          description: Successful Response
          schema:
             $ref: "#/definitions/Token"
          examples:
            application/json:
              application/json:                
              created_at: 1535365683
              updated_at: 1536161359              
              id: cc58c9ea-5fa7-466e-91dc-5c08d0b1127c
              description: ''
              scopes:
                buckets: []
                tunnels:
                - foo
                - bar
                - faa                
              active: true
              api_access: "enabled"
        404:
          description: Tunnel not found
        400:
          description: Bad request (check response message)
    delete:
      tags:
        - "Tokens"
      summary: Delete Token
      responses:
        200:
          description: Successful Response          
        404:
          description: Token not found
  # Bucket configuration
  /v1/buckets:
    x-summary: List and create buckets
    get:
      tags:
        - "Buckets"
      summary: List All Buckets
      responses:
        200:
          description: Successful Response
          schema:
            type: array
            items:
              $ref: '#/definitions/Bucket'
          examples:
            examples:
              application/json:
                - created_at: 1496610194
                  updated_at: 1532192772
                  id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
                  name: webhook-demo
                  description: auto-created input for http://localhost:8090/webhook
                  suspended: false
                  account_id: bd7e1dfc-54c8-408c-a885-7498bf1d8522
                  auth:
                    created_at: -62135596800
                    updated_at: -62135596800
                    id: ''
                    type: none
                  inputs:
                  - created_at: 1496610195
                    updated_at: 1496610195
                    id: 5e722a5e-f3d9-4eec-9e9f-79f1158e4b10
                    name: ingress for http://localhost:8090/webhook
                    bucket_id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
                    description: auto-created input for http://localhost:8090/webhook
                    created_by: ''
                  outputs:
                  - created_at: 1496610196
                    updated_at: 1496610196
                    id: 3ec1899c-7069-4f55-88c6-5d8f5da4fa30
                    name: http://localhost:8090/webhook
                    bucket_id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
                    destination: http://localhost:8090/webhook
                    internal: true
                    description: auto-created output for http://localhost:8090/webhook
                    created_by: ''
    post:
      tags:
        - "Buckets"
      description: >-
        You may create your own bucket using this action. It takes a JSON
        object containing a bucket request. Once bucket is created, it gets 
        assigned a default input to accept webhooks but you will still have to 
        create a new output to give it a destination.
      summary: Create a New Bucket
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/BucketRequest'
      responses:
        201:
          description: ''
          schema:
            $ref: '#/definitions/Bucket'          
        400:
          description: "Invalid bucket request supplied"
  
  /v1/buckets/{bucketID}:
    x-summary: Get and delete buckets
    parameters:
      - name: "bucketID"
        in: "path"
        description: "ID of a bucket to return"
        required: true
        type: "string"
    put:
      tags:
        - "Buckets"
      description: >-
        Update bucket.
      summary: Update Bucket
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Bucket'
      responses:
        200:
          description: 'Bucket updated'
          schema:
            $ref: '#/definitions/Bucket'
        400:
          description: "Invalid bucket update request supplied"
        404:
          description: Bucket not found
    get:
      tags:
        - "Buckets"
      summary: Get Bucket Details
      responses:
        200:
          description: Successful Response
          schema:
             $ref: "#/definitions/Bucket"
          examples:
            application/json:
              created_at: 1496610194
              updated_at: 1532192772
              id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
              name: webhook-demo
              description: auto-created input for http://localhost:8090/webhook
              suspended: false
              account_id: bd7e1dfc-54c8-408c-a885-7498bf1d8522
              auth:
                created_at: -62135596800
                updated_at: -62135596800
                id: ''
                type: none
              inputs:
              - created_at: 1496610195
                updated_at: 1496610195
                id: 5e722a5e-f3d9-4eec-9e9f-79f1158e4b10
                name: ingress for http://localhost:8090/webhook
                bucket_id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
                description: auto-created input for http://localhost:8090/webhook
                created_by: ''
              outputs:
              - created_at: 1496610196
                updated_at: 1496610196
                id: 3ec1899c-7069-4f55-88c6-5d8f5da4fa30
                name: http://localhost:8090/webhook
                bucket_id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
                destination: http://localhost:8090/webhook
                internal: true
                description: auto-created output for http://localhost:8090/webhook
                created_by: ''

        404:
          description: Bucket not found
    delete:
      tags:
        - "Buckets"
      summary: Delete Bucket
      responses:
        200:
          description: Successful Response          
        404:
          description: Bucket not found   

  /v1/buckets/{bucketID}/inputs:
    x-summary: Manage bucket inputs
    parameters:
      - name: "bucketID"
        in: "path"
        description: "ID of a bucket to create input in"
        required: true
        type: "string"
    post:
      tags:
        - "Inputs"
      description: >-
        Create one or more inputs for the bucket to get unique public endpoints.
      summary: Create a New Input
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Input'
      responses:
        201:
          description: ''
          schema:
            $ref: '#/definitions/Input'          
        400:
          description: "Invalid input request supplied"
  /v1/buckets/{bucketID}/inputs/{inputID}:
    x-summary: Manage bucket inputs
    parameters:
      - name: "bucketID"
        in: "path"
        description: "ID of a bucket to create input in"
        required: true
        type: "string"
      - name: "inputID"
        in: "path"
        description: "ID of an input to delete"
        required: true
        type: "string"
    put:
      tags:
        - "Inputs"
      description: >-
        Update input endpoint response code, body or headers.
      summary: Update Input
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Input'
      responses:
        200:
          description: 'Input updated'
          schema:
            $ref: '#/definitions/Input'          
        400:
          description: "Invalid input request supplied"
    delete:
      tags:
        - "Inputs"
      description: >-
        Delete input. Once input is deleted, you will not be able to recreate a new input with the same ID.
      summary: Delete Input      
      responses:
        200:
          description: ''
        404:
          description: "Input or Bucket not found"
  # Outputs
  /v1/buckets/{bucketID}/outputs:
    x-summary: Manage bucket outputs
    parameters:
      - name: "bucketID"
        in: "path"
        description: "ID of a bucket to create output in"
        required: true
        type: "string"
    post:
      tags:
        - "Outputs"
      description: >-
        Create one or more outputs for the bucket to start forwarding webhooks to those destinations.
      summary: Create a New Output
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Output'
      responses:
        201:
          description: ''
          schema:
            $ref: '#/definitions/Output'          
        400:
          description: "Invalid output request supplied"
  /v1/buckets/{bucketID}/outputs/{outputID}:
    x-summary: Manage bucket outputs
    parameters:
      - name: "bucketID"
        in: "path"
        description: "ID of a bucket to create input in"
        required: true
        type: "string"
      - name: "outputID"
        in: "path"
        description: "ID of an output to manage"
        required: true
        type: "string"
    put:
      tags:
        - "Outputs"
      description: >-
        Update output destination or make it public/internal.
      summary: Update Output
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Output'
      responses:
        200:
          description: 'Output updated'
          schema:
            $ref: '#/definitions/Output'          
        400:
          description: "Invalid output request supplied"
    delete:
      tags:
        - "Outputs"
      summary: Delete Output      
      responses:
        200:
          description: ''
        404:
          description: "Output or Bucket not found"  
  # ------------------------   functions  -------------------------
  /v1/functions:
    x-summary: List and create functions
    get:
      tags:
        - "Functions"
      summary: List All Functions
      responses:
        200:
          description: Successful Response
          schema:
            type: array
            items:
              $ref: '#/definitions/Function'
          examples:
            examples:
              application/json:
                - created: 1496610194
                  updated: 1532192772
                  id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
                  name: lightspeedhq_to_webshipper
                  driver: "lua"
                  payload_size: 500814
                  account_id: bd7e1dfc-54c8-408c-a885-7498bf1d8522                  
    post:
      tags:
        - "Functions"
      description: >-
        You may create your own functions using this action. It takes a JSON
        object containing a function request. Once function is created, you can 
        assign it based on its ID to bucket's input and/or output.
      summary: Create a New Function
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/FunctionRequest'
      responses:
        201:
          description: ''
          schema:
            $ref: '#/definitions/Function'          
        400:
          description: "Invalid function request supplied"
  
  /v1/functions/{functionID}:
    x-summary: Get and delete functions
    parameters:
      - name: "functionID"
        in: "path"
        description: "ID of a function to return"
        required: true
        type: "string"
    put:
      tags:
        - "Functions"
      description: >-
        Update function.
      summary: Update Function
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/FunctionRequest'
      responses:
        200:
          description: 'Function updated'
          schema:
            $ref: '#/definitions/Function'
        400:
          description: "Invalid function update request supplied"
        404:
          description: Function not found
    get:
      tags:
        - "Functions"
      summary: Get Function Details
      responses:
        200:
          description: Successful Response
          schema:
             $ref: "#/definitions/Function"
          examples:
            application/json:
              - created: 1496610194
                updated: 1532192772
                id: 339ed2e3-70cf-4a81-8db8-e95a9251155d
                name: lightspeedhq_to_webshipper
                driver: "lua"
                payload: "<base64 encoded function body>"
                payload_size: 500814
                account_id: bd7e1dfc-54c8-408c-a885-7498bf1d8522

        404:
          description: Function not found
    delete:
      tags:
        - "Functions"
      summary: Delete Function
      responses:
        200:
          description: Successful Response          
        404:
          description: Function not found   
  # ---------------------------   logs  ---------------------------
  /v1/logs:
    get:
      tags:
        - Logs
      summary: List logs
      parameters:
      - in: query
        name: from
        type: string               
        description: "YYYY-MM-DD date from when the logs should be returned, for example '2020-01-01'"
      - in: query
        name: to
        type: string               
        description: "YYYY-MM-DD last day till when the logs should be returned, for example '2020-01-02' (includes the last day)"
      - in: query
        name: bucket
        type: string               
        description: "Optional bucket ID for filtering logs"
      - in: query
        name: limit
        type: integer
        description: "Limit of the logs to return"
      - in: query
        name: offset
        type: integer
        description: "Offset of the logs when querying"
      - in: query
        name: status
        type: string
        enum: [status, failed, stalled, received, rejected]
        description: "Webhook log status"
      responses:
        200:
          description: Successful Response
          schema:
            $ref: '#/definitions/LogsResponse'
  /v1/logs/{logID}/action:
    post:
      tags:
        - Logs
      description: You may resend log to one or more destinations
      summary: Resend log
      parameters:
        - name: "logID"
          in: "path"
          required: true
          description: "ID of a log"
          type: "string"       
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/LogAction'
      responses:
        200:
          description: ""
          schema:
            $ref: '#/definitions/Response'
        400:
          description: Invalid request
  # Domain reservation
  /v1/domains:
    get:
      tags:
        - Domains
      summary: List domain reservations      
      responses:
        200:
          description: Successful Response
          schema:
            $ref: '#/definitions/Domain'
    post:
      tags:
        - Domains
      description: Reserve a domain      
      parameters:    
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/Domain'
      responses:
        201:
          description: ""
          schema:
            $ref: '#/definitions/Response'
        400:
          description: Invalid request
        412:
          description: Domain already taken
        451:
          description: Your subscription doesn't include domain reservations
        500:
          description: Internal server error
  /v1/domains/{domainID}:
    x-summary: Get and delete buckets
    parameters:
      - name: "domainID"
        in: "path"
        description: "ID of a domain to delete"
        required: true
        type: "string"  
    delete:
      tags:
        - "Domains"
      summary: Delete a domain reservation
      responses:
        200:
          description: Successful Response          
        404:
          description: Domain reservation not found  
        412:
          description: Can't delete domain reservation, it's in use by a tunnel or an input with a custom domain
# -----------------------------------------------------------------
#
#                          DEFINITIONS
#
#------------------------------------------------------------------
definitions:
  # --------------------------- tunnels ---------------------------
  Tunnel:
    title: Tunnel
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      destination:
        type: string
      name:
        type: string
      region:
        type: string
        enum:
          - ""
          - us-west
          - eu
          - au
        description: "Tunnel region"
        example: "au"
      group:
        type: string
        description: Groups allow agents to subscribe to one or more tunnels
      host:
        type: string
      protocol:
        type: string
      description:
        type: string
      auth:
        type: object
        $ref: '#/definitions/TunnelAuth'
      crypto:
        enum:
          - "off"
          - flexible
          - full
          - full-strict
          - tls-pass-through
        type: string
        description: Tunnel encryption type
        example: flexible
    example:
      created_at: 1534409264
      updated_at: 1534409264
      id: b3237483-e96e-4f3a-905c-0d9603d66c1f
      destination: http://localhost:8090
      name: tunnel
      group: ''
      addr: ''
      host: tunnelx.webrelay.io
      protocol: http
      account_id: bd7e1dfc-54c8-408c-a885-7498bf1d8522
      description: ''
      features: 
      auth:
        created_at: 1534409264
        updated_at: 1534409264
        id: eb3fbc49-0713-48b1-8971-a7c4a9c64dfb
        type: none
      agent_id: ''
      ingress_rules: 
      crypto: 'off'

  TunnelAuth:
    title: Tunnel Authentication
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      type:
        type: string
      username:
        type: string
      password:
        type: string
      token:
        type: string
  # --------------------------- tokens ---------------------------
  Token:
    title: Token
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      last_login:
        type: string
        readOnly: true
      api_access:
        type: string
        enum:
          - disabled
          - enabled
        description: "Enable/disable API access. If disabled, it can only be used to open tunnel connections or forward webhooks but not change any existing configuration"
        example: "enabled"
      description:
        type: string
      scopes:
        type: object
        $ref: '#/definitions/TokenScopes'

  TokenCreateResponse:
     title: Token Create Response
     type: object
     properties:
      key:
        type: string
        description: "Token key, this is an alias to token ID"
      secret:
        type: string
        description: "This is the only time secret is revealed as it is already encrypted by the system"
  TokenScopes:
    title: TokenScopes
    type: object
    properties:
      tunnels:
        type: array
        items:
          type: string
      buckets:
        type: array
        items:
          type: string
  # --------------------------- buckets ---------------------------
  HeaderItem:
    title: Header values
    type: "array" 
    items:
      type: string
  Headers:
    title: Headers for request/response
    type: object
    # map[string][]string    
    additionalProperties: {
      $ref: '#/definitions/HeaderItem'
    }
    description: A hashmap of header keys and a list of values for each string, Go equivalent map[string][]string 
    example:
      Content-Type: 
        - JSON
      Foo:
        - Bar
  BucketRequest:
    title: Bucket create request
    type: object
    properties:
      name:
        type: string        
      description:
        type: string
  Bucket:
    title: Bucket
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      name:
        type: string
      description:
        type: string
      suspended:
        type: boolean
        readOnly: true
        description: "Indicates that webhooks will not be received due to quota limits"
      stream:
        type: boolean        
        description: "Enable/disabled streaming to WebSocket clients from this bucket"
      ephemeral:
        type: boolean        
        description: "If ephemeral is enabled, Webhook Relay will not persist request body, headers or response details"
      auth:
        type: object
        $ref: '#/definitions/BucketAuth'         
      inputs:
        type: "array"
        readOnly: true       
        items:
          $ref: "#/definitions/Input"
      outputs:
        type: "array"
        readOnly: true    
        items:
          $ref: "#/definitions/Output"

  BucketAuth:
    title: BucketAuth
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      type:
        type: string
      username:
        type: string
      password:
        type: string
      token:
        type: string      

  Input:
    title: Input
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      name:
        type: string
      function_id:
        type: string
        description: ID of the function that will be executed for this input
      headers:
        type: object        
        $ref: "#/definitions/Headers"
      status_code:
        type: integer
        description: Response status code to return when this input receives a webhook
      body:
        type: string
        description: Response body to return when this input receives a webhook
      response_from_output:
        type: string
        description: Output ID to specify a single output for response or set it to 'anyOutput' to return response from any output. Output should respond within 10 seconds 
      custom_domain:
        type: string
        description: Specify any custom domain from your Reserved Domains, such as example.hooks.webhookrelay.com or hooks.example.com (if used with your own top level domain name, create a CNAME pointing at hooks.webhookrelay.com) 
      path_prefix:
        type: string
        description: When used with custom domains, path_prefix can host multiple input endpoints on a single domain, such as hooks.example.com/github -> Jenkins CI, hooks.example.com/gitlab -> Spinnaker
      description:
        type: string  
  AndRule:
    title: And Rule
    type: array
    items:
      $ref: '#/definitions/Rules'
  OrRule:
    title: Or Rule
    type: array
    items:
      $ref: '#/definitions/Rules'
  NotRule:
    title: Not Rule
    type: array
    items:
      $ref: '#/definitions/Rules'
  MatchRule:
    title: Match Rule
    type: object
    properties:
      parameter:
        type: object
        $ref: '#/definitions/RuleParameter'
      type:
        type: string
        enum:
          - "value"
          - "contains"
          - "does-not-contain"
          - "regex"
          - "payload-hash-sha1"
          - "payload-hash-sha256"
      value:
        type: string
      substring:
        type: string
      regex:
        type: string
      secret:
        type: string
  Rules:
    title: Rules
    type: object
    properties:
      and:
        type: object
        $ref: "#/definitions/AndRule"
      or:
        type: object
        $ref: "#/definitions/OrRule"
      not:
        type: object
        $ref: "#/definitions/NotRule"
      match:
        type: object
        $ref: "#/definitions/MatchRule"
  RuleParameter:
    title: RuleParameter
    type: object
    properties:
      name: 
        type: string
      source:
        type: string
        enum:
          - "header"
          - "payload"
          - "query"
  Output:
    title: Output
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      bucket_id:
        type: string
        readOnly: true
      name:
        type: string
      disabled:
        type: boolean
        description: Allows to disable specific output destination without deleting the output itself.
      internal:
        type: boolean
        description: When internal output receives webhook, it forwards it to any connected agent (relay CLI, Docker agent or WebSocket connection)
      tls_verification:
        type: boolean
        description: Enforce TLS verification where possible (internal and public destinations)
      destination:
        type: string
        description: "Destination, where to forward the webhook, such as 'http://localhost:4000'" 
      headers:
        type: object
        description: Headers to override (for example Host)  
        $ref: "#/definitions/Headers"
      rules:
        type: object
        description: Request matching rules, documentation can be found here https://webhookrelay.com/docs/webhooks/public/public-destination
        $ref: "#/definitions/Rules"
      timeout:
        type: integer
        description: "Timeout in seconds, value between 0 and 180"
      description:
        type: string
      function_id:
        type: string
        description: ID of the function that will be executed for this output
  LogAction:
    title: Webhook Log Action
    type: object
    properties:
      action:
        type: string
        description: "Log action, for example 'resend'"
      output:
        type: string
        description: "Optional, only set to an output ID if you want to resend this log to the specific output instead of all bucket outputs"
  Response:
    title: Action response
    type: object
    properties:
      id:
        type: string
        description: "ID of the object"
      status:
        type: string
        description: "Status of the action"
  LogsResponse:
    title: Logs API response
    type: object
    properties:
      data:
        type: array
        items:
          $ref: '#/definitions/Log'
      total:
        type: integer
      limit:
        type: integer
      offset:
        type: integer
  Log:
    title: Webhook Log
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created_at:
        type: integer
        readOnly: true
      updated_at:
        type: integer
        readOnly: true
      bucket_id:
        type: string
        readOnly: true
      input_id:
        type: string
        readOnly: true
      output_id:
        type: string
        readOnly: true        
      internal:
        type: boolean
        description: When internal output receives webhook, it forwards it to any
          connected agent (relay CLI, Docker agent or WebSocket connection)
      # Response related fields
      status_code:
        type: integer
      response_body:
        type: string
      response_headers:
        $ref: "#/definitions/Headers"
      status:
        type: string
        description: Request status, example values 'preparing', 'sent', 'failed', 'stalled', 'received', 'rejected'
      retries:
        type: integer
        description: Retries taken so far
      # Request details
      headers:
        $ref: "#/definitions/Headers"
      raw_query:
        type: string
        description: raw query for example request to http://example.com?foo=bar is foo=bar
      method:
        type: string
      body:
        type: string
      ephemeral:
        type: boolean
        description: This field is inherited from the bucket, if set - request/response body will not be set
  FunctionRequest:
    title: Create/update function request
    type: object
    properties:
      name:
        type: string        
      payload:
        type: string
        description: base64 encoded function payload
      driver:
        type: string
        description: Driver name (Lua, WASI)
  Function:
    title: Function
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created:
        type: integer
        readOnly: true
      updated:
        type: integer
        readOnly: true
      name:
        type: string        
      payload:
        type: string
        description: base64 encoded function body
      payload_size:
        type: integer
        readOnly: true
      compression: 
        type: string
        readOnly: true
      metadata:
        type: object
        additionalProperties:
          type: string
  Domain:
    title: Reserved Domain
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created:
        type: integer
        readOnly: true
      updated:
        type: integer
        readOnly: true
      domain:
        type: string
        description: Name of the domain to reserve, for example joe.hooks.webhookrelay.com, hooks.example.com, tunnel.mydomain.com, etc.
  IntegrationConfiguration:
    title: Integration Configuration
    type: object
    properties:
      id:
        type: string
        readOnly: true
      created:
        type: integer
        readOnly: true
      updated:
        type: integer
        readOnly: true
      buckets:
        type: array
        items:
          $ref: '#/definitions/Bucket'
      disabled:
        type: boolean
        description: Disable/enable notification configuration. Consistently failing configurations will be disabled
      events:
        type: array
        items:
          type: string
          enum: [forwarding.function.error, forwarding.delivery.error]
        description: "Event types, currently supported are: 'forwarding.function.error' for failed functions and 'forwarding.delivery.error' for failed webhook delivery."
      plugin:
        type: string
        enum: [slack, webhook]
        description: "Plugin to use"
      status:
        type: string
        description: Plugin status
        readOnly: true
      message:
        type: string
        description: Status description
      description:
        type: string
        description: Free form description field