Autofy Batch Sync API

Propelware Autofy Developer Portal

Developer Portal

Autofy API Overview

The Autofy API is a private API used by partners to create, schedule and run integrations utilizing the Autofy platform. For access and to discuss further, please e-mail us.

Autofy is conceptually broken up into a few key components, each of which we expose as part of the API:

  • Company: a company is an entity that has data to be integrated between applications.
  • User: a user is a person that has permissions to run a sync operation. For on-premise data, the user is provided with an access token used to connect to Autofy in the cloud
  • Sync Profile: a company has one or more sync profiles which outline which data should be synchronized and in which direction; when setting up a new profile or company using the Autofy API, we will work with you to create one or more "sync templates" which are pre-configured sync profiles and make it easy to setup new users.
  • Sync Operation: a sync operation contains details about the specific data types, direction, and credentials for each type of data to be synchronized. A sync profile has one or more sync operations.

API Url
			https://autofy.propelware.com/api/v1/
		

Authentication

Each organization the utilizes Autofy receives an authentication token which should be passed in through each call into the API. This token is assigned by Propelare and is provided to each development organization upon using the API.

To set the token, set the AUTHORIZATION header of the HTTP request when calling the API.

			AUTHORIZATION: [API_TOKEN_FROM_PROPELWARE]
		
In C#:
			HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl);
			
			//set your API token
			string authenticationHeader = string.Format(@"{0}", [API_TOKEN_FROM_PROPELWARE]);
			req.Headers.Add(HttpRequestHeader.Authorization, authenticationHeader);
		


Company

The company method exists to create a new company and sync profile in one call. Doing this essentially provisions a new user in Autofy and sets up a sync profile for them based on the sync template that is stored in Autofy.

This method is called as a POST method where the following JSON data is passed to it. The information includes data such as what sync template to use and the credentials to be used while synchronizing.

The response from Autofy will be the same JSON data structure that was passed in by the request, but will have additional information contained within it. The response will include information about the sync profile that was setup and associated with the company. Also, information about the users associated with the company, including their desktop sync token is also returned. The goal is to provide all the information back from Autofy about the company and profile that was created and is setup to run.

Request JSON to be POSTed
			{
				"CoName": null,
				"SyncProfileTemplate": "salesforce-qbd",
				"Credentials": [
					{
						"ID": 0,
						"UserName": "[email protected]",
						"Password": "somePassword",
						"DataSource": "AutofyXml",
						"AccessToken": null,
						"AccessTokenSecret": null,
						"AccessTokenCreationDate": null,
						"RealmID": null
					}
				],
				"Profiles": [],
				"Users": []
			}
		
Name Description
CoName Is the common name used to identify the company being created. It's an optional field.
SyncProfileTemplate Used to create a sync profile in addition to just setting up the company. This field identifies which Autofy sync profile template should be created for this company. This value will be shared with you from the Propelware team when applicable and able to be used.
Credentials These credentials are used to setup the sync profile properly and get the user ready to process data. It encompasses fields to save OAuth security values and or a variety of user name/password combinations of credentials.

DataSource value should be one of:
  • QuickBooks
  • QuickBooks Online
  • Sage 50
  • Salesforce.com
  • Fishbowl
  • Autofy XML
  • CSV
SyncID This is used in advanced cases where a sync profile has multiple groups of sync operations that can be run. For example, a sync profile may be setup to have certain data to be synchronized when doing an initial data import or new customer setup and then a separate set of operations to be run to process transactions. By default, the value is set to "0".
Response JSON
			{
				"Meta": {
					"StatusCode": 0,
					"Severity": null,
					"Message": null
				},
				"Detail": {
					"CoName": null,
					"SyncProfileTemplate": "salesforce-qbd",
					"Credentials": [],
					"Profiles": [
						{
							"ID": "68fd8661-44cc-47b6-818f-33b7287f04b5",
							"CreatedDateTime": "3/19/2015 4:42:50 PM",
							"LastSyncTime": "3/10/2015 9:23:30 AM"
						}
					],
					"Users": [
						{
							"ID": "4526",
							"Token": "KGR6B1VGJQU5MK3P9XUJLGZ0ZPCH"
						}
					]
				}
			}
		
Sample code in C#
			string sUrl = m_sBaseApiUrl + "company";
			HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl);
			req.ContentType = "application/json";

			// post request tells us to insert
			req.Method = "POST";

			//set your API token
			string authenticationHeader = string.Format(@"{0}", [API_TOKEN_FROM_PROPELWARE]);
			req.Headers.Add(HttpRequestHeader.Authorization, authenticationHeader);

			using (var streamWriter = new StreamWriter(req.GetRequestStream()))
			{
				string json = COMPANY_JSON_REQUEST;

				streamWriter.Write(json);
				streamWriter.Flush();
				streamWriter.Close();

				try
				{
					HttpWebResponse res = (HttpWebResponse)req.GetResponse();

					Stream resst = res.GetResponseStream(); 
					StreamReader sr = new StreamReader(resst);
					var sRes = sr.ReadToEnd();

					JavaScriptSerializer s = new JavaScriptSerializer();
					string sJsonResponse = s.Deserialize(sRes);
				}
				catch (Exception ex)
				{
				}
			}
		

Sync Profile

You can add or update a sync profile to an existing company. When creating an additional profile to an existing company, you will send a POST message and provide the name of the sync template to be added to the company. An example where this is used is if a company has multiple, disparate sync profiles that need to be run. For example, they want to integrate a CRM with QuickBooks, but also want to separately integrate a shopping cart with QuickBooks.

If you use the company method above to setup companies, then you typically will not need this method except for advanced circumstances where an edit to a sync profile is required. The company method can be used to encompass the creation of a company and a sync profile.

Request JSON to be POSTed
		{
    "AppID": "",
    "LastSyncAttempt": "",
    "LastSuccessfulSync": "",
    "LastSuccessfulSyncTime": "",
    "DataFile": "",
    "CoName": "",
    "SyncTitle": "",
    "LastModifiedDateTime": "",
    "CreatedDateTime": "",
    "UserCompanyID": 5328,
    "LastModifiedByUserID": 0,
    "CreatedByUserID": 0,
    "TemplateName": "salesforce-qbd",
    "ProfileID": null,
    "UserID": 0,
    "EnableScheduler": false,
    "ScheduleInterval": 0,
    "ScheduleTime": null,
 	"DataSourceCreds": [
					{
						"ID": 0,
						"UserName": "[email protected]",
						"Password": "somePassword",
						"DataSource": "AutofyXml",
						"AccessToken": null,
						"AccessTokenSecret": null,
						"AccessTokenCreationDate": null,
						"RealmID": null
					},
	"DataDestinationCreds": [
					{
						"ID": 0,
						"UserName": "[email protected]",
						"Password": "somePassword",
						"DataSource": "AutofyXml",
						"AccessToken": null,
						"AccessTokenSecret": null,
						"AccessTokenCreationDate": null,
						"RealmID": null
					}
}
		
JSON Response
			same as JSON request with additional fields filled in
		
Sample code in C#
			string sUrl = m_sBaseApiUrl + "profiles";
			HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl);
			req.ContentType = "application/json";

			// if there is a uniqueId, then update the profile, otherwise create a new profile
			if (null != p.ProfileID)
			{
				// put request tells us to update the sync profile
				req.Method = "PUT";
			}
			else
			{
				// post request tells us to insert a new profile
				req.Method = "POST";
			}

			//set your API token
			string authenticationHeader = string.Format(@"{0}", [API_TOKEN_FROM_PROPELWARE]);
			req.Headers.Add(HttpRequestHeader.Authorization, authenticationHeader);

			using (var streamWriter = new StreamWriter(req.GetRequestStream()))
			{
				string json = SYNC_PROFILE_JSON_REQUEST;

				streamWriter.Write(json);
				streamWriter.Flush();
				streamWriter.Close();

				try
				{
					HttpWebResponse res = (HttpWebResponse)req.GetResponse();

					Stream resst = res.GetResponseStream(); // display HTTP response
					StreamReader sr = new StreamReader(resst);
					var sRes = sr.ReadToEnd();

					JavaScriptSerializer s = new JavaScriptSerializer();
					string sJsonResponse = s.Deserialize(sRes);
				}
				catch (Exception ex)
				{
					string sMsg = ex.Message;
				}
			}
		

Schedule

Autofy can be enabled to process automatically on a scheduled basis.

Request JSON
			{
				profileId: "34027c47-7546-48b9-9b30-451ed25293c5",
				scheduleInterval: "30",
				scheduleTime: "4:00 AM",
				intervalType: 0
			}
		
profileId Identifies the sync profile to be scheduled. This value was returned as part of the JSON response when creating a company or a profile.
scheduleInterval (Optional)
This value defines how often the sync should run. It is used in combination with the intervalType value to determine the exact specification of the schedule.
scheduleTime (Optional)
The value is used to describe the time of day to run the sync. For example, if the syn should be run at 4:00 AM, this is the value that tells that to Autofy. It is used in conjunction with the intervalType value described below only when the intervalType = 2.
intervalType This value describes the type of schedule to be performed. Possible values include:
  • 0 = minutes
  • 1 = hours
  • 2 = days
    This value is used in conjunction with the scheduleInterval and scheduleTime values. For example, if the desired schedule is to be performed every 30 minutes, the scheduleInterval would be set to 30 and the intervalType would be set to 0. The scheduleTime value would only be used if intervalType is set to 2 (days).
  • Response JSON
    			{
    				"Meta": {
    					"StatusCode": 0,
    					"Severity": null,
    					"Message": null
    				},
    				"Detail": null
    			}
    		

    Run Sync

    To execute a sync profile, you POST information about which profile to run and with sync operations to run as part of the sync profile.

    Request JSON
    			{
    				"profileId": "34027c47-7546-48b9-9b30-451ed25293c5",
    				"syncId": "0",
    				"dtStartUTC": "1/1/2016 12:00:00 PM"
    			}
    		
    Name Description
    profileId Identifies the sync profile to be run. This value was returned as part of the JSON response when creating a company or a profile.
    syncId (Optional)
    This is used in advanced cases where a sync profile has multiple groups of sync operations that can be run. For example, a sync profile may be setup to have certain data to be synchronized when doing an initial data import or new customer setup and then a separate set of operations to be run to process transactions. By default, the value is set to "0".
    dtStartUTC (Optional)
    For times when it is desired to dictate to Autofy the timestamp of how far back in time the sync should run. By default, Autofy internally tracks the timestamp of each sync and uses this as the time range that should be used in order to ensure each sync is an incremental processing of data.
    Response JSON
    			{
    				"Meta": {
    					"StatusCode": 0,
    					"Severity": null,
    					"Message": null
    				},
    				"Detail": null
    			}
    		

    Disconnect

    To disable a profile and make it so that it will not synchronize, utilize the disconnect method.

    Request JSON
    			{
    				"profileId": "34027c47-7546-48b9-9b30-451ed25293c5", 
    				"syncId": "0" 
    			}
    		
    Name Description
    profileId Identifies the sync profile to be disconnected.
    syncId This is used in advanced cases where a sync profile has multiple groups of sync processes that can be run. If you want to only disable part of the sync profile, then this parameter specifies which group of sync processes to disable.
    Response JSON
    			{
    				"Meta": {
    					"StatusCode": 0,
    					"Severity": null,
    					"Message": null
    				},
    				"Detail": null
    			}
    		
    Sample code in C#
    			string sUrl = m_sUrl + "disconnect";
    			HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl);
    			req.ContentType = "application/json";
    
    			req.Method = "POST";
    
    			//set your API token
    			string authenticationHeader = string.Format(@"{0}", [API_TOKEN_FROM_PROPELWARE]);
    			req.Headers.Add(HttpRequestHeader.Authorization, authenticationHeader);
    
    			using (var streamWriter = new StreamWriter(req.GetRequestStream()))
    			{
    				string json = RUN_SYNC_JSON_REQUEST;
    
    				streamWriter.Write(json);
    				streamWriter.Flush();
    				streamWriter.Close();
    
    				try
    				{
    					HttpWebResponse res = (HttpWebResponse)req.GetResponse();
    
    					Stream resst = res.GetResponseStream(); // display HTTP response
    					StreamReader sr = new StreamReader(resst);
    					var sRes = sr.ReadToEnd();
    					
    					JavaScriptSerializer s = new JavaScriptSerializer();
    					string sJsonResponse = s.Deserialize(sRes);
    				}
    				catch (Exception ex)
    				{
    				}
    			}
    		

    Sample Code

    			Download the full sample code in C#.