Lead Entry API

In this article:

Appendix

What is the Lead Entry API?

Reduce duplicate data entry, and increase your team's efficiency with a Leads API integration. This allows you to create new leads in SingleOps from an outside system. 

This will require some technical know-how on your end. If that is not available to your team, you can use our Client Portal for Lead Entry from your website! Learn more here

 

Technical Requirements

  1. Technical resource on your team to connect, troubleshoot, and maintain the connection.
    *Note: SingleOps provides steps to request an API Token. All integration and maintenance is managed on your end. 
  2. You will need an API Access Token. Contact support (support@singleops.com) to create a new API User on the Account you wish to create Leads on and note the Email Address and API Token. This user will not incur any additional costs. API access may not be available on all pricing tiers. 

 

SingleOps API (Customers, Leads, Tasks)

The SingleOps API documentation below covers customer, lead, and task entry/creation. Leads created through the process detailed here will follow the Customer Portal workflow (requiring manual confirmation before a client/location is considered valid).

 

URL Patterns and Credentials

Account Groups

Each account must have its own unique API user. API users are unable to make API calls to other accounts in their account group even if the user has access to the other account. These are just passed as parameters on the request:

Auth Parameters

These are passed as part of the message body.  GET requests also support passing them as URL parameters.

user_email: <API user’s email address>
user_token: <API user’s secret token - must request>

 

Example GET request with URL parameters:

curl -X 'GET' \

  'https://app.singleops.com/api/v1/custom_inputs?user_email=<API user’s email address>&user_token=<API user’s secret token>' \

  -H 'accept: application/json'

 

In Browser testing

For testing GET requests you can use your regular user cookie to access the API endpoints with 2 caveats:

  • Requests must be made over HTTPS
  • You must currently be viewing the correct account for your user. If you have an account group and are currently looking at a different account in app you must switch to your “home” account before you can access that account’s data

 

Referenced Entities

The first two requests are to get entities whose IDs are needed for each lead: custom input and operation. Our preference would be that these IDs are cached but the API consumer can request them for each lead created.

Operations

Operations represent the division that this lead will be for. This is a required field for leads, but can be modified subsequently if it is mis-classified.
URL: https://app.singleops.com/api/v1/operations
No additional params needed.
Response

[
  {
      "id": 1234,
      "name": "Main",
      "active": true,
      "tax_location_id": null,
      "display_name": null,
      "location_id": null,
      "location": {}
  },
  {
      "id": 1235,
      "name": "Other",
      "active": true,
      "tax_location_id": null,
      "display_name": null,
      "location_id": null,
      "location": {}
  }
]

 

Custom Inputs

Custom Inputs are fields that accounts can specify to retain additional information about leads, jobs, clients, items, etc.
URL: https://app.singleops.com/api/v1/custom_inputs
Response

[
  {
      "id": 123,
      "name": "Lead Source",
      "order": null,
      "placeholder": "",
      "input_type": "dropdown",
      "resource_type": "job",
      "important": false,
      "required": false,
      "searchable": false,
      "display_on_show": false,
      "include_in_global_search": false,
      "available_accross_account_group": false,
      "section_name": "",
      "operations": [],
      "dropdown_options": [
          {
              "key": "Email",
              "display": "Email",
              "order": null
          },
          {
              "key": "Mailer",
              "display": "Mailer",
              "order": null
          },
          {
              "key": "Phone",
              "display": "Phone",
              "order": null
          }
      ]
  }
]

The “dropdown_options” can be ignored. This is to provide a list of dropdown options that a custom input supports, but since the lead source for your use case should all be the same this won’t be needed.

 

Client search

The next request is to search for clients by email and phone number. This is to find a matching existing client, if possible, for the lead.
There are two additional params for the client search request. Search field allows you to specify whether you want to search by email or phone number. Please note that this is a prefix search. Sometimes clients will append multiple phone numbers or extensions, so we wanted to allow those to be caught as well.
This example only returns one result, but it can return anywhere from 0 to 50. Additional pages are available using a “page” parameter.
URL: https://app.singleops.com/api/v1/clients/search_by_field

search_field: "email" or "phone"
search_term: [email or phone number]

Response

[
  {
      "id": 12345,
      "account_id": 123,
      "location_id": null,
      "name": "Example Client",
      "active": true,
      "user_id": null,
      "created_at": "2020-12-13T15:09:22.000-05:00",
      "updated_at": "2020-12-13T15:09:22.000-05:00",
      "is_archived": false,
      "is_property": null,
      "is_new": false,
      "qb_list_id": null,
      "email": "support@singleops.com",
      "bill_addr_city": "",
      "bill_addr_state": "",
      "bill_addr_postal_code": "",
      "bill_addr_country": null,
      "bill_addr_1": "",
      "bill_addr_2": "",
      "bill_addr_3": "",
      "bill_addr_4": null,
      "bill_addr_5": null,
      "phone": "555-555-5555",
      "mobile": "",
      "fax": "",
      "term_id": null,
      "qbo_id": null,
      "qbo_status_cd": 0,
      "qbo_error_code": null,
      "company_name": "",
      "display_name": null,
      "notes": "",
      "default_operation_id": null,
      "default_sales_tax_location_id": null,
      "default_sales_tax_category": null,
      "skip_qb_sync": false,
      "customer_type_id": null,
      "first_name": "Test",
      "last_name": "Search",
      "middle_name": "",
      "notice_level_cd": 4,
      "notice_text": "",
      "qbwc_edit_sequence": null,
      "qbwc_status_cd": null,
      "merged_to_client_id": null,
      "default_credit_card_alias_id": null,
      "token": "<secret token>",
      "exclude_save_cc_info": false,
      "portal_active": true,
      "autopay_enabled": null,
      "qb_balance": 0.0,
      "qb_balance_last_updated": null,
      "portal_entered": false,
      "portal_confirmed": null,
      "anonymous": false,
      "last_qbwc_error_id": null,
      "ag_import_created": false,
      "qbo_retry_count": null,
      "on_hold": false
  }
]
At this point, you should have all the information you need to create a lead. There are two possible ways to create a lead, one in which you have identified an existing client and another if you believe your lead is for a new client.

 

Create a Lead 

For An Existing Client: 

URL: https://app.singleops.com/api/v1/jobs
Request should be a POST and the body should be JSON:

{
    "user_email": "<API user’s email address>",
    "user_token": "<API user’s secret token>",
    "job": {
        "client_id": 12345,
        "operation_id": 123,
        "name": "Example Lead",
        "job_notes": "Here are notes that are internal.",
        "client_notes": "Here are notes that the client can see.",
        "crew_notes": "Here are notes that are on the work order.",
        "custom_input_values": [
            {
                "custom_input_id": 123,
                "value": "Email"
            }
        ]

     },
    "portal_lead": {
        "address": "101 Test Ave",
        "city": "Atlanta",
        "us_state": "GA",
        "zip": "30339"
    },

     "visit": {

       "visit_stage_id": 8

   }
}

Response 

The response will indicate whether the lead was created or not, along with the id of created lead: 

{

      "success":true,

      "error":null,

      "id":123456

}

 

For A New Client

URL: https://app.singleops.com/api/v1/jobs
Request should be a POST and the body should be JSON. Note that client_id for “job” is empty in this example. Instead the new client details are put under the “portal lead” section and can include phone number, email and mobile number.:

{
  "user_email": "<API user’s email address>",
  "user_token": "<API user’s secret token>",
  "job": {
      "operation_id": 916,
      "name": "Example Lead",
      "job_notes": "Here are notes that are internal.",
      "client_notes": "Here are notes that the client can see.",
      "crew_notes": "Here are notes that are on the work order.",
      "custom_input_values": [
          {
              "custom_input_id": 463,
              "value": "Email"
          }
      ]

   },
  "portal_lead": {
      "first_name": "Example",
      "last_name": "Lead",
      "company_name": "LeadCo LLC",
      "email": "new-lead@example.com",
      "phone": "555-555-5555",
      "address": "101 Test Ave",
      "city": "Atlanta",
      "us_state": "GA",
      "zip": "30305",

       "bill_addr_1": "200 Main St",

       "bill_addr_2": "Apt 2B",

       "bill_addr_state": "GA",

       "bill_addr_postal_code": "30367",

       "bill_addr_city": "Marietta"
  },

   "visit": {

       "visit_stage_id": 8

   }

}

 

 

For a New Task

To create a new Task when a new Lead is created, we must add the appropriate task related fields to the POST JSON body. “job_task_create” must be set to true and the “task” Object must be provided. 

{
  "user_email": "<API user’s email address>",
  "user_token": "<API user’s secret token>",
  "job": {
      "operation_id": 916,
      "name": "Example Lead",
      "job_notes": "Here are notes that are internal.",
      "client_notes": "Here are notes that the client can see.",
      "crew_notes": "Here are notes that are on the work order.",
      "custom_input_values": [
          {
              "custom_input_id": 463,
              "value": "Email"
          }
      ]

   },
  "portal_lead": {
      "first_name": "Example",
      "last_name": "Lead",
      "company_name": "LeadCo LLC",
      "email": "new-lead@example.com",
      "phone": "555-555-5555",
      "address": "101 Test Ave",
      "city": "Atlanta",
      "us_state": "GA",
      "zip": "30305",

       "bill_addr_1": "200 Main St",

       "bill_addr_2": "Apt 2B",

       "bill_addr_state": "GA",

       "bill_addr_postal_code": "30367",

       "bill_addr_city": "Marietta"
  },

   "visit": {

       "visit_stage_id": 8

   },

   "job_task_create": true,

   "task": {

      "name": "Task name",

      "notes": "Internal Notes from Lead",

      "on_site": true,

      "start": "2021-10-10 07:00:00",

      "stop": "2021-10-10 07:30:00",

      "all_day": false

   }

}

 

Response 

The response will indicate whether the lead was created or not, along with the id of created lead: 

{

      "success":true,

      "error":null,

      "id":148830

}

 

Appendix

Field Information:

Job:

name: 41 characters

notes: 4000 characters 

            Custom Field Value: 4000 characters

Portal Lead:

           first_name: 255 characters

           last_name: 255 characters 

           company_name: 255 characters

           email: 255 characters

           phone: 255 characters

           mobile: 255 characters

           address: 255 characters

           city: 255 characters

           state: 5 characters (State / Province codes)

           zip: 255 characters

Task:

job_task_create: true or false

task.name: 41 characters 

            task.notes: 4000 characters

task.on_site: true or false

task.start: DateTime

task.stop: DateTime

task.all_day: true or false

 

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.