The Search API allows customers to lookup form submissions by email address, phone number or Reference Number.

The Search API

The Search API1 returns the same information about form responses as the Search page.

  • To look up form responses2 associated with an email address or phone number for a specific form, pass its ID in the form_id parameter and submit a GET request
  • To search for all form entries2 associated with an email address or phone number, submit a GET request without specifying a Form ID
  • To retrieve the latest form responses, submit a query with the latest command. Use the form_id parameter to limit results to a specific form.
  • Use the tags and system_tags parameters to filter form responses matching specific tags or system tags.
API Endpoint
https://formsmarts.com/api/v1/entries/search
HTTP Method
GET
ParameterDescriptionNotes
query The value to search for. See Supported Query Values below. Required
form_id A Form ID. If the URL of a form is https://f8s.co/1nk5, it's ID is 1nk5 Optional. If omitted, returns matches for all your forms.
tags A comma-separated list of tags. If a tag filter is specified, only form responses matching all tags are returned. Optional
system_tags A comma-separated list of system tags. If a system tag filter is specified, only form submissions matching all system tags are returned. Optional
limit The maximum number of form responses to return Optional. 50 by default.
offset An offset to return partial results, ie: 5 will return results 6 to the value of the limit parameter. Optional. 0 by default.

Supported Query Values

The query parameter accepts the following values:

  • Email address — returns all submissions containing that email address2
  • Phone number — returns all submissions containing that phone number2
  • Reference Number — returns the specific form submission identified by that FormSmarts Reference Number
  • Stripe Payment ID — returns the submission associated with that Stripe payment (for forms with Stripe payment)
  • PayPal Transaction ID — returns the submission associated with that PayPal transaction (for forms with PayPal payment)
  • PayPal Subscription ID — returns submissions associated with that PayPal subscription
  • PayPal Invoice ID — returns the submission associated with that PayPal invoice ID as shown on PayPal
  • latest — returns the most recent form submissions. Use the form_id parameter to limit results to a specific form.

API Response

If the request is successful, the API returns an HTTP 200 status and a list of JSON objects with the form submissions matching the email address or phone number specified in the query parameter.

The JSON objects returned currently include:

  • The Reference Number of the form response, which you can then use to retrieve the complete form response with the Form Response API.
  • The date the form was submitted as a UTC timestamp

If you search form responses across all your forms (form_id parameter unset), the responses also include:

  • The ID of the form
  • The name of the form

Example

This is a sample API response:

[
   {
      "reference_number":"1GZCTWIGK8E5HYPIK0RPMIJT7",
      "date_submitted":"2017-04-29 03:22:21",
      "form_id":"1nk5",
      "form_name":"E-Signature Demo"
   },
   {
      "reference_number":"94JSBKMURKW3UTOMVGA0SPWLK",
      "date_submitted":"2017-04-26 11:17:50",
      "form_id":"k2a",
      "form_name":"Multimedia Projector Booking Form"
   }
]

If the request fails, the API returns a non-success HTTP status with a JSON object specifying the error.

Authentication

FormSmarts verifies API requests with a JWT token in the Authorization header. You can sign requests with the FormSmarts API Client or a JWT library in your favorite programming language. You'll need to know your FormSmarts Account ID and secret FormSmarts API Key.

You'll find your Account ID in the Account Overview section of your account and your API Key in the Security Settings.

Python Example

The easiest way to use the Search API is with the API & Webhook Client, which provides a Python interface to FormSmarts services. Install it with pip:

pip install formsmarts

The example below searches for all submissions to a specific form matching an email address. Credentials are read from environment variables — never hard-code them in your source.


import os
from formsmarts import APIAuthenticator, FormEntry

auth = APIAuthenticator(os.environ['FS_ACCOUNT_ID'], os.environ['FS_API_KEY'])

for entry in FormEntry.search(auth, form_id='lqh', query='example@example.com'):
    print(entry.reference_number, entry.submitted_at)

Omit form_id to search across all your forms, or pass query='latest' to retrieve the most recent submission. See the API Client documentation for the full list of options.

If you prefer to call the API directly with an HTTP library or another programming language, here is an equivalent example:


import os
import json
import requests
from formsmarts import APIAuthenticator

FORM_ID = 'lqh'
API_URL = 'https://formsmarts.com/api/v1/entries/search'

auth = APIAuthenticator(os.environ['FS_ACCOUNT_ID'], os.environ['FS_API_KEY'])

resp = requests.get(API_URL, params={'form_id': FORM_ID, 'query': 'example@example.com'},
                    headers={APIAuthenticator.AUTH_HEADER: auth.get_authorization_header()})
if resp.status_code == 200:
    print(resp.json())
else:
    print('Error {}: {}'.format(resp.status_code, resp.text))

Node.js Example

The Form Submission API has a Node.js example.


  1. Not available with Business Starter and Plus accounts
  2. Search by email address or phone number are delayed by up to fifteen minutes