Managing Workers

Workers (aka “Wonoloers”) are the people who hired for jobs and who use the Wonolo mobile app to search for and apply to job postings.

Employers (or “Requesters”) are the people posting jobs, primarily through the Customer Portal web application.

Both Workers and Employers are represented as Users within the API, and it is through that service that workers are managed.

Privilege Level

If you have Public Pool access, you will only be able to access Wonoloers with whom you have “active” Jobs. Active jobs are those Jobs which are in a state of:

  • filled
  • in_progress
  • paused
  • completed
  • approved (this only includes Jobs approved within the last 24 hours)

Creating / Updating Workers

Creating workers requires a variety of properties to be defined such as name, gender, and address information. Particular properties important for assigning users to jobs are described below.

Workers are created by sending an initial post request to the invite endpoint of the Users service. Users are not created directly through posting the user service to avoid sending a password. Calling the invite endpoint sends a link to the new user’s email. Note that both the user’s email and the user’s phone number must be unique and the email must be formatted as a valid email address.

curl -X POST \
  'https://test.wonolo.com/api_v2/users/invite?token=[yourtoken]' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
        "type": "Worker",
        "first_name": "InviteUserTestFName",
        "last_name": "InviteUserTestLName",
        "phone": "+1415-555-5555",
        "email": "[email protected]",
        "external_id": "wonolo_employee_1234"
    }'
//first invite a worker
var data = JSON.stringify({
  "type": "Worker",
  "first_name": "InviteUserTestFName",
  "last_name": "InviteUserTestLName",
  "phone": "+1415-555-5551",
  "email": "[email protected]",
  "external_id": "wonolo_employee_1234"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://test.wonolo.com/api_v2/users/invite?token=QwErTyAsDfZxCv");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);

Subsequent updates to the user’s account may be done by making PATCH requests to the Users service with the new identifier returned from calls to invite.

curl -X PATCH \
  'https://test.wonolo.com/api_v2/users/9012?token=VEzCnWyk1uFWEqyyuzhd' \
  -H 'Content-Type: application/json' \
  -H 'cache-control: no-cache' \
  -d '{
    "user": {
        "id": 9012,
        "external_id": wonolotest1,
        "address_state": "",
        "address": null,
        "avatar_url": null,
        "business_name": null,
        "city": "San Francisco",
        "dob": null,
        "drug_tested": "",
        "email": "[email protected]",
        "first_name": "FName",
        "gender": null,
        "home_latitude": "37.7952",
        "home_longitude": "-122.4029",
        "last_name": "LName",
        "latitude": "37.7952",
        "logo_url": null,
        "longitude": "-122.4029",
        "lower_pool_until": null,
        "lower_pool": null,
        "onboarding_appt_time": null,
        "phone": "+1415-555-5551",
        "rating": null,
        "referred_by": "",
        "ssn": "",
        "suspended_until": null,
        "suspended": false,
        "tracking_code": null,
        "type": "Worker",
        "updated_at": "2019-08-30T11:59:49.919-07:00",
        "user_badges": [{"badge_id": "5053"}],
        "w2_address_state": null,
        "w2_employee_id": "",
        "w2_onboarding_completed": null,
        "w2_onboarding_started": null,
        "w2_onboarding_status": "",
        "workplace_image_url": null,
        "zip": "94111"
        }
}'
//then patch the user you created to add particular data
data = JSON.stringify({
	"id": 9012,
	"address_state": "",
	"address": null,
	"avatar_url": null,
	"business_name": null,
	"city": "San Francisco",
	"dob": null,
	"drug_tested": "",
	"email": "[email protected]",
	"external_id": "wonolotest1",
	"first_name": "Fname",
	"gender": null,
	"home_latitude": "37.7952",
	"home_longitude": "-122.4029",
	"last_name": "LastName",
	"latitude": "37.7952",
	"logo_url": null,
	"longitude": "-122.4029",
	"lower_pool_until": null,
	"lower_pool": null,
	"onboarding_appt_time": null,
	"phone": "+1415-555-5551",
	"rating": null,
	"referred_by": "",
	"ssn": "",
	"suspended_until": null,
	"suspended": false,
	"tracking_code": null,
	"type": "Worker",
	"updated_at": "2019-08-30T11:59:49.919-07:00",
	"user_badges": [
		{
			"badge_id": "5053"
		}
	],
	"w2_address_state": null,
	"w2_employee_id": "",
	"w2_onboarding_completed": null,
	"w2_onboarding_started": null,
	"w2_onboarding_status": "",
	"workplace_image_url": null,
	"zip": "94111"
});

xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PATCH", "https://test.wonolo.com/api_v2/users/9012?token=VEzCnWyk1uFWEqyyuzhd");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);

Worker Location Info

Location information on users representing workers will be important when it comes to ranking workers for a job posting (see Finding and Communicating with Workers ). This location information is represented as longitude and latitude coordinates for both here the worker resides as well as the worker’s current location. These values describe GPS coordinates as positive or negative decimal values. These values can typically be obtained from an end user’s device.

Assigning Badges to Workers

As described in Managing Badges, Badges will be important in determining which jobs are visible and available to workers in the system. It is therefore important to assign badges to users through the “badges” property, which is an array of badge objects. To add a Badge, you need to specify the ID of the Badge in the user_badges_attributes property as a list of objects with the property badge_id.

Any number of badges may be added to a given worker object but note that you are not allowed to add duplicate badges to a user.

You can associate your own ID as the external_id parameter and use that to retrieve the Worker in future. This can be any arbitrary string (it doesn’t have to be a number)


What’s Next

Post a job through the API