$teamApi = $client->getTeamApi();
TeamApi
- Create Team Member
- Bulk Create Team Members
- Bulk Update Team Members
- List Jobs
- Create Job
- Retrieve Job
- Update Job
- Search Team Members
- Retrieve Team Member
- Update Team Member
- Retrieve Wage Setting
- Update Wage Setting
Creates a single TeamMember
object. The TeamMember
object is returned on successful creates.
You must provide the following values in your request to this endpoint:
given_name
family_name
Learn about Troubleshooting the Team API.
function createTeamMember(CreateTeamMemberRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreateTeamMemberRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type CreateTeamMemberResponse
.
$body = CreateTeamMemberRequestBuilder::init()
->idempotencyKey('idempotency-key-0')
->teamMember(
TeamMemberBuilder::init()
->referenceId('reference_id_1')
->status(TeamMemberStatus::ACTIVE)
->givenName('Joe')
->familyName('Doe')
->emailAddress('joe_doe@gmail.com')
->phoneNumber('+14159283333')
->assignedLocations(
TeamMemberAssignedLocationsBuilder::init()
->assignmentType(TeamMemberAssignedLocationsAssignmentType::EXPLICIT_LOCATIONS)
->locationIds(
[
'YSGH2WBKG94QZ',
'GA2Y9HSJ8KRYT'
]
)
->build()
)
->wageSetting(
WageSettingBuilder::init()
->jobAssignments(
[
JobAssignmentBuilder::init(
JobAssignmentPayType::SALARY
)
->annualRate(
MoneyBuilder::init()
->amount(3000000)
->currency(Currency::USD)
->build()
)
->weeklyHours(40)
->jobId('FjS8x95cqHiMenw4f1NAUH4P')
->build(),
JobAssignmentBuilder::init(
JobAssignmentPayType::HOURLY
)
->hourlyRate(
MoneyBuilder::init()
->amount(2000)
->currency(Currency::USD)
->build()
)
->jobId('VDNpRv8da51NU8qZFC5zDWpF')
->build()
]
)
->isOvertimeExempt(true)
->build()
)
->build()
)
->build();
$apiResponse = $teamApi->createTeamMember($body);
if ($apiResponse->isSuccess()) {
$createTeamMemberResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Creates multiple TeamMember
objects. The created TeamMember
objects are returned on successful creates.
This process is non-transactional and processes as much of the request as possible. If one of the creates in
the request cannot be successfully processed, the request is not marked as failed, but the body of the response
contains explicit error information for the failed create.
Learn about Troubleshooting the Team API.
function bulkCreateTeamMembers(BulkCreateTeamMembersRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BulkCreateTeamMembersRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type BulkCreateTeamMembersResponse
.
$body = BulkCreateTeamMembersRequestBuilder::init(
[
'idempotency-key-1' => CreateTeamMemberRequestBuilder::init()
->teamMember(
TeamMemberBuilder::init()
->referenceId('reference_id_1')
->givenName('Joe')
->familyName('Doe')
->emailAddress('joe_doe@gmail.com')
->phoneNumber('+14159283333')
->assignedLocations(
TeamMemberAssignedLocationsBuilder::init()
->assignmentType(TeamMemberAssignedLocationsAssignmentType::EXPLICIT_LOCATIONS)
->locationIds(
[
'YSGH2WBKG94QZ',
'GA2Y9HSJ8KRYT'
]
)
->build()
)
->build()
)
->build(),
'idempotency-key-2' => CreateTeamMemberRequestBuilder::init()
->teamMember(
TeamMemberBuilder::init()
->referenceId('reference_id_2')
->givenName('Jane')
->familyName('Smith')
->emailAddress('jane_smith@gmail.com')
->phoneNumber('+14159223334')
->assignedLocations(
TeamMemberAssignedLocationsBuilder::init()
->assignmentType(TeamMemberAssignedLocationsAssignmentType::ALL_CURRENT_AND_FUTURE_LOCATIONS)
->build()
)
->build()
)
->build()
]
)->build();
$apiResponse = $teamApi->bulkCreateTeamMembers($body);
if ($apiResponse->isSuccess()) {
$bulkCreateTeamMembersResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Updates multiple TeamMember
objects. The updated TeamMember
objects are returned on successful updates.
This process is non-transactional and processes as much of the request as possible. If one of the updates in
the request cannot be successfully processed, the request is not marked as failed, but the body of the response
contains explicit error information for the failed update.
Learn about Troubleshooting the Team API.
function bulkUpdateTeamMembers(BulkUpdateTeamMembersRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BulkUpdateTeamMembersRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type BulkUpdateTeamMembersResponse
.
$body = BulkUpdateTeamMembersRequestBuilder::init(
[
'AFMwA08kR-MIF-3Vs0OE' => UpdateTeamMemberRequestBuilder::init()
->teamMember(
TeamMemberBuilder::init()
->referenceId('reference_id_2')
->status(TeamMemberStatus::ACTIVE)
->givenName('Jane')
->familyName('Smith')
->emailAddress('jane_smith@gmail.com')
->phoneNumber('+14159223334')
->assignedLocations(
TeamMemberAssignedLocationsBuilder::init()
->assignmentType(TeamMemberAssignedLocationsAssignmentType::ALL_CURRENT_AND_FUTURE_LOCATIONS)
->build()
)
->build()
)
->build(),
'fpgteZNMaf0qOK-a4t6P' => UpdateTeamMemberRequestBuilder::init()
->teamMember(
TeamMemberBuilder::init()
->referenceId('reference_id_1')
->status(TeamMemberStatus::ACTIVE)
->givenName('Joe')
->familyName('Doe')
->emailAddress('joe_doe@gmail.com')
->phoneNumber('+14159283333')
->assignedLocations(
TeamMemberAssignedLocationsBuilder::init()
->assignmentType(TeamMemberAssignedLocationsAssignmentType::EXPLICIT_LOCATIONS)
->locationIds(
[
'YSGH2WBKG94QZ',
'GA2Y9HSJ8KRYT'
]
)
->build()
)
->build()
)
->build()
]
)->build();
$apiResponse = $teamApi->bulkUpdateTeamMembers($body);
if ($apiResponse->isSuccess()) {
$bulkUpdateTeamMembersResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Lists jobs in a seller account. Results are sorted by title in ascending order.
function listJobs(?string $cursor = null): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
?string |
Query, Optional | The pagination cursor returned by the previous call to this endpoint. Provide this cursor to retrieve the next page of results for your original request. For more information, see Pagination. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type ListJobsResponse
.
$apiResponse = $teamApi->listJobs();
if ($apiResponse->isSuccess()) {
$listJobsResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Creates a job in a seller account. A job defines a title and tip eligibility. Note that compensation is defined in a job assignment in a team member's wage setting.
function createJob(CreateJobRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreateJobRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type CreateJobResponse
.
$body = CreateJobRequestBuilder::init(
JobBuilder::init()
->title('Cashier')
->isTipEligible(true)
->build(),
'idempotency-key-0'
)->build();
$apiResponse = $teamApi->createJob($body);
if ($apiResponse->isSuccess()) {
$createJobResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Retrieves a specified job.
function retrieveJob(string $jobId): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
jobId |
string |
Template, Required | The ID of the job to retrieve. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type RetrieveJobResponse
.
$jobId = 'job_id2';
$apiResponse = $teamApi->retrieveJob($jobId);
if ($apiResponse->isSuccess()) {
$retrieveJobResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Updates the title or tip eligibility of a job. Changes to the title propagate to all
JobAssignment
, Shift
, and TeamMemberWage
objects that reference the job ID. Changes to
tip eligibility propagate to all TeamMemberWage
objects that reference the job ID.
function updateJob(string $jobId, UpdateJobRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
jobId |
string |
Template, Required | The ID of the job to update. |
body |
UpdateJobRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type UpdateJobResponse
.
$jobId = 'job_id2';
$body = UpdateJobRequestBuilder::init(
JobBuilder::init()
->title('Cashier 1')
->isTipEligible(true)
->build()
)->build();
$apiResponse = $teamApi->updateJob(
$jobId,
$body
);
if ($apiResponse->isSuccess()) {
$updateJobResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Returns a paginated list of TeamMember
objects for a business.
The list can be filtered by location IDs, ACTIVE
or INACTIVE
status, or whether
the team member is the Square account owner.
function searchTeamMembers(SearchTeamMembersRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
body |
SearchTeamMembersRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type SearchTeamMembersResponse
.
$body = SearchTeamMembersRequestBuilder::init()
->query(
SearchTeamMembersQueryBuilder::init()
->filter(
SearchTeamMembersFilterBuilder::init()
->locationIds(
[
'0G5P3VGACMMQZ'
]
)
->status(TeamMemberStatus::ACTIVE)
->build()
)
->build()
)
->limit(10)
->build();
$apiResponse = $teamApi->searchTeamMembers($body);
if ($apiResponse->isSuccess()) {
$searchTeamMembersResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Retrieves a TeamMember
object for the given TeamMember.id
.
Learn about Troubleshooting the Team API.
function retrieveTeamMember(string $teamMemberId): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
teamMemberId |
string |
Template, Required | The ID of the team member to retrieve. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type RetrieveTeamMemberResponse
.
$teamMemberId = 'team_member_id0';
$apiResponse = $teamApi->retrieveTeamMember($teamMemberId);
if ($apiResponse->isSuccess()) {
$retrieveTeamMemberResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Updates a single TeamMember
object. The TeamMember
object is returned on successful updates.
Learn about Troubleshooting the Team API.
function updateTeamMember(string $teamMemberId, UpdateTeamMemberRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
teamMemberId |
string |
Template, Required | The ID of the team member to update. |
body |
UpdateTeamMemberRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type UpdateTeamMemberResponse
.
$teamMemberId = 'team_member_id0';
$body = UpdateTeamMemberRequestBuilder::init()
->teamMember(
TeamMemberBuilder::init()
->referenceId('reference_id_1')
->status(TeamMemberStatus::ACTIVE)
->givenName('Joe')
->familyName('Doe')
->emailAddress('joe_doe@gmail.com')
->phoneNumber('+14159283333')
->assignedLocations(
TeamMemberAssignedLocationsBuilder::init()
->assignmentType(TeamMemberAssignedLocationsAssignmentType::EXPLICIT_LOCATIONS)
->locationIds(
[
'YSGH2WBKG94QZ',
'GA2Y9HSJ8KRYT'
]
)
->build()
)
->build()
)
->build();
$apiResponse = $teamApi->updateTeamMember(
$teamMemberId,
$body
);
if ($apiResponse->isSuccess()) {
$updateTeamMemberResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Retrieves a WageSetting
object for a team member specified
by TeamMember.id
. For more information, see
Troubleshooting the Team API.
Square recommends using RetrieveTeamMember or SearchTeamMembers
to get this information directly from the TeamMember.wage_setting
field.
function retrieveWageSetting(string $teamMemberId): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
teamMemberId |
string |
Template, Required | The ID of the team member for which to retrieve the wage setting. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type RetrieveWageSettingResponse
.
$teamMemberId = 'team_member_id0';
$apiResponse = $teamApi->retrieveWageSetting($teamMemberId);
if ($apiResponse->isSuccess()) {
$retrieveWageSettingResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());
Creates or updates a WageSetting
object. The object is created if a
WageSetting
with the specified team_member_id
doesn't exist. Otherwise,
it fully replaces the WageSetting
object for the team member.
The WageSetting
is returned on a successful update. For more information, see
Troubleshooting the Team API.
Square recommends using CreateTeamMember or UpdateTeamMember
to manage the TeamMember.wage_setting
field directly.
function updateWageSetting(string $teamMemberId, UpdateWageSettingRequest $body): ApiResponse
Parameter | Type | Tags | Description |
---|---|---|---|
teamMemberId |
string |
Template, Required | The ID of the team member for which to update the WageSetting object. |
body |
UpdateWageSettingRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a Square\Utils\ApiResponse
instance. The getResult()
method on this instance returns the response data which is of type UpdateWageSettingResponse
.
$teamMemberId = 'team_member_id0';
$body = UpdateWageSettingRequestBuilder::init(
WageSettingBuilder::init()
->jobAssignments(
[
JobAssignmentBuilder::init(
JobAssignmentPayType::SALARY
)
->jobTitle('Manager')
->annualRate(
MoneyBuilder::init()
->amount(3000000)
->currency(Currency::USD)
->build()
)
->weeklyHours(40)
->build(),
JobAssignmentBuilder::init(
JobAssignmentPayType::HOURLY
)
->jobTitle('Cashier')
->hourlyRate(
MoneyBuilder::init()
->amount(2000)
->currency(Currency::USD)
->build()
)
->build()
]
)
->isOvertimeExempt(true)
->build()
)->build();
$apiResponse = $teamApi->updateWageSetting(
$teamMemberId,
$body
);
if ($apiResponse->isSuccess()) {
$updateWageSettingResponse = $apiResponse->getResult();
} else {
$errors = $apiResponse->getErrors();
}
// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());