CIOPulse Knowledge Base

3.1 Relationship Surveys API v5

Updated on

By using the Relationship Surveys API endpoint you can:

  • Add or edit a Relationship Survey with an HTTP PUT request and providing the Relationship Survey's information as a JSON payload.
  • Delete a Relationship Survey using an HTTP DELETE request.
  • Retrieve Relationship Survey information for one or all Relationship Surveys using an HTTP GET request.

A common use of the Relationship Surveys endpoint is to add Relationship Surveys for projects in your customer support or project management software.

The API returns data in JSON format which is readily decodable by all modern programming languages.

To use the API you must be on our Corporate or Enterprise Plan and have a 40 character API key. The key can be found in the Portal at the bottom of the Preferences page. If your key is blank, please email us at [email protected].

If you have setup IP address security in the CIOPulse Portal, the IP address of the server making the API call must be included in your list of valid IP addresses.

Authentication

All our API endpoints require HTTP basic authentication as specified in RFC 7616 from 2015. The HTTP Header of your request must contain a header field in the form of:

Authorization: Basic {credentials}

Where {credentials} is the Base64 encoding of: your Client Portal Code, a single colon, and your API Key (found in the Preferences of the Portal).

Here's a snippet of PHP script using CURL to set the authentication header.

$portal_code = 'ABC123'; 
$api_key = 'SMzYECYJYLpNw8PrfX8EtPO2tcP0XaKJvZ4FW5VL';

$header = array('Authorization: Basic '. base64_encode($portal_code .":". $api_key) );

$curl_session = curl_init();
curl_setopt($curl_session, CURLOPT_HTTPHEADER, $header);

Adding or Updating Relationship Surveys

To use the Relationship Surveys endpoint to add or edit a Relationship Survey, issue an HTTP PUT request with this URL:

https://app.cio-pulse.com/api/v5/relationship-surveys/{system_id}

{system_id} is a unique identifier for the Relationship Survey you are adding or updating, e.g. the Unique ID of the Project from your customer support or project management software. This is often the same as the relationship_survey_code, but it doesn't have to be.

Your PUT request must be accompanied by a JSON payload that carries the field values for the Relationship Survey you wish to add or update.

The JSON payload may only contain information for a single Relationship Survey and looks like this:

{
"survey_name": "CRM Version 3 Upgrade Project",
"survey_code": "project123",
"invitation_count": 150,
"close_date_gmt": "2021-02-28",
"survey_series_code": "projects"
}

If you don't want the Relationship Survey to be linked to a Survey Series, either:

  • Use null in the JSON for survey_series_code. Do not surround null with quotes. null must be in lowercase. 
  • Or, leave out this field altogether.

The fields allowed in the JSON payload are:

  • survey_name is the name of the Relationship Survey.
  • survey_code is the unique Relationship Survey Code that can be used in the rsid= parameter when requesting a Relationship Survey Responses report or viewing a relationship survey dashboard.
  • invitation_count is the number of people you are inviting to complete the survey.
  • close_date_gmt is the close date of the survey (GMT) in yyyy-mm-dd format. Surveys received after this date will not be used for calculating the NPS for this survey.
  • survey_series_code is the Series Code of the Series you wish this Survey to be part of.  If you don't want this Relationship Survey to be linked to a Series, use null. Do not surround null with quotes. null must be in lowercase.

The Relationship Survey API endpoint behaves as follows:

  • If a Relationship Survey with this system_id is NOT found in the Portal, a new Relationship Survey will be added using the values in the JSON payload.
  • If a Relationship Survey with this system_id IS found in the Portal, the existing Relationship Survey will be updated using the values in the JSON payload.

Add &clean to the end of your URL and any invalid characters in the relationship_survey_name (e.g. em dashes or colons) will be replaced with hyphens when the Relationship Survey is added or updated.

Your JSON must never include a backslash (\) anywhere within it. Backslashes will prevent your API call from working.

Adding a new Relationship Survey

If a Relationship Survey with this system_id is not found in the Portal, a new Relationship Survey will be added using the values in the JSON payload.

The following fields are mandatory in the JSON when adding a new Relationship Survey:

  • survey_name
  • survey_code
  • invitation_count
  • close_date_gmt

The following field is optional in the JSON when adding a new Relationship Survey:

  • survey_series_code  (defaults to null when omitted).

Here's a snippet of PHP script using CURL to add a new Relationship Survey:

$portal_code = 'ABC123'; 
$api_key = 'SMzYECYJYLpNw8PrfX8EtPO2tcP0XaKJvZ4FW5VL';

$payload_json = '{   
	"survey_name": "CRM Version 3 Upgrade Project",
	"survey_code": "project123",
	"invitation_count": 150,
	"close_date_gmt": "2021-02-28",
	"survey_series_code": "projects"
}';

$headers = array(
	'Authorization: Basic '. base64_encode($portal_code .":". $api_key),
	'Content-Type:application/json',
	'Content-Length: ' . strlen($payload_json)
);
	
$curl_session = curl_init();

curl_setopt($curl_session, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl_session, CURLOPT_POSTFIELDS,$payload_json);
curl_setopt($curl_session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl_session, CURLOPT_URL, 'https://app.cio-pulse.com/api/v5/relationship-surveys/project123');

curl_exec($curl_session);

Note that, in this example, the System ID (used in the URL) and the Survey Code (used in the JSON payload) are the same.

Updating a Relationship Survey

If a Relationship Survey with this system_id is found in the Portal, the existing Relationship Survey will be updated.

When updating a Relationship Survey, each of the fields allowed in the JSON may be set to a value, to null (survey_series_code only), or the field can be omitted from the JSON altogether:

  • Set to value - Update the field to this value.
  • Set to null - Set the Survey Series to 'No Series'.
  • Omitted - Leave the current field value unchanged.

For example, this JSON payload would update the Relationship Survey Name, remove the Survey from a Series and leave all other fields unchanged:

{"survey_name": "This is a new name for this survey",
	"survey_series_code": null}

When setting survey_series_code to null, use null in the JSON. Do not surround null with quotes. null must be in lowercase. 

Deleting a Relationship Survey

To use the Relationship Surveys endpoint to delete a Relationship Survey, issue an HTTP DELETE request with this URL:

https://app.cio-pulse.com/api/v5/relationship-surveys/{system_id}

{system_id} is a unique identifier for the Relationship Survey you are deleting.

The Relationship Survey to be deleted must not have any Survey Responses completed for it.

Retrieving Relationship Survey information

To use the Relationship Surveys endpoint to get the information for a single Relationship Survey, issue an HTTP GET request with this URL:

https://app.cio-pulse.com/api/v5/relationship-surveys/{system_id}

{system_id} is a unique identifier for the Relationship Survey you wish to retrieve information for.

To use the Relationship Surveys endpoint to get the information for all Relationship Surveys, issue an HTTP GET request without the system id:

https://app.cio-pulse.com/api/v5/relationship-surveys

A normal response will result in an HTTP response code of 200 being returned in the header.

The Relationship Survey information returned by the API looks like this (which shows 3 Relationship Surveys):

{"relationship_surveys":[

{"relationship_survey":{"Relationship_Survey_System_ID":"sysid-001","Survey_Code":"TEST001",
"Survey_Name":"Survey 123",
"Series_Code":"NONE","Series_Name":"No Series",
"Invitation_Count":99,"Close_Date_GMT":"2021-12-31"}},

{"relationship_survey":{"Relationship_Survey_System_ID":"sysid-002","Survey_Code":"TEST002",
"Survey_Name":"Survey 456",
"Series_Code":"NONE","Series_Name":"No Series",
"Invitation_Count":50,"Close_Date_GMT":"2022-02-28"}},

{"relationship_survey":{"Relationship_Survey_System_ID":"sysid-003","Survey_Code":"TEST003",
"Survey_Name":"Survey 789",
"Series_Code":"TEST","Series_Name":"Testing",
"Invitation_Count":150,"Close_Date_GMT":"2021-11-30"}}

]}

Error Handling

A successful API call will result in one of these codes being returned in the HTTP header:

  • 200 Success: Relationship Survey updated or information successfully retrieved .
  • 201 Success: Relationship Survey created.
  • 202 Success: Relationship Survey deleted.

If there is a problem, one of these error codes will be returned in the HTTP header:

  • 400 Field value invalid or missing or JSON is malformed.
  • 401 Invalid security credentials (portal code and/or API key missing or invalid).
  • 404 A Relationship Survey with this System ID was not found.
  • 422 Another Relationship Survey already has this Relationship Survey Code.
  • 500 Transaction failed. Contact CIOPulse support for assistance.

In each of these error situations, a description of the error will also be returned in JSON format.

{"message":"Invalid security credentials","status":401}
Previous Article 2.3 Transactional Survey Webhook
Next Article 3.2 Relationship Survey Responses API v5