About
The Truckers Against Trafficking (TAT) Salesforce account stores data associated with each user of the TAT mobile app. The mobile app uses this data stored in Salesforce. However, the mobile app does not directly communicate with Salesforce—it communicates with this proxy instead. This proxy is given authorization to read any user's data from Salesforce. Users of the TAT app authenticate with a separate service (Firebase), and the proxy filters data from Salesforce so that each user can only access his/her data.
This gives the benefit of only requiring one Salesforce account for all users of the app, and keeps app user management separate from Salesforce user management.
Users of the app authenticate with Firebase. The app passes the user's Firebase ID token to the proxy, and the proxy confirms with Firebase that the token is valid and retrieves the user's FirebaseUid from Firebase. The proxy then retrieves the Salesforce data that is associated with that FirebaseUid, and passes it on to the user.
Status

Failed to connect to Salesforce.
Unexpected error.
{"error":"Malformed json."}

Connected.

Configured.

Installed.

Configured.
API
Required POST headers
All POST requests to the API must include the following header:
Content-Type: application/json
The POST payload must be JSON-formatted.
Error responses
If a request results in an error, the API will return a 400 http response code and return a JSON-formatted object like the following:
{ errorCode: "SOME_ERROR_CODE", message: "A short description of the error." }
The documentation for each method lists the different possible error codes.
Methods
- checkRegistrationCode
- contactSearch
- getTeamCoordinators
- createNewUser
- updateUser
- getUserData
- getCampaigns
- createFeedback
- createPreOutreachSurvey
- createPostOutreachReport
- deleteOutreachLocation
- updateNotificationPreferences
- unregisterFcmToken
checkRegistrationCode
checkRegistrationCode verifies whether a registration code is valid. If it is, it returns the related volunteer type and any other related information (like campaign ID).
Make a GET request to:
/api/checkRegistrationCode?code=[CODE]
GET parameters
code
{string} (required)
The code (password) required to create a new user account.
Response payload
{ success: true, volunteerType: 'volunteerDistributor' | 'ambassadorVolunteer', // for volunteerDistributor users: accountId: {string}, // representing one or more teams of volunteers isIndividualDistributor: {boolean}, teamCoordinators: { name: {string}, salesforceId: {string} }[] }
Error codes ?
INCORRECT_REGISTRATION_CODE
The provided registration code was incorrect.
Example request
GET /api/checkRegistrationCode?code=correct-horse-battery-staple
contactSearch
contactSearch searches via email address or phone number for Salesforce Contact objects which are not associated with Firebase user accounts. If any unassociated Contact object has either the given email address or phone number, then that Contact's Id is returned.
Make a GET request to:
/api/contactSearch?email=[EMAIL_ADDRESS]&phone=[PHONE_NUMBER]
GET parameters
email
{string} (required)
An email address. For example, joe.somebody@example.com
phone
{string} (required)
A phone number in any format. The format doesn't matter. For example, 5551234567
or (555) 123-4567
.
Response payload
{ salesforceId: {string} }
Error codes ?
NO_MATCHING_ENTRY
There is no matching Contact in Salesforce.
ENTRY_ALREADY_HAS_ACCOUNT
There is a matching Contact, but it already has an associated Firebase user account.
Example request
GET /api/contactSearch?email=joe.blow@example.com&phone=5559092332
getTeamCoordinators
getTeamCoordinators returns the Salesforce Contact IDs and names for all users who are listed as volunteer team coordinators for a given Account.
Make a GET request to:
/api/getTeamCoordinators
GET parameters
accountId
{string} (required)
The Salesforce ID of an Account.
Response payload
[ { name: {string}, salesforceId: {string} }, { name: {string}, salesforceId: {string} }, ... ]
Example request
GET /api/getTeamCoordinators?accountId=j9KeT4
createNewUser
createNewUser creates a new app user by associating a firebase uid with a Contact entry in Salesforce, creating a new Contact if needed.
Make a POST request to:
/api/createNewUser
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
registrationCode
{string} (required)
A code (password) required to create a new user account. This is not the user's password.
salesforceId
{string}
The ID of a Contact object in Salesforce. If provided, the Contact object will be updated with the app user's data. If not provided, a new Contact object will be created.
email
{string}
The user's email address. Required if salesforceId
is not provided.
phone
{string}
The user's phone number. Required if salesforceId
is not provided.
firstName
{string}
The user's first name. Required if salesforceId
is not provided.
lastName
{string}
The user's last name. Required if salesforceId
is not provided.
isCoordinator
{boolean}
Whether the user is a team coordinator. This should also be set to true if the user is an individual distributor volunteer.
coordinatorId
{string}
The Salesforce Contact ID of the user's volunteer team coordinator (if the user is not the team coordinator).
trainingVideoRequiredForTeam
{boolean}
For volunteer distributor team leaders. Whether new team members are required to watch the training video when they sign up.
Response payload
{ contactId: {string} // the ID of the updated or newly created Contact object in Salesforce }
Error codes ?
INCORRECT_REGISTRATION_CODE
The provided registration code was incorrect.
FIREBASE_USER_ALREADY_IN_SALESFORCE
There is already a Contact entry in Salesforce associated with the Firebase user.
Example request
// URL: POST /api/createNewUser // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "registrationCode": "correct-horse-battery-staple", "salesforceId": "JOF7EK0enoejMOE8", "isCoordinator": true, "trainingVideoRequiredForTeam": false }
updateUser
updateUser updates fields on an existing user account.
Make a POST request to:
/api/updateUser
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
coordinatorId
{string}
The Contact ID of the user's team coordinator.
hasWatchedTrainingVideo
{boolean}
Whether the user has watched the training video.
trainingVideoLastWatchedDate
{string, YYYY-MM-DD}
When the user last watched the training video in the app.
trainingVideoRequiredForTeam
{boolean}
For volunteer distributor team leaders. Whether new team members are required to watch the training video when they sign up.
Response payload
{ success: true }
Example request
// URL: POST /api/updateUser // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "coordinatorId": "KJD94JFR" }
getUserData
getUserData provides a way for the TAT mobile app to get a user's data.
Make a POST request to:
/api/getUserData?parts=[LIST_OF_PARTS]
Required headers
See the section on required POST headers.
GET parameters
parts
{string} (required)
A comma-separated list of values. These values define what data will be returned.
Acceptable values are: basic
, unfinishedActivities
.
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
Response payload
The API returns a JSON object containing data on the user.
If basic
is in the list of parts, the API will return basic info on the user.
The following properties will be included in the returned object:
{ salesforceId: {string}, // the identifier of the object in Salesforce representing the user firstName: {string}, lastName: {string}, volunteerType: {string}, accountId: {string}, hasWatchedTrainingVideo: {boolean}, trainingVideoLastWatchedDate: {string (ISO-8601 or YYYY-MM-DD)}, street: {string}, city: {string}, state: {string}, zip: {string}, country: {string}, isTeamCoordinator: {boolean}, teamCoordinatorId: {string}, // ContactID of the salesforce object representing the user's team coordinator isOnVolunteerTeam: {boolean}, trainingVideoRequiredForTeam: {boolean} notificationPreferences: { [ fcmToken: string ]: { language: {string}, preEventSurveyReminderEnabled: {boolean}, reportReminderEnabled: {boolean}, upcomingEventsReminderEnabled: {boolean} } } }
If unfinishedActivities
is in the list of parts, the API will return a list of outreach
activities (locations identified in pre-outreach form submissions) or events which the user has not
completed a post-report for.
The following properties will be included in the returned object, if the user is a Volunteer Distributor:
{ outreachLocations: [ { id: {string}, // the identifier of the Salesforce object representing the outreach activity or event activity name: {string}, type: {'cdlSchool' | 'truckingCompany' | 'truckStop' | 'event'}, campaignId: {string}, street: {string}, city: {string}, state: {string}, zip: {string}, country: {string}, date: {string (ISO-8601 or YYYY-MM-DD)}, // planned date of outreach, or date of event contact: { // the person to be contacted at the defined location name: {string}, title: {string}, email: {string}, phone: {string} } }, { ... } ] }
Error codes ?
FIREBASE_USER_NOT_IN_SALESFORCE
The user defined by the firebaseIdToken does not have an entry in Salesforce.
Example request
// URL: POST /api/getUserData?parts=basic,unfinishedActivities // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234" }
getCampaigns
getCampaigns returns a list of campaigns associated with a user.
Make a POST request to:
/api/getCampaigns
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
Response payload
[ { name: {string}, salesforceId: {string}, daysSinceCreated: {number} }, ... ]
Example request
// URL: POST /api/getCampaigns // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234" }
createFeedback
createFeedback adds the data from a testimonial/feedback survey to Salesforce.
Make a POST request to:
/api/createFeedback
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
campaignId
{string}
The ID of the campaign in salesforce associated with this feedback submission.
advice
{string}
Advice that the user would give other volunteers.
bestPart
{string}
The best part of the volunteer's experience.
improvements
{string}
Suggestions on how the volunteer experience could be improved.
givesAnonPermission
{boolean} (required)
Whether the user gives TAT permission to quote him anonymously.
givesNamePermission
{boolean} (required)
Whether the user gives TAT permission to use his name/organization in quotes and on social media.
Response payload
{ success: true }
Example request
// URL: POST /api/createFeedback // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "advice": "Show your passion for volunteering", "givesAnonPermission": true, "givesNamePermission": false }
createPreOutreachSurvey
createPreOutreachSurvey adds the data from a pre-outreach survey to Salesforce. Creates multiple Outreach Location objects associated with the submitter's campaign.
Make a POST request to:
/api/createPreOutreachSurvey
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
campaignId
{string} (required)
The salesforce ID of the campaign related to the outreach locations submitted in this survey.
isReadyToReceive
{boolean} (required)
Whether the user is ready to receive TAT materials.
mailingStreet
{string}
The street address to send TAT materials to.
mailingCity
{string}
The city to send TAT materials to.
mailingState
{string}
The state to send TAT materials to.
mailingZip
{string}
The zip code to send TAT materials to.
mailingCountry
{string}
The country to send TAT materials to.
feelsPrepared
{boolean}
Whether the user feels prepared to perform outreach duties.
questions
{string}
Questions the user may have for TAT staff.
locations
{object[]} (required)
An array of locations that the team will perform outreach activities at. This array may not be longer than 200 items.
locations[].name
{string} (required)
A friendly name of the location to be visited.
locations[].type
{string} (required)
The type of location. Valid values are cdlSchool
, truckingCompany
, and truckStop
.
locations[].street
{string} (required)
The street address of the location to be visited.
locations[].city
{string} (required)
The city of the location to be visited.
locations[].state
{string} (required)
The state of the location to be visited.
locations[].zip
{string} (required)
The zip code of the location to be visited.
locations[].country
{string} (required)
The country of the location to be visited.
locations[].date
{string, YYYY-MM-DD} (required)
The date when the volunteer is planning on visiting the location.
locations[].hasContactedManager
{boolean} (required)
Whether the user has contacted the manager (or some other employee) of the location.
locations[].contactFirstName
{string}
The first name of the contacted individual.
locations[].contactLastName
{string}
The last name of the contacted individual.
locations[].contactTitle
{string}
The professional title of the contacted individual.
locations[].contactEmail
{string}
The email address of the contacted individual.
locations[].contactPhone
{string}
The phone number of the contacted individual.
Response payload
{ success: true }
Error codes ?
TOO_MANY_LOCATIONS
The locations array has more than 200 items.
Example request
// URL: POST /api/createPreOutreachSurvey // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "campaignId": "qrst4321", "isReadyToReceive": false, "locations": [ { "name": "Love's", "street": "1234 Wowee St.", "city": "Blakefield", "state": "Oklahoma", "zip": "45454", "country": "United States", "hasContactedManager": false } ] }
createPostOutreachReport
createPostOutreachReport adds the data from a post-outreach report to Salesforce. Each report should be considered as a follow-up to a pre-outreach survey.
Make a POST request to:
/api/createPostOutreachReport
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
outreachLocationId
{string} (required)
The ID of an Outreach Location object in Salesforce.
totalHours
{number} (required)
The total number of man-hours spent by the volunteer team on this outreach effort.
completionDate
{string, YYYY-MM-DD} (required)
The date on which the outreach activity was performed.
accomplishments
{string[]} (required)
An array containing descriptions of the accomplishments made by the volunteer team during their outreach effort.
For a location type of truckStop
, the values should include zero or more of: 'willDistributeMaterials', 'willTrainEmployees'
For a location type of cdlSchool
, the values should include zero or more of: 'willUseTatTraining'
For a location type of truckingCompany
, the values should include zero or more of: 'willTrainDrivers'
otherAccomplishments
{string}
A description of accomplishments other than those specified by the accomplishments
field.
contactFirstName
{string} (required)
The first name of the contacted individual.
contactLastName
{string} (required)
The last name of the contacted individual.
contactTitle
{string} (required)
The professional title of the contacted individual.
contactEmail
{string}
The email address of the contacted individual.
contactPhone
{string}
The phone number of the contacted individual.
willFollowUp
{boolean} (required)
Whether the volunteer team will follow up with additional outreach.
followUpDate
{string, YYYY-MM-DD}
When the additional follow-up will be performed.
Response payload
{ success: true }
Example request
// URL: POST /api/createPostOutreachReport // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "outreachLocationId": "IOJEHW8nEhehoh", "totalHours": 14, "completionDate": "2019-03-12", "accomplishments": ["willUseTatTraining"], "otherAccomplishments": ["Distributed some posters"], "contactFirstName": "Stan", "contactLastName": "Francisco", "contactTitle": "Asst manager", "contactEmail": "stanfran@example.com", "willFollowUp": false }
deleteOutreachLocation
deleteOutreachLocation removes an Outreach Location, typically because the volunteers no longer intend to visit it.
Make a POST request to:
/api/deleteOutreachLocation
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
outreachLocationId
{string} (required)
The ID of an Outreach Location object in Salesforce.
Response payload
{ success: true }
Example request
// URL: POST /api/deleteOutreachLocation // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "outreachLocationId": "IOJEHW8nEhehoh" }
updateNotificationPreferences
updateNotificationPreferences associates an FCM (Firebase Cloud Messaging) token with a user, so that the device associated with the token will receive the user's notifications. This also updates preferences associated with that FCM token.
Make a POST request to:
/api/updateNotificationPreferences
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
fcmToken
{string} (required)
The FCM token.
language
{string}
A language code, like 'en'
or 'es'
. This is the language that will be used when sending notifications to the device with the specified FCM token.
preEventSurveyReminderEnabled
{string}
Whether pre-event survey reminder notifications should be sent to the device with the specified FCM token.
reportReminderEnabled
{string}
Whether post-event or post-outreach report reminder notifications should be sent to the device with the specified FCM token.
upcomingEventsReminderEnabled
{string}
Whether reminders about upcoming events should be sent to the device with the specified FCM token.
Response payload
{ success: true }
Example request
// URL: POST /api/updateNotificationPreferences // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "fcmToken": "IOJEHW8nEhehoh", "language": "en", "reportReminderEnabled": false }
unregisterFcmToken
unregisterFcmToken disassociates an FCM (Firebase Cloud Messaging) token from a user, so that any device associated with the token will no longer receive the user's notifications.
Make a POST request to:
/api/unregisterFcmToken
POST request body payload parameters
firebaseIdToken
{string} (required)
A token retrieved from Firebase after the user authenticates, which can be used to identify the user, verify his login state, and access various Firebase resources.
fcmToken
{string} (required)
The FCM token.
Response payload
{ success: true }
Example request
// URL: POST /api/unregisterFcmToken // Headers: Content-Type: application/json // Request body: { "firebaseIdToken": "abcd1234", "fcmToken": "IOJEHW8nEhehoh" }