Introduction

Territory Services API is a RESTful api developed to provide easy and accessible storage and management for congregation territories. Although many systems can connect to the api via mobile and web client, the api does provide a web UI client interface. The web UI client interface can be viewed here.

Core Entities

  • Users userId, userType, email, publisherId
  • Publishers publisherId, firstName, lastName, publisherType
  • Territories. territoryId, publisherId, date, number, location, cityState, boundaries
  • Addresses addressId, territoryId, inActive, name, address, apt, lat, long, phone, streetId
  • Streets streetId, isAptBuilding, street
  • Records, recordId, userId, territoryId, publisherId, activityType
  • Notes, note, date

Get started

Sign up

URL: /signup
type: POST
@params: { email: (string), password: (string) }
@return:
{ "token": (string) }

Sign in

URL: /signin
type: POST
@params: { email: (string), password: (string) }
@return:
{ "token": (string) }

Get Access

URL: /auth-user
type: GET
@params: JWT token (header)
@return:
{
	"data": {
		"email": (string),
		"userId": (int), 
		"userType": (string)
	}
}

Get All Users

URL: /users
type: GET
@params: JWT token (header)
@return:
{
	"data": [
		{
			"userId": (int),
			"userType": (string),
			"email": (string),
			"publisher": {
				"publisherId": (int), 
				"firstName": (string),
				"lastName": (string),
				"publisherType": (string),
				"territories": [
					{
						"territoryId": (int),
						"publisherId": (int),
						"date": (date),
						"number": (int),
						"location": (string),
						"cityState": (string)
					},...
				]
			}
		},...
	]
}

Save User

URL: /users/{userId}/save
type: POST
@params: JWT token (header), userId (int), {"email": (string), "userType": (string)}
@return:
{
	"data": [
		{ 
			"userId": (int), 
			"userType": (string), 
			"email": (string), 
			"publisherId": (int)
		}
	]
}

Delete User

URL: /users/{userId}/delete
type: POST
@params: JWT token (header), userId (int)
@return:
{ "data": true }

Attach User to Publisher

URL: /publishers/attach-user
type: POST
@params: JWT token (header), { "userId": (int), "publisherId": (int) }
@return:
{
	"data": [
		{ 
			"publisherId": (int),
			"firstName": (string),
			"lastName": (string),
			"publisherType": (string)
		}
	]
}

Get All Publishers

URL: /publishers
type: GET
@params: JWT token (header)
@return:
{
	"data": [
		{
			"publisherId": (int),
			"firstName": (string),
			"lastName": (string),
			"publisherType": (string),
			"territories": [
				{
					"territoryId": (int),
					"publisherId": (int),
					"date": (date),
					"number": (int),
					"location": (string),
					"cityState": (string),
					"boundaries": (string)
				},...
			]
		}
	]
}

Get Publisher

URL: /publishers/{publisherId}
type: GET
@params: JWT token (header), publisherId (int)
@return:
{
	"data": { 
		"publisherId": (int),
		"firstName": (string),
		"lastName": (string),
		"publisherType": (string), 
		"territories": [
			{
				"territoryId": (int),
				"publisherId": (int),
				"date": (date),
				"number": (int),
				"location": (string),
				"cityState": (string),
				"boundaries": (string)
			},...
		]
	}
}

Add Publisher

URL: /publishers/add
type: GET
@params: JWT token (header), {"firstName": (string), "lastName": (string)}
@return:
{
	"data": { 
		"publisherId": (int),
		"firstName": (string),
		"lastName": (string),
		"publisherType": (string),
		"territories": [
			{ 
				"territoryId": (int),
				"publisherId": (int),
				"date": (date),
				"number": (int),
				"location": (string),
				"cityState": (string),
				"boundaries": (string)
			},...
		]
	}
}

Update Publisher

URL: /publishers/{publisherId}/save
type: GET
@params: JWT token (header), publisherId (int), {"firstName": (string), "lastName": (string)}
@return:
{
	"data": {
		"publisherId": (int),
		"firstName": (string),
		"lastName": (string),
		"publisherType": (string), 
		"territories": [
			{
				"territoryId": (int),
				"publisherId": (int),
				"date": (date),
				"number": (int),
				"location": (string),
				"cityState": (string),
				"boundaries": (string)
			},...
		]
	}
}

Delete Publisher

URL: /publishers/{publisherId}/delete
type: POST
@params: JWT token (header), publisherId (int)
@return:
{ "data": true }

Get All Territories

URL: /territories
type: GET
@params: JWT token (header)
@return:
{
	"data": [
		{
			"territoryId": (int),
			"publisherId": (int),
			"date": (date),
			"number": (int),
			"location": (string),
			"cityState": (string),
			"boundaries": (string)
		},...
	]
}

Get Available Territories

URL: /available-territories
type: GET
@params: JWT token (header)
@return:
{
	"data": [
		{
			"territoryId": (int),
			"publisherId": (int),
			"date": (date),
			"number": (int),
			"location": (string),
			"cityState": (string),
			"boundaries": (string)
		},...
	]
}

Get All Territories By Filter

URL: /territories/filter
type: POST
@params: JWT token (header)
@params: { "userId": (int) }
@return:
{
	"data": [
		{
			"territoryId": (int),
			"publisherId": (int),
			"date": (date),
			"number": (int),
			"location": (string),
			"cityState": (string),
			"boundaries": (string)
		},...
	]
}

Get Territory Details

URL: /territories/{territoryId}
type: GET
@params: JWT token (header), territoryId (int)
@return:
{
	"data": {
		"territoryId": (int),
		"publisherId": (int),
		"date": (date),
		"number": (int),
		"location": (string),
		"cityState": (string),
		"boundaries": (string),
		"addresses": [
			{
				"addressId": (int),
				"territoryId": (int),
				"inActive": (bool),
				"name": (string),
				"address": (string),
				"apt": (string),
				"lat": (float),
				"long": (float),
				"phone": (string),
				"street": {
					"streetId": (int),
					"isAptBuilding": (bool),
					"street": (string)
				},
				"streetId": (int),
				"streetName": (string),
				"notes": ""
			},...
		],
		"publisher": {
			"publisherId": (int),
			"firstName": (string),
			"lastName": (string),
			"publisherType": (string)
		},
	}
}

Get Territory Activities

URL: /all-activities
type: GET
@params: JWT token (header)
@return:
{
	"data": {
		"territoryId": (int),
		"publisherId": (int),
		"date": (date),
		"number": (int),
		"location": (string),
		"cityState": (string),
		"boundaries": (string), 
		"addresses": [
			{
				"addressId": (int), 
				"territoryId": (int), 
				"inActive": (bool), 
				"name": (string), 
				"address": (int), 
				"apt": (string), 
				"lat": (float), 
				"long": (float), 
				"phone": (string), 
				"streetId": (int), 
				"streetName": (string), 
				"notes": (string)
				"street": {
					"streetId": (int),
					"isAptBuilding": (bool),
					"street":(string)
				},
			},...
		], 
		"records": [
			{
				"recordId": (int), 
				"userId": (int), 
				"territoryId": (int), 
				"publisherId": (int), 
				"activityType": (string), 
				"publisher": {
					"publisherId": (int), 
					"firstName": (string), 
					"lastName": (string), 
					"publisherType": (string)
				}, 
				"user": {
					"userId": (int), 
					"userType": (string), 
					"email": (string)
				}
			},...	
		], 
		"publisher" :{
			"publisherId": (int),
			"firstName": (string),
			"lastName": (string),
			"publisherType": (string)
		}
	}
}

Get Recent Activities

URL: /activities
type: GET
@params: JWT token (header)
@return:
{
	"data": [
		{
			"territoryId": (int),
			"publisherId": (int),
			"date": (date),
			"number": (int),
			"location": (string),
			"cityState": (string),
			"boundaries": (string), 
			"records": [
				{
					"recordId": (int), 
					"userId": (int), 
					"territoryId": (int), 
					"publisherId": (int), 
					"activityType": (string), 
					"publisher": {
						"publisherId": (int), 
						"firstName": (string), 
						"lastName": (string), 
						"publisherType": (string)
					}, 
					"user": {
						"userId": (int), 
						"userType": (string), 
						"email": (string)
					}
				}
			]
		},...
	]
}

Get Territory Map

URL: /territories/{territoryId}/map
type: GET
@params: JWT token (header), territoryId (int)
@return:
{
	"data": {
		"territory": {
			"territoryId": (int), 
			"publisherId": (int), 
			"date": (date), 
			"number": (int), 
			"location": (string), 
			"cityState": (string), 
			"boundaries": (string),  
			"publisher": {
				"publisherId": (int), 
				"firstName": (string), 
				"lastName": (string), 
				"publisherType": (string)
			},
			"map": [
				{
					"address": (string), 
					"name": (string), 
					"lat": (float), 
					"long": (float), 
					"id": (int)
				},...
			]
		}
	}
}

Add Territory

URL: /territories/add
type: POST
@params: JWT token (header), {"location": (string), "number": (int)}
@return:
{
	"data": {
		"territory": {
			"territoryId": (int), 
			"publisherId": (int), 
			"date": (date), 
			"number": (int), 
			"location": (string), 
			"cityState": (string), 
			"boundaries": (string)
		}	
	}
}

Update Territory

URL: /territories/{territoryId}
type: POST
@params: JWT token (header), territoryId (int)
@return:
{
	"data": {
		"territory": {
			"territoryId": (int), 
			"publisherId": (int), 
			"date": (date), 
			"number": (int), 
			"location": (string), 
			"cityState": (string), 
			"boundaries": (string)
		}	
	}
}

Add Address

URL: /territories/{territoryId}/addresses/add
type: POST
@params: JWT token (header), territoryId (int)
@return:
{
	"data": {
		"address": (string), 
		"name": (string), 
		"lat": (float), 
		"long": (float), 
		"addressId": (int)
	}
}

Update Address

URL: /territories/{territoryId}/addresses/edit/{addressId}
type: POST
@params: JWT token (header), territoryId (int), addressId (int)
@return:
{
	"data": {
		"address": (string), 
		"name": (string), 
		"lat": (float), 
		"long": (float), 
		"addressId": (int)
	}
}

Remove Addresses

URL: /addresses/{addressId}/remove
type: POST
@params: JWT token (header), {"addressId": (int), "delete" : (bool), "note": (string)}
@return:
{ "data": true }

Add Note

URL: /territories/{territoryId}/addresses/{addressId}/notes/add
type: POST
@params: JWT token (header), territoryId (int), addressId (int), { "note": (string), "date": (date) }
@return:
{ 
	"data": {
		"address": (string), 
		"name": (string), 
		"lat": (float), 
		"long": (float), 
		"id": (int), 
		"notes": (string)
	}
}

Update Note

URL: /territories/{territoryId}/notes/edit/{noteId}
type: POST
@params: JWT token (header), territoryId (int), noteId (int), { "note": (string), "date": (date) }
@return:
{ 
	"data": {
		"address": (string), 
		"name": (string), 
		"lat": (float), 
		"long": (float), 
		"id": (int), 
		"notes": (string)
	}
}