> ## Documentation Index
> Fetch the complete documentation index at: https://developers.activeprospect.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List all events

> The `/events` resource is used to query
[events](/docs/leadconduit/api/tag/Leads/#tag/Leads/schema/Event)
generated while handling leads. For each lead, one event is generated for
each configured [flow
step](/docs/leadconduit/api/tag/Flows/#tag/Flows/schema/Flow)
that handles the lead. After lead processing completes, a source event
is also recorded.




## OpenAPI

````yaml /api-reference/leadconduit_api.json get /events
openapi: 3.1.0
info:
  title: LeadConduit API
  version: 1.0.1
  termsOfService: https://activeprospect.com/terms-of-service/
  contact:
    name: ActiveProspect Support Team
    email: support@activeprospect.com
    url: https://support.activeprospect.com
  description: |
    # About
    This documentation is a technical manual for the LeadConduit API. It is
    primarily intended to be read by software developers who want to integrate
    another system with LeadConduit.

    The API is RESTful and speaks JSON over HTTPS. In general, anything that
    can be accomplished by pointing and clicking in the LeadConduit user
    interface can also be done using the API.

    ## Conventions
    This documentation provides examples that show how to interact with the
    API. Examples are shown in monospaced blocks like the one shown below:

    ```
    Examples are presented in blocks like this one
    ```

    You may also see monospaced font inline `like this`. This text represents a
    literal value or expression to be used with the API.

    ## Questions
    If you have a question, or spot an error in the documentation, or just
    generally need to speak with someone about the API, email
    [support@activeprospect.com](mailto:support@activeprospect.com).
servers:
  - url: https://app.leadconduit.com
    description: The base URL for production.
security:
  - APIKey: []
tags:
  - name: Destinations
    description: >
      Destinations are similar to a recipient step in a flow; they represent

      an external system which receives lead data at the end of a flow.

      Data is sent to a Destination if all prior steps have completed
      successfully,

      and are skipped if an error occurs in a prior step.


      Destinations are configured once and then globally available within all of
      an account's flows.

      Destinations must be configured within the [LeadConduit
      app](https://app.leadconduit.com),

      and cannot be configured directly via the API. However, once a destination
      is configured,

      it can be queried via the API. Configured destinations can also be added
      to flows via the API.
  - name: Flows
    description: >
      A flow defines how leads are processed. A flow

      can include a range of actions, including validation, normalization, and
      distribution, that are applied to leads as they

      move through the flow.


      Each step in the flow is represented by a "node," which can perform a
      specific action or set of actions on the lead.

      For example, a node might validate the lead's phone number or email
      address, normalize the lead's data, or distribute

      the lead to a specific destination based on predefined rules.


      Flows can be customized to meet the specific needs of your business, and
      LeadConduit offers a range of pre-built

      templates and tools to help you create a flow that fits your unique
      requirements.


      Overall, flows are a powerful feature of the LeadConduit platform that
      enable you to streamline lead processing,

      automate lead distribution, and improve lead quality, all while maximizing
      your ROI.


      Free accounts do not have access to Flows
      (https://app.leadconduit.com/flows) and will receive a 401 (Unauthorized)

      error when trying to access it
  - name: Fields
    description: >-
      A field represents a piece of data collected about a lead.  When a field
      is referenced by ID from a flow's `fields` 

      property, that piece of data will be captured when submitted. LeadConduit
      provides a large catalog of built-in fields, 

      so there should rarely be a need to create a custom field.  Custom fields
      are those where the `standard` property is false.


      Free accounts do not have access to Fields
      (https://app.leadconduit.com/fields) and will receive a 401
      (Unauthorized) 

      error when trying to access it
  - name: Changelogs
  - name: Events
  - name: Leads
    description: >-
      Free accounts do not have access to Leads
      (https://app.leadconduit.com/leads) and will receive a 401 (Unauthorized) 

      error when trying to access it
  - name: Entities
    description: >
      An entity is used to track lead flow. Each entity can be a source or a
      recipient or both. Entities can be used in 

      multiple flows. When an entity is a source, it can be added to a flow as a
      source and when it is a recipient, it can be 

      added to a flow as a recipient.
  - name: Firehose
    description: >-
      # Firehose Multi-Service Configuration


      ## Overview


      Each flow is separately configured to use the firehose. This API allows
      firehose configuration to be tested before it 

      is set on a flow.


      The Firehose feature supports multiple cloud storage services for event
      data export. This document describes the configuration options for both
      AWS S3 and Azure Blob Storage services.


      ## Configuration Structure


      ### Legacy Configuration (Backward Compatible)


      For existing flows, the legacy configuration continues to work:


      ```json

      {
        "firehose": {
          "enabled": true,
          "credential_id": "507f1f77bcf86cd799439011",
          "bucket": "my-s3-bucket",
          "prefix": "events/production"
        }
      }

      ```


      ### New Service-Based Configuration


      The new service-based configuration allows multiple cloud storage
      providers:


      ```json

      {
        "firehose": {
          "enabled": true,
          "services": {
            "aws": {
              "enabled": true,
              "credential_id": "507f1f77bcf86cd799439011",
              "bucket": "my-s3-bucket",
              "prefix": "events/aws"
            },
            "azure": {
              "enabled": true,
              "credential_id": "507f1f77bcf86cd799439012", 
              "bucket": "my-azure-container",
              "prefix": "events/azure"
            }
          }
        }
      }

      ```


      ## Credential Validation


      ### AWS S3 Validation


      The `/firehose` endpoint validates AWS credentials by:


      1. Creating a test file with unique name:
      `leadconduit_verification_[flow_id_]YYYYMMDDHHMMSSMS.txt`

      2. Uploading it to the specified bucket (with optional prefix) when
      `verification_file=true` (default)

      3. Alternatively, validating bucket access without creating file when
      `verification_file=false`

      4. Returning the S3 response with ETag or validation confirmation


      **Example Requests:**


      *Basic validation (creates file):*

      ```bash

      curl -X GET
      "https://app.leadconduit.com/firehose?service=aws&access_key_id=AKIA...&secret_access_key=wJal...&bucket=my-bucket&prefix=test"

      ```


      *With flow ID (includes flow identifier in filename):*

      ```bash

      curl -X GET
      "https://app.leadconduit.com/firehose?service=aws&access_key_id=AKIA...&secret_access_key=wJal...&bucket=my-bucket&flow_id=507f1f77bcf86cd799439011"

      ```


      *Validation only (no file created):*

      ```bash

      curl -X GET
      "https://app.leadconduit.com/firehose?service=aws&access_key_id=AKIA...&secret_access_key=wJal...&bucket=my-bucket&verification_file=false"

      ```


      **Example Responses:**


      *File created:*

      ```json

      {
        "validated": true,
        "verification_file": true
      }

      ```


      *Validation only:*

      ```json

      {
        "validated": true,
        "verification_file": false
      }

      ```


      ### Azure Blob Storage Validation


      The `/firehose` endpoint validates Azure credentials by:


      1. Creating a BlobServiceClient from the connection string

      2. Checking if the specified container exists and is accessible

      3. Optionally creating verification file based on `verification_file`
      parameter

      4. Returning container validation information


      **Example Request:**

      ```bash

      curl -X GET
      "https://app.leadconduit.com/firehose?service=azure&connection_string=DefaultEndpointsProtocol=https;AccountName=test;AccountKey=key;EndpointSuffix=core.windows.net&bucket=my-container"

      ```


      **Example Responses:**


      *With verification file:*

      ```json

      {
        "validated": true,
        "verification_file": true
      }

      ```


      *Validation only (verification_file=false):*

      ```json

      {
        "validated": true,
        "verification_file": false
      }

      ```


      ## Event Processing


      ### Single Service Configuration


      When only one service is configured, events are sent to that service. If
      the service fails, events are spooled for retry.


      ### Multi-Service Configuration


      When multiple services are configured:


      1. Each enabled service receives the event independently

      2. If a service fails, it generates its own spool message for retry

      3. Each service can have different bucket/container and prefix
      configurations


      ### Spooling and Retry


      - Each service failure generates a separate SQS message for retry

      - Spooled events contain service-specific metadata (bucket, prefix,
      credentials)

      - The unspooler processes each service's failed events independently

      - File-based spooling creates separate paths for each service
      configuration


      ## Migration Guide


      ### From Legacy to Service-Based Configuration


      1. **Keep existing configuration**: Legacy configuration continues to work

      2. **Add services object**: Gradually migrate to service-based
      configuration

      3. **Test thoroughly**: Validate both configurations work as expected


      Example migration:


      **Before:**

      ```json

      {
        "firehose": {
          "enabled": true,
          "credential_id": "507f1f77bcf86cd799439011",
          "bucket": "my-bucket"
        }
      }

      ```


      **After:**

      ```json

      {
        "firehose": {
          "enabled": true,
          "services": {
            "aws": {
              "enabled": true,
              "credential_id": "507f1f77bcf86cd799439011",
              "bucket": "my-bucket"
            }
          }
        }
      }

      ```
  - name: Account
    description: >
      The authenticated user reveals the details of the API caller's user
      account as well as certain details about

      the account of which the user is member. The `products` array reveals all
      ActiveProspect products and to which the

      caller's account is subscribed.
  - name: Connections
    description: Account connections with other LC accounts
  - name: System
  - name: Changelogs
    description: |
      A changelog represents a creation, update, or deletion of a model such as
      `Flow`, `Entity`, or `Field`. Every change made will log the exact
      difference between the previous revision and the current one, as well as
      what user was logged in and what account the change was made on.
      Contained within the changelog is the full revision of the model changed
      at the state after the change was applied, as well as the differences
      between the previous revision and current revision.
  - name: Credentials
    description: |
      A credential is used by LeadConduit's rich integrations to authenticate
      with third party platforms. Once a credential is established, it can be
      used across flows. A credential ID can be specified on a source in a flow
      or in recipient step's integration mappings.
  - name: Reports
    description: ''
  - name: Routers
    description: ''
  - name: Types
    x-traitTag: true
    description: >
      A type defines the kind of data LeadConduit expects in a field or in a
      data point appended to a lead by any

      LeadConduit integration. LeadConduit uses a field's type to understand a
      value submitted with a lead.


      Types are simple and are all provided "out of the box" by LeadConduit. You
      cannot add or remove types. Standard

      LeadConduit fields are properly typed. If you need to create a custom
      field for some reason, you can set the type.


      A field's type...

      * determines whether a field's value is valid

      * normalizes the formatting of a value

      * parses a value into it's constituent components for use in flow rules
      and mappings

      * protects consumer PII by masking sensitive information before
      LeadConduit stores it

      * preserves the raw value submitted to LeadConduit, just in case



      ## Boolean


      Boolean fields and variables are declared as type `boolean`.


      | Component | Type | Description |

      | --------------- | ---- | ----------- |

      | `raw`           | string  | Unmodified field value submitted with the
      lead |

      | `valid`         | boolean | Indicates whether the value could be
      understood as a boolean |

      | `normal`        | boolean | The normalized value (i.e. `"Yes"` is
      normalized to `true`) |


      ## City


      City fields and variables are declared as type `city`.


      ## Credential


      Credential fields and variables are declared as type `credential`.


      ## Date


      Date fields and variables are declared as type `date`.


      | Component | Type | Description |

      | --------------- | ---- | ----------- |

      | `raw`           | string | Unmodified value submitted with the lead |

      | `valid`         | boolean | Indicates whether the value could be
      understood as a date |

      | `normal`        | string  | The normalized value (i.e. `"10/1/1988"` is
      normalized to `"1988-10-01"`) |



      ### Supported Formats


      | Format | Example |

      | ------ | ------- |

      | `ddd MMM DD YYYY` | `"Mon Jun 02 2014"` |

      | `MMM DD YYYY`     | `"Jun 02 2014"` |

      | `M/D/YYYY`        | `"6/2/2014 or 06/02/2014"` |

      | `M/D/YY`          | `"6/2/14"` |

      | `YYYY-MM-DD`      | `"2014-06-02"` |

      | `MM-DD-YYYY`      | `"06-02-2014"` |

      | `MMDDYYYY`        | `"06022014"` |

      | `YYYYMMDD`        | `"20140602"` |

      | `"ddd DD MMM YYYY` | `"Fri 18 July 2014"` |

      | `"DD MMM YYYY"`   | `"18 July 2014"` |

      | `"D/M/YYYY"`      | `"18/7/2014"` |

      | `"D/M/YY"`        | `"18/7/14"` |

      |  `"YYYY-DD-MM"`   | `"2014-18-07"` |

      |  `"DD-MM-YYYY"`   | `"18-07-2014"` |

      |  `"DDMMYYYY"`     | `"18072014"` |

      |  `"YYYY-DD-MM"`   | `"2014-18-07"` |

      |  `"YYYYDDMM"`     | `"20141807"` |


      ## Date of Birth


      Date of birth fields and variables are declared as type `dob`. See the
      [date type](/docs/leadconduit/api/tag/Types/#tag/Types/section/Date) for
      supported formats.


      | Component | Type | Description |

      | --------------- | ---- | ----------- |

      | `raw`           | string | Unmodified value submitted with the lead |

      | `valid`         | boolean | Indicates whether the value could be
      understood as a date |

      | `normal`        | string  | The normalized value (i.e. `"10/1/1988"` is
      normalized to `"1988-10-01"`) |


      ## Email


      Email fields and variables are declared as type `email`.


      | Component       | Type | Description |

      | --------------- | ---- | ----------- |

      | `raw`           | string | Unmodified value submitted with the lead |

      | `valid`         | boolean | Indicates whether the value could be
      understood as an email address |

      | `normal`        | string  | The normalized value (i.e.
      `"MIKEJONES32@gmail.com"` is normalized to `"mikejones32@gmail.com"`) |

      | `user`          | string  | User name (everything to the left of @) |

      | `domain`        | string  | Domain name (everything to the right of @) |

      | `host`          | string  | Domain excluding top level domain |

      | `tld`           | string  | Top level domain (.com, .net, etc) |

      | `is_free`       | boolean  | Whether or not the email is from a free
      domain (ex: gmail, yahoo, etc) |

      | `is_disposable` | boolean  | Whether or not the email is disposable |


      ## First Name


      Email fields and variables are declared as type `first_name`.


      ## Gender


      Gender fields and variables are declared as type `gender`. Values are
      parsed case insensitively. Examples of valid

      gender values are: "male", "m", "female", "f", "other", "o".  


      | Component | Type | Description |

      | --------------- | ---- | ----------- |

      | `raw`           | string | Unmodified value submitted with the lead |

      | `valid`         | boolean  | Indicates whether the value could be
      understood as a gender |

      | `normal`        | string  | The normalized value (`"male"`, `"female"`,
      `"other"`) |

      | `abbr`          | string  | Abbreviation of the `normal` value (`"M"`,
      `"F"`, `"O"`) |


      ## Last Name


      Last name fields and variables are declared as type `last_name`.


      ## Number


      Number fields and variables are declared as type `number`. Decimal and
      negative numbers are supported. 

      Currency and unit punctuation characters are ignored.  


      | Component | Type | Description |

      | --------------- | ---- | ----------- |

      | `raw`           | string | Unmodified value submitted with the lead |

      | `valid`         | boolean  | Indicates whether the value could be
      understood as a number |

      | `normal`        | number  | The normalized value (i.e. `"$100.99"` is
      normalized to `100.99`) |



      ## Phone


      Phone fields and variables are declared as type `phone`. This data type
      only supports US phone numbers.


      | Component       | Type     | Description |

      | --------------- | -------- | ----------- |

      | `raw`           | string   | Unmodified value submitted with the lead |

      | `valid`         | boolean  | Indicates whether the value could be
      understood as a phone number |

      | `normal`        | string   | The normalized value (i.e. `"(281)
      330-8004"` is normalized to `"2813308004"`) |

      | `area`          | string   | Area code portion of the phone number (i.e.
      `"281"`) |

      | `exchange`      | string   | Exchange portion of the phone number (i.e.
      `"330"`) |

      | `line`          | string   | Line number portion of the phone number
      (i.e. `"8004"`) |

      | `number`        | string   | Full number (i.e. `"3308004"` |

      | `extension`     | string   | Phone number extension (i.e.
      `"2813308004x201" has extension `"201"`) |

      | `type`          | string   | Phone number type based on hint `m`, `h`,
      or `w` appended to the number- (i.e. `"(281) 330-8004m"` has type of
      `"mobile"`) |

      | `is_tollfree`   | boolean  | Phone has an `area` of 800, 844, 855, 866,
      877, or 888 |


      ### Supported Formats


      | Format | Description |

      | ------ | ------- |

      | `"2813308004"` |  Ten-digit phone number |

      | `"281-330-8004"` |  Ten-digit phone number with dashes |

      | `"281.330.8004"` |  Ten-digit phone number with dots |

      | `"281 330 8004"` |  Ten-digit phone number with spaces |

      | `"(281) 330-8004"` |  Ten-digit phone number with parentheses, space,
      and dash |

      | `"1 (281) 330-8004"` | Any supported format with preceding country code
      |


      ### Line Type Hint


      If a raw phone number value has line type hint appended, the phone type
      will automatically set the `type` value 

      appropriately. For example, the `c` hint found in `281-330-8004 (c)` (c
      indicates "cell") will cause the `type` 

      value to be set to "mobile". Hints can immediately follow the phone
      number, can be separated by the phone by any 

      number of spaces, and can also optionally be wrapped in parentheses.


      | Phone Number | `type` Value |

      | ------------ | ------------ |

      | `"2813308004c` | "mobile" |

      | `"2813308004m` | "mobile" |

      | `"2813308004 m` | "mobile" |

      | `"2813308004 (m)` | "mobile" |

      | `"2813308004w` | "work" |

      | `"2813308004h` | "home" |


      ### Extension Hint


      If a raw phone number value has an extension hint appended, the phone type
      will automatically set the `extension` 

      value appropriately. For example, the `x201` hint found in `281-330-8004
      x201` will cause the `extension` 

      value to be set to `"201"`. Hints can immediately follow the phone number,
      can be separated by the phone by any 

      number of spaces.



      ## Postal Code


      Postal Code fields and variables are declared as type `postal_code`.


      | Component       | Type     | Description |

      | --------------- | -------- | ----------- |

      | `raw`           | string   | Unmodified value submitted with the lead |

      | `valid`         | boolean  | Indicates whether the value could be
      understood as a postal code |

      | `normal`        | string   | The normalized value (i.e. `"78704 4224"`
      is normalized to `"78704-4224"`) |

      | `country_code`  | string   | Two letter country abbreviation (i.e.
      `"US"`) |

      | `zip`           | string   | First 5 digits of a US zip code (i.e.
      `"78704"`) |

      | `four`          | string   | Last 4 digits of a US zip code (i.e.
      `"4424"` |

      | `fsa`           | string   | Canadian forward sortation area (i.e. `"Q2E
      4U7"` has `fsa` of `"Q2E"`) |

      | `ldu`           | string   | Canadian forward sortation area (i.e. `"Q2E
      4U7"` has `fsa` of `"47U"`) |

      | `outcode`       | string   | Great Britain outward code (i.e. `"A1 1AA"`
      has `outcode` of `"A1"`) |

      | `incode`        | string   | Great Britain inward code (i.e. `"A1 1AA"`
      has `incode` of `"1AA"`) |


      ## Range


      Range fields and variables are declared as type `range`. A range is a
      field value with lower and upper numeric

      boundaries. Range fields are commonly used in scenarios where a consumer
      is presented a drop-down. For example,

      the standard `credit_score` range field might have the value `"700 -
      749"`.


      | Component       | Type     | Description |

      | --------------- | -------- | ----------- |

      | `raw`           | string   | Unmodified value submitted with the lead |

      | `valid`         | boolean  | Indicates whether the value could be
      understood as a range value |

      | `normal`        | string   | The normalized value (i.e. `"700 to 749"`
      is normalized to `"700-749"`) |

      | `min`           | number   | The lower boundary of the range (i.e.
      `700`) |

      | `max`           | number   | The upper boundary of the range (i.e.
      `749`) |

      | `avg`           | number   | The average of the `min` and `max` accurate
      to the second decimal place (i.e. `724.50`) |

      | `mid`           | number   | Average of max and min, rounded down to the
      nearest whole number (i.e. `724`) |


      ## SSN


      US Social Security Number fields and variables are declared as type `ssn`.


      | Component       | Type     | Description |

      | --------------- | -------- | ----------- |

      | `raw`           | string   | Unmodified value submitted with the lead |

      | `valid`         | boolean  | Indicates whether the value could be
      understood as a Social Security Number |

      | `normal`        | string   | The normalized SSN value (i.e.
      `"1234567890`") |

      | `first_three`   | string   | First three digits of SSN (i.e. SSN
      `"123-456-7890"` has `first_three` of`"123"`|

      | `middle_two`    | string   | Middle two digits of SSN (i.e. SSN
      `"123-456-7890"` has `first_three` of`"456"`|

      | `last_four`     | string   | Last four digits of SSN (i.e. SSN
      `"123-456-7890"` has `first_three` of`"7890"` |


      ## State


      Locality or State fields and variables are declared as type `state`.


      | Component       | Type     | Description |

      | --------------- | -------- | ----------- |

      | `raw`           | string   | Unmodified value submitted with the lead |

      | `valid`         | boolean  | Indicates whether the value could be
      understood as a locality or state |

      | `normal`        | string   | The normalized locality or state. US states
      and territories are normalized to their two letter code (i.e. `"TX"`) |

      | `name`          | string   | Full name of the locality or state (i.e
      `"Texas"`) |


      ## String


      String fields and variables are declared as type `string`.



      ## Time


      Time fields and variables are declared as type `time`.
  - name: Rules
    x-traitTag: true
    description: >
      LeadConduit uses a rules engine to customize flow behavior based on field
      data, appended data, or internal

      tracking metadata (such as the submission timestamp). The rules engine is
      built into flow acceptance criteria,

      filtering, volume caps, pricing, mappings, and more. 


      ### Rule Set


      Rules belong to a set which has the following properties:

       * `op` &mdash; `and` or `or` determines whether all rules in set must pass or just one
       * `rules` &mdash; the array of Rules and/or Rule Sets to evaluate

      ### Rules


      Each element of the `rules` array can be a Rule or another Rule Set.


      Rules have the following properties:
       * `lhv` &mdash; left hand value is a key to look up a value from the lead data context
       * `op` &mdash; operator Name of the operator 
       * `rhv` &mdash; right hand value (omit for unary operators like `is blank`)
       * `rule_set` &mdash; optional rule set to be ANDed with the rule

      ### Variables


      When rules are processed the `lhv` will be resolved to a value using the
      data in the variables found under that key. For example, if the `lhv`

      is "lead.first_name" and the variables are `{ "lead": { "first_name":
      "Bob" } }`, then the resolved `lhv` will be "Bob".


      ### Templating


      The `lhv` and `rhv` of each rule supports
      (templating)[/docs/leadconduit/api/tag/Templates/]. The variables are used
      to evaluate the template.
  - name: Invitations
    description: Invite another account to connect
  - name: Onboards
    description: >
      Onboards are records that track the buyer connection onboarding process in
      LeadConduit. When a buyer accepts an invitation to connect with a seller,
      an onboard record is created to manage and track the setup workflow.


      ## Overview


      The onboarding process involves:


      1. **Creating an Onboard** - When a buyer accepts a connection invitation,
      an onboard record is created with status `created`. Optionally, the UI can
      send a `flow_id` if already available

      2. **In Progress** - The UI sends a PUT with the user's `flow_id` and
      status `in_progress`

      3. **Completing Setup** - The UI must send a PUT with status `completed`
      to notify the backend that the onboard process is finished. The backend
      then calls `/onboard/buyer` to finish the flow synchronization


      **Note:** The `/onboard/buyer` endpoint can also be called directly by the
      UI modal when the user has already completed a previous onboard process.


      ## Onboard Statuses


      | Status | Description |

      |--------|-------------|

      | `created` | Initial state when the onboard is first created |

      | `in_progress` | The UI has sent the user's `flow_id` |

      | `completed` | The backend triggers the buyer delivery setup by calling
      `/onboard/buyer` |

      | `failed` | The setup process encountered an error |


      ## Buyer Setup Process


      The backend automatically triggers the buyer delivery setup when the
      onboard status is set to `completed`. This process performs:


      1. **Connection Validation** - Verifies the connection exists and hasn't
      already been set up

      2. **Seller Flow Discovery** - Finds all seller flows that have a buyer
      step pointing to this buyer

      3. **Buyer Flow Setup** - Creates or updates the buyer's flow to receive
      leads from the seller

      4. **Seller Flow Updates** - Adds the buyer's `flow_id` to the seller's
      flow mappings

      5. **Notifications** - Sends email notifications to seller account users
      about the new connection

      6. **Connection Flagging** - Marks the connection as having buyer delivery
      configured
  - name: Variables
    x-traitTag: true
    description: |
      A variable is a key/value pair that is available to filters, rule sets
      and mappings and in templates at run time while processing a lead.

      Every lead is born with a standard set of variables, and additional
      variables are added at run-time as leads are processed by each step in
      the flow. The full set of variables are stored on every event (in the
      `vars` property) generated during lead processing.

      Variables are stored on events as nested objects and are referenced at
      runtime using dot-notation. There are several top-level variable prefixes
      that logically group variables.
  - name: Caps and Limits
    description: >
      LeadConduit supports two controls that set constraints on lead submissions
      and pings. 


      ### Cap

      A cap allows limiting the number of leads sent to a flow. If a lead is
      successful, it will be counted against the

      `maximum` configured leads. If configured, the rule set will be evaluated
      to determine whether a lead will be counted

      against the cap.
  - name: Lead Submission
    x-traitTag: true
    description: |+
      How lead handling works

  - name: Templates
    x-traitTag: true
    description: >
      LeadConduit supports combining,
      [formatting](/docs/leadconduit/api/tag/Templates/#tag/Templates/section/Variable-Formatting),

      [hashing](/docs/leadconduit/api/tag/Templates/#tag/Templates/section/Variable-Hashing),
      and [performing
      math](/docs/leadconduit/api/tag/Templates/#tag/Templates/section/Variable-Math)
      on

      values using template markup. Templating in LeadConduit is based on the

      popular [Handlebars](https://handlebarsjs.com/) semantic templating

      library. A template is a string which contains any number of variable

      placeholders


      ## Template Variable


      Variable placeholders in templates start and end with two curly-brace

      characters: `{{ lead.first_name }}`. Multiple placeholders can be

      combined in a single template: `{{ lead.first_name }} {{ lead.last_name

      }}`. The [universe of possible
      variables](/docs/leadconduit/api/tag/Variables/) available to a

      template depends on the [fields](/docs/leadconduit/api/tag/Fields/)
      defined in your flow and the

      steps you've added to your flow.


      ## Variable Formatting


      LeadConduit has a built-in helper for formatting numbers and dates.

      Formatting a value is done with the `format` helper.  If the value is a

      date field, then you may use date formatting options with the helper.

      If it's a number field, then you may use the number formatting options

      with the helper.


      ### Date Variable Formatting


      To format a date, use the `format` helper: `{{ format lead.dob

      format="YYYY-MM-DD" }}` results in '2015-06-24'. The `format` option is

      a string which defines the format of the date. This format can be any

      combination of the below tokens.  To escape characters in format

      strings, you can wrap the characters in square brackets: `{{ format

      lead.dob format="[It's] MMMM Do" }}` results in "It's October 12th".


      #### Date Format Tokens


      |                            | Token                      | Output     |

      | -------------------------- | -------------------------- | -----------|

      | Month                      | `M`                          | 1 2 ... 11
      12

      |                            | `Mo`                         | 1st 2nd ...
      11th 12th

      |                            | `MM`                         | 01 02 ... 11
      12

      |                            | `MMM`                        | Jan Feb ...
      Nov Dec

      |                            | `MMMM`                       | January
      February ... November December

      | Quarter                    | `Q`                          | 1 2 3 4

      |                            | `Qo`                         | 1st 2nd 3rd
      4th

      | Day of Month               | `D`                          | 1 2 ... 30
      31

      |                            | `Do`                         | 1st 2nd ...
      30th 31st

      |                            | `DD`                         | 01 02 ... 30
      31

      | Day of Year                | `DDD`                        | 1 2 ... 364
      365

      |                            | `DDDo`                       | 1st 2nd ...
      364th 365th

      |                            | `DDDD`                       | 001 002 ...
      364 365

      | Day of Week                | `d`                          | 0 1 ... 5 6

      |                            | `do`                         | 0th 1st ...
      5th 6th

      |                            | `dd`                         | Su Mo ... Fr
      Sa

      |                            | `ddd`                        | Sun Mon ...
      Fri Sat

      |                            | `dddd`                       | Sunday
      Monday ... Friday Saturday

      | Day of Week (Locale)       | `e`                          | 0 1 ... 5 6

      | Day of Week (ISO)          | `E`                          | 1 2 ... 6 7

      | Week of Year               | `w`                          | 1 2 ... 52
      53

      |                            | `wo`                         | 1st 2nd ...
      52nd 53rd

      |                            | `ww`                         | 01 02 ... 52
      53

      | Week of Year (ISO)         | `W`                          | 1 2 ... 52
      53

      |                            | `Wo`                         | 1st 2nd ...
      52nd 53rd

      |                            | `WW`                         | 01 02 ... 52
      53

      | Year                       | `YY`                         | 70 71 ... 29
      30

      |                            | `YYYY`                       | 1970 1971
      ... 2029 2030

      |                            | `Y`                         | 1970 1971 ...
      9999 +10000 +10001 Note: This complies with the ISO 8601 standard for
      dates past the year 9999

      | Week Year                  | `gg`                         | 70 71 ... 29
      30

      |                            | `gggg`                       | 1970 1971
      ... 2029 2030

      | Week Year (ISO)            | `GG`                         | 70 71 ... 29
      30

      |                            | `GGGG`                       | 1970 1971
      ... 2029 2030

      | AM/PM                      | `A`                          | AM PM

      |                            | `a`                          | am pm

      | Hour                       | `H`                          | 0 1 ... 22
      23

      |                            | `HH`                         | 00 01 ... 22
      23

      |                            | `h`                          | 1 2 ... 11
      12

      |                            | `hh`                         | 01 02 ... 11
      12

      |                            | `k`                          | 1 2 ... 23
      24

      |                            | `kk`                         | 01 02 ... 23
      24

      | Minute                     | `m`                          | 0 1 ... 58
      59

      |                            | `mm`                         | 00 01 ... 58
      59

      | Second                     | `s`                          | 0 1 ... 58
      59

      |                            | `ss`                         | 00 01 ... 58
      59

      | Fractional Second          | `S`                          | 0 1 ... 8 9

      |                            | `SS`                         | 00 01 ... 98
      99

      |                            | `SSS`                        | 000 001 ...
      998 999

      |                            | `SSSS ... SSSSSSSSS`         | 000[0..]
      001[0..] ... 998[0..] 999[0..]

      | Time Zone                  | `z` or `zz`                  | EST CST ...
      MST PST (requires use of the `timezone` option)

      |                            | `Z`                          | -07:00
      -06:00 ... +06:00 +07:00

      |                            | `ZZ`                         | -0700 -0600
      ... +0600 +0700

      | Unix Timestamp             | `X`                          | 1360013296

      | Unix Millisecond Timestamp | `x`                          |
      1360013296123


      #### Localized Date Formats


      Because preferred formatting differs based on locale, there are a few

      tokens that can be used to format a moment based on its locale.  There

      are upper and lower case variations on the same formats. The lowercase

      version is intended to be the shortened version of its uppercase

      counterpart.  To change the locale, use the `locale` options: `{{

      format date format="LLL" locale="fr" }}` results in "24 june 2015 17:24".


      |                                      | Format string | Output          |

      | ------------------------------------ | ------------- | ----------------|

      | Time                                 | `LT`            | 8:30 PM

      | Time with seconds                    | `LTS`           | 8:30:25 PM

      | Month numeral, day of month, year    | `L`             | 09/04/1986

      |                                      | `l`             | 9/4/1986

      | Month name, day of month, year       | `LL`            | September 4,
      1986

      |                                      | `ll`            | Sep 4, 1986

      | Month name, day of month, year, time | `LLL`           | September 4,
      1986 8:30 PM

      |                                      | `lll`           | Sep 4, 1986
      8:30 PM

      | Month name, day of month, day of week, year, time | `LLLL` | Thursday,
      September 4, 1986 8:30 PM

      |                                      | `llll`          | Thu, Sep 4,
      1986 8:30 PM


      ### Number Variable Formatting


      To format a number, use the `format` helper: `{{ format

      lead.mortgage.first_mortgage_balance format="$0,0.00"}}` results in

      '$45,302.00'. The `format` option is a string which defines the format

      of the number. See the table of examples below:


      | Number     | Format       | String      |

      | ---------- | ------------ | ----------- |

      | 10000      | `0,0.0000`   | 10,000.0000

      | 10000.23   | `0,0`        | 10,000

      | 10000.23   | `+0,0`       | +10,000

      | -10000     | `0,0.0`      | -10,000.0

      | 10000.1234 | `0.000`      | 10000.123

      | 100.1234   | `00000`      | 00100

      | 1000.1234  | `000000,0`   | 001,000

      | 10         | `000.00`     | 010.00

      | 10000.1234 | `0[.]00000`  | 10000.12340

      | -10000     | `(0,0.0000)` | (10,000.0000)

      | -0.23      | `.00`        | -.23

      | -0.23      | `(.00)`      | (.23)

      | 0.23       | `0.00000`    | 0.23000

      | 0.23       | `0.0[0000]`  | 0.23

      | 1230974    | `0.0a`       | 1.2m

      | 1460       | `0 a`        | 1 k

      | -104000    | `0a`         | -104k

      | 1          | `0o`         | 1st

      | 100        | `0o`         | 100th

      | 1000.234   | `$0,0.00`    | $1,000.23

      | 1000.2     | `0,0[.]00 $` | 1,000.20 $

      | 1001       | `$ 0,0[.]00` | $ 1,001

      | -1000.234  | `($0,0)`     | ($1,000)

      | -1000.234  | `$0.00`      | -$1000.23

      | 1230974    | `($ 0.00 a)` | $ 1.23 m


      Use the `locale` option to format the number to a particular locale:

      `{{ format lead.mortgage.first_mortgage_balance locale="fr"

      format="$0,0.00" }}` results in '€45 302.00'.


      ### Converting Number and Boolean to String


      Fields of type number and boolean can be converted to string using the
      `format` helper with the `dataType="String"` option:


      `{{format field_name dataType="String"}}`


      Example:

      - Input: `{{format lead.age dataType="String"}}` with `lead.age` = 30

      - Output: "30"


      ### Converting String to Number


      Fields whose final result from the `format` helper is a string can be
      converted to a number if the `dataType="Number"` option is passed and the
      value is a string representing a valid number.


      Examples:

      - Input: `{{format lead.postal_code dataType="Number"}}` with
      `lead.postal_code` = '78751'

      - Output: 78751 (as a number value)


      If the string does not represent a valid number, the result will not be
      converted:

      - Input: `{{format lead.postal_code dataType="Number"}}` with
      `lead.postal_code` = 'H3Z 2Y7'

      - Output: 'H3Z 2Y7'


      This can also be used with dates if the formatting returns only numbers,
      such as epoch time:

      - Input: `{{format lead.source_timestamp format="X" dataType="Number"}}`
      with `lead.source_timestamp` = '2015-06-24T17:24:49.060Z'

      - Output: 1435166689 (as a number value)



      ## Variable String Manipulation


      Strings can be manipulated with the following helpers:


      ### Lowercase


      Transforms the value to lowercase:


      `{{lowercase field_name}}`


      Example:

      - Input: `{{lowercase lead.first_name}}` with `lead.first_name` = "Mike"

      - Output: "mike"


      ### Uppercase


      Transforms the value to uppercase:


      `{{uppercase field_name}}`


      Example:

      - Input: `{{uppercase lead.first_name}}` with `lead.first_name` = "Mike"

      - Output: "MIKE"


      ### Substring


      Returns a substring from the start position to the end position, or from
      the start position to the end of the string if no end position is
      provided:


      `{{substring field_name start="3"}}`


      Example:

      - Input: `{{substring lead.first_name start="3"}}` with `lead.first_name`
      = "Michael"

      - Output: "chael"


      `{{substring field_name start="2" end="4"}}`


      Example:

      - Input: `{{substring lead.first_name start="2" end="4"}}` with
      `lead.first_name` = "Michael"

      - Output: "ich"


      ### Replace


      Replaces the pattern with the content of the replace option. The pattern
      can be a literal string or a regular expression using the `regexp()`
      option:


      `{{replace field_name pattern="Mi" replace="At"}}`


      Example:

      - Input: `{{replace lead.first_name pattern="Mi" replace="At"}}` with
      `lead.first_name` = "Michael"

      - Output: "Atchael"


      `{{replace field_name pattern="regexp(h.{3})" replace="ke"}}`


      Example:

      - Input: `{{replace lead.first_name pattern="regexp(h.{3})"
      replace="ke"}}` with `lead.first_name` = "Michael"

      - Output: "Micke"


      ### Extract


      Extracts all occurrences found with the regular expression in the pattern:


      `{{extract field_name
      pattern="\$begin:math:display$(.*?)\\$end:math:display$"}}`


      Example:

      - Input: `{{ extract foo pattern="(?<=#)(\\w+)(?=#)" }}` with
      `lead.first_name` = "#John#Doe#Smith"

      - Output: "John Doe"


      ## Variable Math


      To perform math operations, use the `math` helper: `{{ math "1 + 1" }}`

      results in `2`. Of course, variables can also be used: `{{ math "1 +

      lead.random_number" }}` might result in `32` depending on the value

      of `lead.random_number`. The math expression accepts a pretty basic

      grammar. Operators have the normal precedence:


      | Operator                 | Associativity | Description

      | ------------------------ | ------------- | ----------

      | (...)                    | None          | Grouping

      | f(), x.y                 | Left          | Function call, property
      access

      | !                        | Left          | Factorial

      | ^                        | Right         | Exponentiation

      | +, -, not, sqrt, etc.    | Right         | Unary prefix operators (see
      below for the full list)

      | \*, /, %                 | Left          | Multiplication, division,
      remainder

      | +, -, \|\|               | Left          | Addition, subtraction,
      concatenation

      | ==, !=, >=, <=, >, <, in | Left          | Equals, not equals, etc. "in"
      means "is the left operand included in the right array operand?" (disabled
      by default)

      | and                      | Left          | Logical AND

      | or                       | Left          | Logical OR

      | x ? y : z                | Right         | Ternary conditional (if x
      then y else z)


      There are also several pre-defined functions:


      | Function      | Description |

      | ------------- | ----------- |

      | sin(x)        | Sine of x (x is in radians)

      | cos(x)        | Cosine of x (x is in radians)

      | tan(x)        | Tangent of x (x is… well, you know)

      | asin(x)       | Arc sine of x (in radians)

      | acos(x)       | Arc cosine of x (in radians)

      | atan(x)       | Arc tangent of x (in radians)

      | sqrt(x)       | Square root of x. Result is NaN (Not a Number) if x is
      negative.

      | log(x)        | Natural logarithm of x (not base-10). It’s log instead
      of ln because that’s what JavaScript calls it.

      | abs(x)        | Absolute value (magnitude) of x

      | ceil(x)       | Ceiling of x — the smallest integer that’s >= x.

      | floor(x)      | Floor of x — the largest integer that’s <= x

      | round(x)      | X, rounded to the nearest integer, using "grade-school
      rounding"

      | roundTo(x, n) | Rounds x to n places after the decimal point

      | exp(x)        | ex (exponential/antilogarithm function with base e)

      | random(n)     | Get a random number in the range [0, n). If n is zero,
      or not provided, it defaults to 1.

      | fac(n)        | n! (factorial of n: “n * (n-1) * (n-2) * … * 2 * 1″)

      | min(a,b,...)  | Get the smallest (“minimum”) number in the list

      | max(a,b,...)  | Get the largest (“maximum”) number in the list

      | pyt(a, b)     | Pythagorean function, i.e. the c in “c2 = a2 + b2“

      | pow(x, y)     | xy. This is exactly the same as “x^y”. It’s just
      provided since it’s in the Math object from JavaScript

      | atan2(y, x)   | arc tangent of x/y. i.e. the angle between (0, 0) and
      (x, y) in radians

      | if(c, a, b)   | Function form of c ? a : b


      #### Example


      To calculate the loan-to-value ratio, given a mortgage loan amount and

      the value of the home: `{{ math "(lead.mortgage.loan.amount /

      lead.mortgage.new_property_value) * 100" }}%`. Note that this example

      expresses the LTV as a percentage, first by calculating the percentage

      and then by appending the `%` character outside the variable

      placeholder. This could instead be handled using

      [formatting](#variable-math-formatting).


      ### Variable Math Formatting


      The `math` helper supports the same options as the `format` helper for

      numbers: `format` and `locale`. For example, to calculate the

      loan-to-value ratio and format it as a percentage: `{{ math

      "lead.mortgage.loan.amount / lead.mortgage.new_property_value"

      format="0.[00]%" }}`. This would return the LTV percentage with up to 2

      decimal points (i.e. 72.93%) as a string value.


      ## Variable Hashing


      LeadConduit supports a wide variety of hashing functions that can be

      applied to variables in a template. The helper name determines the

      hashing algorithm. For example, to use MD5 to hash the email address use:

      `{{ md5 lead.email }}`.  All the following hashing algorithms are

      supported:
        
      * md4

      * md5

      * ripemd

      * ripemd160

      * sha1

      * sha224

      * sha256

      * sha384

      * sha512

      * whirlpool
        
      Multiple values can be hashed together: `{{ md5 lead.email lead.phone_1
      }}`. This can be used to salt the hash 

      also: `{{ md5 lead.email "this is my salt" }}`. The `salt` option can also
      be used. This is the equivalent of the 

      last example: `{{ md5 lead.email salt="this is my salt" }}`.  


      Hashing supports multiple encodings using the `encoding` option:

      `{{ md5 lead.email encoding="base64" }}` results in something like

      "tkK0IXs0sejTvZFfxlxEUg==". The following encodings are supported:
        
      * `hex` (default)

      * `base64`

      * `latin1`
externalDocs:
  url: https://developers.activeprospect.com/
  description: ActiveProspect Developer Portal
paths:
  /events:
    get:
      tags:
        - Leads
      summary: List all events
      description: >
        The `/events` resource is used to query

        [events](/docs/leadconduit/api/tag/Leads/#tag/Leads/schema/Event)

        generated while handling leads. For each lead, one event is generated
        for

        each configured [flow

        step](/docs/leadconduit/api/tag/Flows/#tag/Flows/schema/Flow)

        that handles the lead. After lead processing completes, a source event

        is also recorded.
      operationId: listEvents
      parameters:
        - name: after_id
          in: query
          schema:
            $ref: '#/components/schemas/ID'
          description: >-
            Return only events that were created after the one with this ID
            (exclusive)
        - name: before_id
          in: query
          schema:
            $ref: '#/components/schemas/ID'
          description: >-
            Return only events that were created before the one with this ID
            (exclusive)
        - name: start
          in: query
          schema:
            $ref: '#/components/schemas/Timestamp'
          description: Return only events that were created at or after this time
        - name: end
          in: query
          schema:
            $ref: '#/components/schemas/Timestamp'
          description: Return only events that were created at or before this time
        - name: rules
          in: query
          schema:
            type: string
          description: Stringified array of Rules to select matching events
        - name: include
          in: query
          schema:
            type: array
            items:
              type: string
          description: An array of fields to include. Cannot be used with exclude.
        - name: exclude
          in: query
          schema:
            type: array
            items:
              type: string
          description: An array of fields to exclude. Cannot be used with include.
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 1000
          description: >-
            The maximum number of events to return (maximum limit is 1000,
            default 100)
        - name: sort
          in: query
          schema:
            type: string
          description: >-
            The results are sorted by date. Use asc to sort by oldest first or
            desc to sort by newest first. Defaults to desc.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Event'
        '401':
          description: Authorization information is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotAuthorized'
components:
  schemas:
    ID:
      type: string
      description: 24 character alpha-numeric BSON identifier
      pattern: ^[0-9a-fA-F]{24}$
      readOnly: true
      example: 5fd4371e940df5a34a3888b2
    Timestamp:
      type: string
      format: date-time
    Event:
      x-tags:
        - Leads
      type: object
      description: >-
        An event tracks what happened with a lead at a particular step in a
        flow. An event is a self-contained snapshot of the state of the lead at
        the time the lead visited the step. It contains a full copy of all lead
        data, along with all data that was appended before that step. Every
        event contains the below properties.
      properties:
        type:
          type: string
          enum:
            - source
            - recipient
            - filter
            - feedback-received
            - feedback-sent
            - retry
      discriminator:
        propertyName: type
        mapping:
          source:
            $ref: '#/components/schemas/source-event'
          recipient:
            $ref: '#/components/schemas/recipient-event'
          filter:
            $ref: '#/components/schemas/filter-event'
          feedback-received:
            $ref: '#/components/schemas/feedback-received-event'
          feedback-sent:
            $ref: '#/components/schemas/feedback-sent-event'
          retry:
            $ref: '#/components/schemas/retry-event'
      oneOf:
        - $ref: '#/components/schemas/source-event'
        - $ref: '#/components/schemas/recipient-event'
        - $ref: '#/components/schemas/filter-event'
        - $ref: '#/components/schemas/feedback-received-event'
        - $ref: '#/components/schemas/feedback-sent-event'
        - $ref: '#/components/schemas/retry-event'
    NotAuthorized:
      type: object
      properties:
        error:
          type: string
          example: not authorized
    source-event:
      allOf:
        - $ref: '#/components/schemas/EventProperties'
        - title: Source Event
          type: object
          description: >-
            The source event is created after all steps have been processed. It
            represents the outcome of lead processing from the perspective of
            the lead source. A source event records the below properties in
            addition to the event properties shown above.
          properties:
            type:
              description: Recorded after a source submits a lead to a flow
              type: string
              enum:
                - source
            outcome:
              enum:
                - success
                - failure
                - error
              x-enumDescriptions:
                success: >-
                  The source was notified in the response that the lead was
                  accepted
                failure: >-
                  The source was notified in the response that the lead was
                  rejected
                error: >-
                  The source was notified in the response that an error occurred
                  while processing the lead
            vars:
              $ref: '#/components/schemas/SourceVariables'
            module_id:
              $ref: '#/components/schemas/ModuleID'
              description: The integration module ID configured for the source
            package_version:
              $ref: '#/components/schemas/SemanticVersion'
              description: The semantic version of the integration package
            acceptance_criteria:
              $ref: '#/components/schemas/acceptance-criteria'
              description: >-
                The acceptance criteria configured on the source when the lead
                was processed
            step_count:
              type: integer
              description: >-
                The number of steps processed for this lead (>= 0 and <= total
                number of steps)
              example: 4
            appended:
              type: object
              description: All data appended while handing the lead
            request:
              $ref: '#/components/schemas/HttpRequest'
              description: The inbound HTTP request
            response:
              $ref: '#/components/schemas/HttpResponse'
              description: The inbound HTTP response
    recipient-event:
      allOf:
        - $ref: '#/components/schemas/EventProperties'
        - title: Recipient Event
          type: object
          description: >
            When a lead is processed by a recipient step, the associated
            integration is resolved using

            the `module_id` and invoked. The integration contacts the
            recipient's server and determines the `outcome` and `reason` 

            for the call. Different integrations determine outcome in different
            ways, so it's important to know what `success`

            or `failure` mean for a particular integration.
          properties:
            type:
              description: >-
                Recorded after a lead is sent to a recipient using a recipient
                step in a flow
              type: string
              enum:
                - recipient
            outcome:
              enum:
                - success
                - failure
                - error
                - skip
              x-enumDescriptions:
                success: The recipient accepted the lead
                failure: The recipient rejected the lead
                error: >-
                  An error occurred while attempting to communicate with the
                  recipient
                skip: >-
                  The recipient step was skipped due to failure the rule set or
                  cap having been met
            vars:
              $ref: '#/components/schemas/RecipientVariables'
            step_id:
              type: string
              description: The id of the step in the flow associated with this event
            caps:
              $ref: '#/components/schemas/Caps'
            caps_reached:
              type: boolean
              description: One or more of the recipient caps were met
            key:
              type: string
              description: The property name on the event where appended data is stored
            cost:
              type: number
              format: double
              description: The amount paid for the purchase of this lead
            purchase_price:
              type: number
              format: double
              description: The amount paid for the purchase of this lead
            sale_price:
              type: number
              format: double
              description: The revenue received for the sale of this lead
            revenue:
              type: number
              format: double
              description: The difference between the purchase price and the sale price
            module_id:
              $ref: '#/components/schemas/ModuleID'
            credential:
              $ref: '#/components/schemas/Credential'
            credential_updated:
              type: boolean
              description: Whether the credential used by the integration was refreshed
            package_version:
              $ref: '#/components/schemas/SemanticVersion'
            rule_set:
              $ref: '#/components/schemas/rule-set'
              description: >-
                The rule set configured on the recipient step when the lead was
                processed 
            mappings:
              type: array
              description: The mappings applied while invoking the integration
              items:
                $ref: '#/components/schemas/Mapping'
            pricing:
              $ref: '#/components/schemas/Pricing'
              description: The pricing configuration applied to this recipient
            transactions:
              $ref: '#/components/schemas/Transactions'
            wait_ms:
              type: integer
              description: >-
                The number of milliseconds that LeadConduit spent waiting the
                recipient to respond
            total_ms:
              type: integer
              description: >-
                The number of milliseconds that elapsed since the lead was
                submitted 
    filter-event:
      allOf:
        - $ref: '#/components/schemas/EventProperties'
        - title: Filter Event
          type: object
          description: |
            A filter event is created when a lead is processed by a filter step.
          properties:
            type:
              description: Recorded after a filter step in a flow is processed
              type: string
              enum:
                - filter
            outcome:
              enum:
                - continue
                - stop
                - error
              x-enumDescriptions:
                success: >-
                  The filter's rule set did not match the lead, and the flow
                  continued
                failure: The filter's rule set matched the lead, and the flow stopped
                error: >-
                  An unhandled error occurred while processing the filter step
                  (this indicates a problem with LeadConduit)
            reason:
              type: string
              description: Set by evaluating the `reason` template of the filter step.
            vars:
              $ref: '#/components/schemas/FilterVariables'
            rule_set:
              $ref: '#/components/schemas/rule-set'
              description: >-
                The rule set configured on the recipient step when the lead was
                processed
    feedback-received-event:
      allOf:
        - $ref: '#/components/schemas/EventProperties'
        - title: Feedback Received Event
          type: object
          description: >
            A feedback-received event is created when lead feedback is provided
            by a recipient. The feedback configuration must be

            provided on the recipient step. When feedback is received, all
            variables are copied from the original recipient event.


            When feedback is configured to be sent to the source, the
            feedback-received event's `outcome` and `reason` are copied

            from the feedback-sent event. In other words, if the source refuses
            the feedback, the recipient will receive a "failure"

            outcome in response to the feedback call.
          properties:
            type:
              description: >-
                Recorded after a recipient provides feedback on a lead
                previously sent with a recipient step
              type: string
              enum:
                - feedback-received
            outcome:
              enum:
                - success
                - failure
                - error
              x-enumDescriptions:
                success: >-
                  The recipient was notified in the response that the feedback
                  was accepted
                failure: >-
                  The recipient was notified in the response that the feedback
                  was rejected
                error: >-
                  The recipient was notified in the response that an error
                  occurred while processing the feedback
            vars:
              $ref: '#/components/schemas/FeedbackVariables'
            module_id:
              $ref: '#/components/schemas/ModuleID'
              description: The integration module ID configured for the recipient
            recipient_event_id:
              $ref: '#/components/schemas/ID'
              description: The ID of the recipient event used to provide the feedback
            step_id:
              type: string
              description: The ID flow step that originally sent the lead to the recipient
            feedback:
              $ref: '#/components/schemas/Feedback'
            request:
              $ref: '#/components/schemas/HttpRequest'
              description: The feedback HTTP request
            response:
              $ref: '#/components/schemas/HttpResponse'
              description: The feedback HTTP response
    feedback-sent-event:
      allOf:
        - $ref: '#/components/schemas/EventProperties'
        - title: Feedback Sent Event
          type: object
          description: >
            A feedback-sent event is created when lead feedback is sent to a
            source. The feedback configuration must be provided on

            the source in the flow. When feedback is sent, all lead variables
            are copied from the original recipient event.
          properties:
            type:
              description: >-
                Recorded after a feedback is sent to a source as a consequence
                of the recipient providing feedback
              type: string
              enum:
                - feedback-sent
            outcome:
              enum:
                - success
                - failure
                - error
              x-enumDescriptions:
                success: The source accepted the feedback
                failure: The source rejected the feedback
                error: >-
                  An error occurred while attempting to communicate with the
                  source
            vars:
              $ref: '#/components/schemas/FeedbackVariables'
            module_id:
              $ref: '#/components/schemas/ModuleID'
              description: The integration module ID configured for the recipient
            recipient_event_id:
              $ref: '#/components/schemas/ID'
              description: The ID of the recipient event used to provide the feedback
            step_id:
              type: string
              description: The ID flow step that originally sent the lead to the recipient
            feedback:
              $ref: '#/components/schemas/Feedback'
            request:
              $ref: '#/components/schemas/HttpRequest'
              description: The feedback HTTP request
            response:
              $ref: '#/components/schemas/HttpResponse'
              description: The feedback HTTP response
    retry-event:
      allOf:
        - $ref: '#/components/schemas/EventProperties'
        - title: Retry Event
          type: object
          description: >
            When a recipient step results in an error outcome and retry is
            enabled, a retry event is recorded
          properties:
            type:
              description: Recorded after an error recipient event is retried
              type: string
              enum:
                - retry
            outcome:
              enum:
                - success
                - failure
                - error
                - skip
              x-enumDescriptions:
                success: The recipient accepted the lead
                failure: The recipient rejected the lead
                error: >-
                  An error occurred while attempting to communicate with the
                  recipient
                skip: >-
                  The recipient step was skipped due to failure the rule set or
                  cap having been met
            retry_status:
              type: string
              enum:
                - started
                - completed
            vars:
              $ref: '#/components/schemas/RecipientVariables'
            step_id:
              type: string
              description: The id of the step in the flow associated with this event
            caps_reached:
              type: boolean
              description: One or more of the recipient caps were met
            key:
              type: string
              description: The property name on the event where appended data is stored
            cost:
              type: number
              format: double
              description: The amount paid for the purchase of this lead
            purchase_price:
              type: number
              format: double
              description: The amount paid for the purchase of this lead
            sale_price:
              type: number
              format: double
              description: The revenue received for the sale of this lead
            revenue:
              type: number
              format: double
              description: The difference between the purchase price and the sale price
            module_id:
              $ref: '#/components/schemas/ModuleID'
            credential:
              $ref: '#/components/schemas/Credential'
            credential_updated:
              type: boolean
              description: Whether the credential used by the integration was refreshed
            package_version:
              $ref: '#/components/schemas/SemanticVersion'
            rule_set:
              $ref: '#/components/schemas/rule-set'
              description: >-
                The rule set configured on the recipient step when the lead was
                processed 
            mappings:
              type: array
              description: The mappings applied while invoking the integration
              items:
                $ref: '#/components/schemas/Mapping'
            pricing:
              $ref: '#/components/schemas/Pricing'
              description: The pricing configuration applied to this recipient
            transactions:
              $ref: '#/components/schemas/Transactions'
            wait_ms:
              type: integer
              description: >-
                The number of milliseconds that LeadConduit spent waiting the
                recipient to respond
            total_ms:
              type: integer
              description: >-
                The number of milliseconds that elapsed since the lead was
                submitted 
    EventProperties:
      type: object
      description: >-
        An event tracks what happened with a lead at a particular step in a
        flow. An event is a self-contained snapshot of the state of the lead at
        the time the lead visited the step. It contains a full copy of all lead
        data, along with all data that was appended before that step. Every
        event contains the below properties.
      properties:
        id:
          $ref: '#/components/schemas/ID'
        outcome:
          type: string
          description: The outcome of the event
        reason:
          type: string
          description: The reason for a failure or error outcome
        vars:
          type: object
        host:
          type: string
        start_timestamp:
          description: >-
            The number of milliseconds elapsed since epoch at the start of the
            step processing
          type: integer
        end_timestamp:
          description: >-
            The number of milliseconds elapsed since epoch at the end of the
            step processing
          type: integer
        firehose:
          $ref: '#/components/schemas/Firehose'
        ms:
          description: The number of milliseconds that elapsed while processing the lead
          type: integer
        wait_ms:
          type: integer
          description: >-
            The number of milliseconds that LeadConduit spent waiting for all
            recipients to respond
        overhead_ms:
          description: >-
            The number of milliseconds of overhead that LeadConduit added while
            processing the step
          type: integer
        lag_ms:
          type: integer
        total_ms:
          type: integer
          description: The number of milliseconds that elapsed since the lead was submitted
        handler_version:
          $ref: '#/components/schemas/SemanticVersion'
          description: The version of the lead handler
        version:
          $ref: '#/components/schemas/SemanticVersion'
          description: The schema version of the event
        cap_reached:
          type: boolean
        flow_ping_limits:
          $ref: '#/components/schemas/PingLimit'
        source_ping_limits:
          $ref: '#/components/schemas/PingLimit'
        ping_limit_reached:
          type: boolean
        expires_at:
          $ref: '#/components/schemas/Timestamp'
          description: >-
            The time this event will be automatically deleted from LeadConduit
            (events are retained for 90 days)
      required:
        - id
        - type
        - outcome
        - reason
    SourceVariables:
      title: Source Variables
      description: |
        All data available at the time LeadConduit started processing this event
      type: object
      patternProperties:
        ^submission\.:
          $ref: '#/components/schemas/VariableSubmissionMetadata'
        ^account\.:
          $ref: '#/components/schemas/VariableAccountMetadata'
        ^flow\.:
          $ref: '#/components/schemas/VariableFlowMetadata'
        ^source\.:
          $ref: '#/components/schemas/VariableSourceMetadata'
        ^lead\.:
          $ref: '#/components/schemas/VariableLeadData'
      additionalProperties: false
    ModuleID:
      type: string
    SemanticVersion:
      type: string
      description: A <a href="http://semver.org" target="_blank">semantic version</a>
    acceptance-criteria:
      title: Acceptance Criteria
      type: object
      properties:
        rule_set:
          $ref: '#/components/schemas/rule-set'
          description: This rule set must pass in order for a lead to be accepted
        outcome:
          type: string
          description: >-
            When the rule set fails, `success`, `failure` or `error` is returned
            to the source that submitted the lead
          enum:
            - success
            - failure
            - error
          example: failure
        reason:
          $ref: '#/components/schemas/Template'
          description: >-
            When the outcome is `failure`, this is the reason to provide to the
            source
          example: Lead must live in TX
          type: string
      additionalProperties: false
      required:
        - outcome
        - rule_set
      description: >
        Acceptance criteria specifies the kinds of leads that a source or
        sources must provide in a flow. Acceptance criteria can be configured at
        both a flow level and a source level. When a source submits a lead, the
        flow-level acceptance criteria rule set is evaluated first, then any
        source-level acceptance criteria. If the rule sets pass, then the lead
        is allowed to progress on in the flow. But if either rule set fails,
        then the source is immediately given a response and no further
        processing takes place in the flow for that lead.
    HttpRequest:
      type: object
      properties:
        method:
          type: string
          description: HTTP request method
          enum:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
            - OPTIONS
          example: POST
        uri:
          type: string
          description: The full URI
          format: uri
          example: >-
            https://app.leadconduit.com/flows/5fd4371e940df5a34a3888b2/sources/6369a0e534c9d4ebe142e0ef/submit
        version:
          type: string
          description: The HTTP version used
          example: '1.1'
        headers:
          $ref: '#/components/schemas/Headers'
          description: The headers sent on the request
          example:
            Content-Type: application/json
            Accept: application/json
        body:
          type: string
          description: The contents of the request body
          example: '{"email":"johndoe@email.com","phone_1":"5127891111"}'
        timestamp:
          type: integer
          description: >-
            The number of milliseconds elapsed since epoch immediately prior to
            sending the request
      required:
        - method
        - uri
        - version
        - headers
        - body
        - timestamp
      additionalProperties: false
    HttpResponse:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
          example: 201
        status_text:
          type: string
          description: The textual representation of the status
          format: uri
          example: Created
        version:
          type: string
          description: The HTTP version used
          example: '1.1'
        headers:
          $ref: '#/components/schemas/Headers'
          description: The headers sent in the response
          example:
            Content-Type: application/json
            Accept: application/json
        body:
          type: string
          description: The contents of the response body
          example: '{"outcome":"success","lead":{"id":"63cc6f0e55254d7d1c4c3037"}}'
        timestamp:
          type: integer
          description: >-
            The number of milliseconds elapsed since epoch immediately after
            reading the response body
      required:
        - method
        - uri
        - version
        - headers
        - body
        - timestamp
    RecipientVariables:
      title: Recipient Variables
      description: >
        All data available at the time LeadConduit starts processing the
        recipient step. The following

        additional data will be added to the vars for the purposes of processing
        this step.

        * `price` — The price to be paid to the recipient

        * `purchase_price` - The cost of the lead paid to the source

        * `event_id` - The identifier of this event (so it can be sent to the
        recipient for feedback)

        * `recipient` — The `id` and `name` of the recipient
      type: object
      properties:
        price:
          type: number
          description: The price to be paid to the recipient
        purchase_price:
          type: number
          description: The cost of the lead paid to the source
        event_id:
          $ref: '#/components/schemas/ID'
          example: 636999a5a28de89048cd16fc
      patternProperties:
        ^recipient\.:
          $ref: '#/components/schemas/VariableRecipientMetadata'
        ^submission\.:
          $ref: '#/components/schemas/VariableSubmissionMetadata'
        ^account\.:
          $ref: '#/components/schemas/VariableAccountMetadata'
        ^flow\.:
          $ref: '#/components/schemas/VariableFlowMetadata'
        ^source\.:
          $ref: '#/components/schemas/VariableSourceMetadata'
        ^lead\.:
          $ref: '#/components/schemas/VariableLeadData'
        ^.+\.:
          $ref: '#/components/schemas/VariableAppendedData'
      additionalProperties: false
    Caps:
      description: >
        A cap controls the behavior by setting the maximum and the duration. The
        counter for a cap is kept as a standalone record which shares cap's ID.
      oneOf:
        - type: 'null'
        - type: array
          items:
            $ref: '#/components/schemas/Cap'
          minItems: 1
    Credential:
      x-tags:
        - Account
      type: object
      oneOf:
        - $ref: '#/components/schemas/UserCredential'
        - $ref: '#/components/schemas/TokenCredential'
        - $ref: '#/components/schemas/OauthCredential'
      properties:
        id:
          $ref: '#/components/schemas/ID'
          description: The ID of the credential which uniquely identifies it
        name:
          description: Friendly name for this credential
          type: string
        type:
          description: 'The type of model changes were performed on: user, token, oauth'
          type: string
        package:
          description: >-
            The name of the LeadConduit integration package to which this
            credential belongs
          type: string
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
    rule-set:
      x-tags:
        - Rules
      title: Rule Set
      type: object
      description: >
        A rule set is a collection of rules to evaluate. The `op` property
        determines whether all rules must pass (`and`) or just one of them must
        pass (`or`) in order for the rule set to be considered passing.
      properties:
        id:
          $ref: '#/components/schemas/ShortID'
          description: The ID of the rule set in this flow
          example: 0d144a
          readOnly: true
        op:
          type: string
          description: >-
            Determines whether all rules or just some rules must pass for the
            overall set to pass
          enum:
            - and
            - or
          x-enumDescriptions:
            and: All rules in the set must pass
            or: Only one rule in the set must pass
        rules:
          type: array
          description: >-
            The required rules to be evaluated. Rule sets may also be specified
            as array elements in order to achieve nesting.
          minItems: 1
          items:
            oneOf:
              - $ref: '#/components/schemas/binary-rule'
              - $ref: '#/components/schemas/unary-rule'
              - $ref: '#/components/schemas/rule-set'
      additionalProperties: false
      required:
        - op
        - rules
    Mapping:
      description: |
        A mapping is a rule-based translation that can be applied when a lead
        is submitted from a source or applied when submitting a lead to a
        recipient.
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ShortID'
          description: ID for this mapping
        property:
          description: The name of the variable to set
          type: string
          minLength: 1
        value:
          description: The value to set
          oneOf:
            - type: string
            - type: number
            - type: 'null'
            - type: array
              items:
                oneOf:
                  - type: string
                  - type: 'null'
              minItems: 1
        rule_set:
          $ref: '#/components/schemas/rule-set'
          description: Only apply the mapping if this rule set passes
      additionalProperties: false
      required:
        - property
        - value
    Pricing:
      description: |
        A pricing configuration determines the value of the `purchase_price`
        property on source events or the value of the `sale_price` property on
        recipient events. Consequently, it also determines the `cost` and
        `revenue` properties on source and recipient events. These properties
        can be reported on via the statistics API and the reporting API. If no
        pricing is configured, then the `purchase_price` and `sale_price`
        properties will be set to `0`.

        Pricing can be set on sources in a flow, the flow itself, or on any
        recipient step in a flow.

        A pricing is primarily an array of prices. Each price is evaluated and
        the last price for which all rules match will determine the amount used
        for the `purchase_price` or `sale_price`. If no prices match for a
        particular lead, the price properties will be set to `0`.

        If you wish the source or recipient to specify the price, then
        `override` property on the pricing must be set to `true`.  When
        `override: true`, the price properties on the associated event will be
        set to whatever amount is provided by the source or recipient. The
        `prices` array must be empty, null, or undefined if `override: true`.
      type: object
      properties:
        override:
          description: |
            Allows a source or a recipient to specify the price rather than
            relying on `prices`
          type: boolean
        prices:
          description: The list of prices to evaluate for each lead
          type: array
          items:
            $ref: '#/components/schemas/Price'
      additionalProperties: false
    Transactions:
      type: array
      description: A list of HTTP transactions that occurred while processing the lead
      items:
        type: object
        description: An HTTP transaction initiated by the integration
        properties:
          request:
            $ref: '#/components/schemas/HttpRequest'
            description: An HTTP request sent by the integration
          response:
            $ref: '#/components/schemas/HttpResponse'
            description: An HTTP response received by the integration
          ms:
            type: integer
            description: >-
              The number of milliseconds that elapsed between sending request
              and receiving the response
        required:
          - request
          - response
          - ms
    FilterVariables:
      title: Filter Variables
      description: |
        All data available at the time LeadConduit started processing this event
      type: object
      patternProperties:
        ^submission\.:
          $ref: '#/components/schemas/VariableSubmissionMetadata'
        ^account\.:
          $ref: '#/components/schemas/VariableAccountMetadata'
        ^flow\.:
          $ref: '#/components/schemas/VariableFlowMetadata'
        ^source\.:
          $ref: '#/components/schemas/VariableSourceMetadata'
        ^recipient\.:
          $ref: '#/components/schemas/VariableRecipientMetadata'
        ^lead\.:
          $ref: '#/components/schemas/VariableLeadData'
        ^.+\.:
          $ref: '#/components/schemas/VariableAppendedData'
      additionalProperties: false
    FeedbackVariables:
      title: Feedback Variables
      description: >
        All variables from the most recent event for the lead receiving
        feedback. Additionally contains

        feedback metadata at `feedback.`.
      type: object
      patternProperties:
        ^feedback\.:
          $ref: '#/components/schemas/VariableFeedbackMetadata'
        ^submission\.:
          $ref: '#/components/schemas/VariableSubmissionMetadata'
        ^account\.:
          $ref: '#/components/schemas/VariableAccountMetadata'
        ^flow\.:
          $ref: '#/components/schemas/VariableFlowMetadata'
        ^source\.:
          $ref: '#/components/schemas/VariableSourceMetadata'
        ^recipient\.:
          $ref: '#/components/schemas/VariableRecipientMetadata'
        ^lead\.:
          $ref: '#/components/schemas/VariableLeadData'
        ^.+\.:
          $ref: '#/components/schemas/VariableAppendedData'
      additionalProperties: false
    Feedback:
      description: |
        Feedback specifies the configuration for receiving and sending feedback
        about a lead. When receiving feedback from a recipient, the `rule_set`
        must pass. If it does not, a "failure" Feedback Received Event is
        created. When sending feedback to a source, the `rule_set` must pass. If
        it does not, a " skip" Feedback Sent Event is created.
      properties:
        rule_set:
          $ref: '#/components/schemas/rule-set'
          description: If the rules fail the feedback is not performed
        integration:
          $ref: '#/components/schemas/Integration'
          description: The integration to be used for the feedback
      additionalProperties: false
      required:
        - integration
    Firehose:
      type: object
      properties:
        credential_id:
          $ref: '#/components/schemas/ID'
          description: >-
            The ID of the credential storing the cloud storage credentials
            (legacy - used when services are not specified)
        enabled:
          type: boolean
          description: Is the firehose enabled for this flow?
        bucket:
          type: string
          description: >-
            The name of the s3 bucket (legacy - used when services are not
            specified)
        prefix:
          type: string
          description: >-
            Optional. If provided, files written to s3 will be written as
            &lt;prefix>/&lt;lead id>/&lt;event id>.json (legacy - used when
            services are not specified)
        services:
          type: object
          description: Service-specific configurations for cloud storage providers
          properties:
            aws:
              type: object
              description: AWS S3 service configuration
              properties:
                enabled:
                  type: boolean
                  description: Whether AWS S3 service is enabled
                credential_id:
                  $ref: '#/components/schemas/ID'
                  description: The ID of the credential storing the AWS access keys
                bucket:
                  type: string
                  description: The name of the S3 bucket
                  pattern: >-
                    ^(?=^.{3,63}$)(?!^(\d+\.?)+$)(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9]))$
                prefix:
                  type: string
                  description: >-
                    Optional prefix for files stored in S3. If provided, files
                    written to s3 will be written as &lt;prefix>/&lt;lead
                    id>/&lt;event id>.json
              additionalProperties: false
            azure:
              type: object
              description: Azure Blob Storage service configuration
              properties:
                enabled:
                  type: boolean
                  description: Whether Azure Blob Storage service is enabled
                credential_id:
                  $ref: '#/components/schemas/ID'
                  description: The ID of the credential storing the Azure connection string
                bucket:
                  type: string
                  description: The name of the Azure container (equivalent to S3 bucket)
                prefix:
                  type: string
                  description: >-
                    Optional prefix for files stored in Azure Blob Storage. If
                    provided, files written to azure blob container will be
                    written as &lt;prefix>/&lt;lead id>/&lt;event id>.json
              additionalProperties: false
          additionalProperties: false
      additionalProperties: false
    PingLimit:
      x-tags:
        - Caps and Limits
      title: Ping Limit
      description: >-
        The ping limit configuration is defined in a flow on a source, or
        directly on the flow itself. The configuration controls the behavior of
        the ping limit by setting the maximum and the duration. The counter for
        a ping limit is kept as a standalone record which shares ping limit's
        ID.
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ID'
        name:
          type: string
          description: The human-readable name of the ping limit
        maximum:
          type: integer
          description: The number of pings that will be accepted
        duration:
          type: integer
          description: The number duration_units the ping limit persists for
        duration_units:
          type: string
          description: >-
            The unit of time the ping limit persists for: minute, hour, day,
            week, or month
        time_zone:
          type: string
          description: The time zone in which ping limit resets
          example: America/New_York
        created_at:
          $ref: '#/components/schemas/Timestamp'
          description: Read-only time the ping limit was created
          readOnly: true
    Template:
      type: string
      title: Template
    Headers:
      type: object
      patternProperties:
        '[A-Za-z0-9_\\-~\\{\\}]+':
          type: string
          minLength: 1
      additionalProperties: false
    Cap:
      x-tags:
        - Caps and Limits
      type: object
      description: >
        A cap allows limiting the number of leads sent into or out of a flow. 

        If a lead is successful, it will be counted against the maximum
        configured leads. 

        If configured, the rule set will be evaluated to determine whether a
        lead will be counted against the cap.
      properties:
        id:
          $ref: '#/components/schemas/ID'
          description: ID of this cap
          example: 5fd438f91f0d12766e2bfee5
        type:
          type: string
          description: >-
            The type of this cap (LeadConduit may eventually support different
            types of caps)
          enum:
            - volume
        name:
          description: The human-readable name of the cap
          type: string
          example: Monthly leads from TX
        maximum:
          type: number
          description: The number of successful leads that will be accepted
          example: 1200
        duration:
          type: number
          description: The number duration_units for which the cap persists
          minimum: 1
          examples:
            - 1
        duration_units:
          type: string
          description: The unit of time for which the cap persists
          enum:
            - month
            - week
            - day
            - hour
            - minute
        rule_set:
          $ref: '#/components/schemas/rule-set'
          description: >-
            This rule set must pass in order for the lead to count against the
            cap
        caps:
          description: Nested caps evaluated if rules for the parent cap pass
          type: array
          items:
            $ref: '#/components/schemas/Cap'
        time_zone:
          description: The time zone in which cap resets
          type: string
          example: America/New_York
        reason:
          $ref: '#/components/schemas/Template'
          description: 'When the cap is met this is the reason (default: ''Cap reached'')'
        created_at:
          description: Read-only time the cap was created
          type: string
          format: date-time
          example: '2020-11-23T11:41:52Z'
    UserCredential:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ID'
          description: The ID of the credential which uniquely identifies it
        name:
          description: Friendly name for this credential
          type: string
        type:
          description: 'The type of model changes were performed on: user, token, oauth'
          type: string
          enum:
            - user
        package:
          description: >-
            The name of the LeadConduit integration package to which this
            credential belongs
          type: string
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        username:
          description: The username to user for basic authentication
          type: string
          minLength: 1
        password:
          description: The password to user for basic authentication
          type: string
          minLength: 1
      required:
        - id
        - name
        - type
        - package
        - username
        - password
      additionalProperties: true
    TokenCredential:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ID'
          description: The ID of the credential which uniquely identifies it
        name:
          description: Friendly name for this credential
          type: string
        type:
          description: 'The type of model changes were performed on: user, token, oauth'
          type: string
          enum:
            - token
        package:
          description: >-
            The name of the LeadConduit integration package to which this
            credential belongs
          type: string
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        token:
          description: The access token to use to with type token
          type: string
          minLength: 1
      required:
        - id
        - name
        - type
        - package
        - token
      additionalProperties: true
    OauthCredential:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ID'
          description: The ID of the credential which uniquely identifies it
        name:
          description: Friendly name for this credential
          type: string
        type:
          description: 'The type of model changes were performed on: user, token, oauth'
          type: string
          enum:
            - oauth1
            - oauth2
        package:
          description: >-
            The name of the LeadConduit integration package to which this
            credential belongs
          type: string
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        access_token:
          description: The OAuth access token to use to connect
          type: string
          minLength: 1
        refresh_token:
          description: The OAuth refresh token to use to get a new access token
          type: string
          minLength: 1
        user:
          description: The user the credential belongs to.
          type: object
          properties:
            id:
              type: string
            username:
              type: string
            first_name:
              type: string
            last_name:
              type: string
            email:
              type: string
            phone:
              type: string
        org:
          description: The organization the credential belongs to
          type: object
          properties:
            id:
              type: string
            type:
              type: string
            name:
              type: string
            prefix:
              type: string
        expires_at:
          description: The time epoch seconds at which the token will expire
          type: integer
          format: int64
      required:
        - id
        - name
        - type
        - package
        - access_token
      additionalProperties: true
    ShortID:
      type: string
      pattern: ^[0-9a-zA-Z]{6}$
      example: 1aacd0
      readOnly: true
    binary-rule:
      title: Binary Rule
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ShortID'
          description: ID for this rule
          example: 1aacd0
        lhv:
          type: string
          description: >-
            The required left-hand value to be evaluated
            ([templating](/docs/leadconduit/api/tag/Templates/) is supported)
          example: lead.state
        op:
          type: string
          enum:
            - is equal to
            - is not equal to
            - is less than
            - is less than or equal to
            - is greater than
            - is greater than or equal to
            - is included in
            - is not included in
            - includes
            - does not include
            - is between
            - is not between
            - matches pattern
            - does not match pattern
          example: is equal to
          x-enumDescriptions:
            is equal to: >-
              Is the
              [string](/docs/leadconduit/api/tag/Types/#tag/Types/section/String)
              (case-insensitive),
              [number](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number),
              or
              [range](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `lhv` equal to the `rhv`?
            is not equal to: Inverse of the `is equal to` operator.
            is less than: >-
              Is the
              [numeric](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number)
              or [range
              average](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `lhv` numerically less than the `rhv`?
            is less than or equal to: >-
              Is the
              [numeric](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number)
              or [range
              average](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `lhv` numerically less than or equal to the `rhv`?
            is greater than: >-
              Is the
              [numeric](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number)
              or [range
              average](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `lhv` numerically more than the `rhv`?
            is greater than or equal to: >-
              Is the
              [numeric](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number)
              or [range
              average](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `lhv` numerically more than or equal to the `rhv`?
            is between: >-
              Is the
              [numeric](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number)
              or [range
              average](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `lhv` between the `rhv`
              [range](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `min` and `max` (inclusive)?
            is not between: >-
              Is the
              [numeric](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number)
              or [range
              average](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `lhv` outside the `rhv`
              [range](/docs/leadconduit/api/tag/Types/#tag/Types/section/Range)
              `min` and `max` (exclusive)?
            is included in: >-
              Is the
              [string](/docs/leadconduit/api/tag/Types/#tag/Types/section/String),
              [number](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number),
              or
              [boolean](/docs/leadconduit/api/tag/Types/#tag/Types/section/Boolean)
              `lhv` included in the Array of values provided in the `rhv`?
            is not included in: >-
              Is the
              [string](/docs/leadconduit/api/tag/Types/#tag/Types/section/String),
              [number](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number),
              or
              [boolean](/docs/leadconduit/api/tag/Types/#tag/Types/section/Boolean)
              `lhv` missing from the Array of values provided in the `rhv`?
            includes: >-
              Does the Array of
              [strings](/docs/leadconduit/api/tag/Types/#tag/Types/section/String),
              [numbers](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number),
              or
              [booleans](/docs/leadconduit/api/tag/Types/#tag/Types/section/Boolean)
              provided in the `lhv` contain the `rhv`?
            does not include: >-
              Is the Array of
              [strings](/docs/leadconduit/api/tag/Types/#tag/Types/section/String),
              [numbers](/docs/leadconduit/api/tag/Types/#tag/Types/section/Number),
              or
              [booleans](/docs/leadconduit/api/tag/Types/#tag/Types/section/Boolean)
              provided in the `lhv` missing the `rhv`?
          description: |
            Binary operators compare the `lhv` and the `rhv`.
        rhv:
          oneOf:
            - type: string
            - type: number
            - type: boolean
            - type: array
              items:
                type: string
          description: >-
            The right-hand value to be evaluated
            ([templating](/docs/leadconduit/api/tag/Templates/) is supported)
          example: TX
        rule_set:
          $ref: '#/components/schemas/rule-set'
      additionalProperties: false
      required:
        - lhv
        - op
        - rhv
    unary-rule:
      title: Unary Rule
      type: object
      properties:
        id:
          $ref: '#/components/schemas/ShortID'
          description: ID for this rule
        lhv:
          type: string
          description: >-
            The value to be evaluated
            ([templating](/docs/leadconduit/api/tag/Templates/) is supported)
          example: lead.email
        op:
          type: string
          enum:
            - is blank
            - is not blank
            - is true
            - is false
            - is not true
            - is not false
            - format is valid
            - format is invalid
            - is obscene
            - is not obscene
          x-enumDescriptions:
            is blank: Is the `lhv` missing or empty?
            is not blank: Does the `lhv` contain a value?
            is true: Does the `lhv` evaluate to `true`?
            is false: Does the `lhv` evaluate to `false`?
            format is valid: >-
              The `lhv` was successfully interpreted as a value of its specified
              type.
            format is invalid: >-
              The `lhv` could not be interpreted as a value of its specified
              type.
            is obscene: Does the `lhv` contain obscene language?
            is not obscene: Does the `lhv` contain no obscene language?
          example: is not blank
          description: |
            Unary operators evaluate the `lhv`.
        rule_set:
          $ref: '#/components/schemas/rule-set'
      additionalProperties: false
      required:
        - lhv
        - op
    Price:
      description: |
        A price determines the `purchase_price` or `sale_price` for a lead. If
        all rules in the `rule_set` pass, then the appropriate price property
        will be set equal to the `amount`. When more than one price is
        specified, the last matching price will be used to set the price
        property on the event.
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Price'
          description: |
            ID of this counter (matches the ID of the corresponding cap
            configuration)
        amount:
          description: The price of the lead in USD
          type: number
          exclusiveMinimum: 0
        rule_set:
          $ref: '#/components/schemas/rule-set'
          description: |
            The rule set which must pass in order for this price to be
            considered
      required:
        - amount
      additionalProperties: false
    Integration:
      type: object
      properties:
        module_id:
          $ref: '#/components/schemas/ModuleID'
          description: |
            A pointer to the integration code to use for this integration
        mappings:
          description: |
            The mappings to apply to lead data when interacting with this
            integration
          type: array
          items:
            $ref: '#/components/schemas/Mapping'
      additionalProperties: false
      required:
        - module_id
  securitySchemes:
    APIKey:
      type: http
      scheme: basic
      description: >
        LeadConduit uses [HTTP Basic
        Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication)

        with the username `API` and your API key as the password.


        For example: `API:1f1b96c9150d8050e858c043d543bb4eadae0e6f`'

````