{
  "asyncapi" : "3.0.0",
  "channels" : {
    "subscriberUrl" : {
      "address" : null,
      "description" : "The https URL of a subscription. Horizon sends a POST request with the event as body.",
      "messages" : {
        "recordApprovalDecided" : {
          "$ref" : "#/components/messages/recordApprovalDecided"
        },
        "recordChanged" : {
          "$ref" : "#/components/messages/recordChanged"
        },
        "recordCommented" : {
          "$ref" : "#/components/messages/recordCommented"
        },
        "recordCreated" : {
          "$ref" : "#/components/messages/recordCreated"
        },
        "recordDeactivated" : {
          "$ref" : "#/components/messages/recordDeactivated"
        },
        "recordStateChanged" : {
          "$ref" : "#/components/messages/recordStateChanged"
        }
      }
    }
  },
  "components" : {
    "messageTraits" : {
      "Delivery" : {
        "headers" : {
          "properties" : {
            "Horizon-Delivery" : {
              "description" : "The event id, the same as `id` in the body.",
              "type" : "string"
            },
            "Horizon-Event" : {
              "description" : "The event type, the same as `type` in the body.",
              "enum" : [ "record.created", "record.changed", "record.stateChanged", "record.commented", "record.deactivated", "record.approvalDecided" ],
              "type" : "string"
            },
            "Horizon-Signature" : {
              "description" : "`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<body>\">`.",
              "pattern" : "^t=[0-9]+,v1=[0-9a-f]{64}$",
              "type" : "string"
            }
          },
          "required" : [ "Horizon-Event", "Horizon-Delivery", "Horizon-Signature" ],
          "type" : "object"
        }
      }
    },
    "messages" : {
      "recordApprovalDecided" : {
        "name" : "record.approvalDecided",
        "payload" : {
          "$ref" : "#/components/schemas/Event"
        },
        "summary" : "An approval on a record was granted or rejected.",
        "traits" : [ {
          "$ref" : "#/components/messageTraits/Delivery"
        } ]
      },
      "recordChanged" : {
        "name" : "record.changed",
        "payload" : {
          "$ref" : "#/components/schemas/Event"
        },
        "summary" : "Fields of a record were changed; `changedFields` names them.",
        "traits" : [ {
          "$ref" : "#/components/messageTraits/Delivery"
        } ]
      },
      "recordCommented" : {
        "name" : "record.commented",
        "payload" : {
          "$ref" : "#/components/schemas/Event"
        },
        "summary" : "A comment was added to a record.",
        "traits" : [ {
          "$ref" : "#/components/messageTraits/Delivery"
        } ]
      },
      "recordCreated" : {
        "name" : "record.created",
        "payload" : {
          "$ref" : "#/components/schemas/Event"
        },
        "summary" : "A record was created.",
        "traits" : [ {
          "$ref" : "#/components/messageTraits/Delivery"
        } ]
      },
      "recordDeactivated" : {
        "name" : "record.deactivated",
        "payload" : {
          "$ref" : "#/components/schemas/Event"
        },
        "summary" : "A record was deactivated.",
        "traits" : [ {
          "$ref" : "#/components/messageTraits/Delivery"
        } ]
      },
      "recordStateChanged" : {
        "name" : "record.stateChanged",
        "payload" : {
          "$ref" : "#/components/schemas/Event"
        },
        "summary" : "A record moved to another state, or its state was corrected; `state` has both codes.",
        "traits" : [ {
          "$ref" : "#/components/messageTraits/Delivery"
        } ]
      }
    },
    "schemas" : {
      "Event" : {
        "additionalProperties" : false,
        "properties" : {
          "changedFields" : {
            "description" : "API names of the changed fields; never their values.",
            "items" : {
              "type" : "string"
            },
            "type" : "array"
          },
          "href" : {
            "description" : "Where to fetch the record with your own API key.",
            "format" : "uri",
            "type" : "string"
          },
          "id" : {
            "description" : "Unique per event; the same on every retry.",
            "type" : "string"
          },
          "objectType" : {
            "description" : "The API name of the object type, as in the tenant contract.",
            "type" : "string"
          },
          "occurredAt" : {
            "format" : "date-time",
            "type" : "string"
          },
          "record" : {
            "additionalProperties" : false,
            "properties" : {
              "id" : {
                "format" : "int64",
                "type" : "integer"
              },
              "number" : {
                "description" : "The record number, if the type has one.",
                "type" : "string"
              }
            },
            "required" : [ "id" ],
            "type" : "object"
          },
          "state" : {
            "additionalProperties" : false,
            "description" : "Only for `record.stateChanged`. Codes, not labels.",
            "properties" : {
              "from" : {
                "type" : [ "string", "null" ]
              },
              "to" : {
                "type" : [ "string", "null" ]
              }
            },
            "required" : [ "from", "to" ],
            "type" : "object"
          },
          "type" : {
            "enum" : [ "record.created", "record.changed", "record.stateChanged", "record.commented", "record.deactivated", "record.approvalDecided" ],
            "type" : "string"
          }
        },
        "required" : [ "id", "type", "occurredAt", "objectType", "record", "href" ],
        "type" : "object"
      }
    }
  },
  "defaultContentType" : "application/json",
  "info" : {
    "description" : "Horizon calls a URL you register (Access > Outbound events) whenever something happens to a record.\n\nEach event says what happened, never the values: the record, its type, the state before and after as codes, and the names of the changed fields. Fetch the record through `href` with your own API key, so it is filtered by your rights.\n\nDelivery is at least once. Deduplicate on `id`. Events for the same record arrive in order. Retries follow after 1, 5, 15 and 60 minutes, then hourly; after three days a delivery is given up. Answer `410 Gone` to stop retries for one delivery.\n\nVerify `Horizon-Signature` (HMAC-SHA256 over `<t>.<body>` with the signing key shown once when the subscription is created) and reject events older than five minutes.",
    "title" : "Horizon outbound events",
    "version" : "1"
  },
  "operations" : {
    "sendRecordApprovalDecided" : {
      "action" : "send",
      "channel" : {
        "$ref" : "#/channels/subscriberUrl"
      },
      "messages" : [ {
        "$ref" : "#/channels/subscriberUrl/messages/recordApprovalDecided"
      } ]
    },
    "sendRecordChanged" : {
      "action" : "send",
      "channel" : {
        "$ref" : "#/channels/subscriberUrl"
      },
      "messages" : [ {
        "$ref" : "#/channels/subscriberUrl/messages/recordChanged"
      } ]
    },
    "sendRecordCommented" : {
      "action" : "send",
      "channel" : {
        "$ref" : "#/channels/subscriberUrl"
      },
      "messages" : [ {
        "$ref" : "#/channels/subscriberUrl/messages/recordCommented"
      } ]
    },
    "sendRecordCreated" : {
      "action" : "send",
      "channel" : {
        "$ref" : "#/channels/subscriberUrl"
      },
      "messages" : [ {
        "$ref" : "#/channels/subscriberUrl/messages/recordCreated"
      } ]
    },
    "sendRecordDeactivated" : {
      "action" : "send",
      "channel" : {
        "$ref" : "#/channels/subscriberUrl"
      },
      "messages" : [ {
        "$ref" : "#/channels/subscriberUrl/messages/recordDeactivated"
      } ]
    },
    "sendRecordStateChanged" : {
      "action" : "send",
      "channel" : {
        "$ref" : "#/channels/subscriberUrl"
      },
      "messages" : [ {
        "$ref" : "#/channels/subscriberUrl/messages/recordStateChanged"
      } ]
    }
  }
}
