Upsert many work sessions
Insert or update many work sessions in one call. update is required: it lists the columns to overwrite when a row with a conflicting unique key already exists.
curl --request PUT \
--url https://{instance}/api/v2/deliverable/work-sessions/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
[
{
"deliverableId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shopId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"endDate": "2023-11-07T05:31:56Z",
"isEdited": false,
"lastUpdatedBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shiftWorkHours": {
"startTime": "08:00",
"endTime": "17:00",
"breaks": [
{
"startTime": "12:00",
"durationInSec": 1800
}
],
"timezone": "America/New_York"
},
"externalSource": "<string>",
"externalSync": "synced",
"metadata": {
"costCode": "WELD-100",
"unionCode": "LOCAL-7"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
]
'const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
deliverableId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
workerId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
shopId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
startDate: '2023-11-07T05:31:56Z',
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
endDate: '2023-11-07T05:31:56Z',
isEdited: false,
lastUpdatedBy: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
shiftWorkHours: {
startTime: '08:00',
endTime: '17:00',
breaks: [{startTime: '12:00', durationInSec: 1800}],
timezone: 'America/New_York'
},
externalSource: '<string>',
externalSync: 'synced',
metadata: {costCode: 'WELD-100', unionCode: 'LOCAL-7'},
createdAt: '2023-11-07T05:31:56Z',
updatedAt: '2023-11-07T05:31:56Z'
}
])
};
fetch('https://{instance}/api/v2/deliverable/work-sessions/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{instance}/api/v2/deliverable/work-sessions/bulk"
payload = [
{
"deliverableId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shopId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"endDate": "2023-11-07T05:31:56Z",
"isEdited": False,
"lastUpdatedBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shiftWorkHours": {
"startTime": "08:00",
"endTime": "17:00",
"breaks": [
{
"startTime": "12:00",
"durationInSec": 1800
}
],
"timezone": "America/New_York"
},
"externalSource": "<string>",
"externalSync": "synced",
"metadata": {
"costCode": "WELD-100",
"unionCode": "LOCAL-7"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
]
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text){
"values": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"organizationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"deliverableId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shopId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"isEdited": false,
"lastUpdatedBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shiftWorkHours": {
"startTime": "08:00",
"endTime": "17:00",
"breaks": [
{
"startTime": "12:00",
"durationInSec": 1800
}
],
"timezone": "America/New_York"
},
"breakTimeInSec": 123,
"externalSource": "<string>",
"externalSync": "synced",
"metadata": {
"costCode": "WELD-100",
"unionCode": "LOCAL-7"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"rawStart": "2023-11-07T05:31:56Z",
"rawEnd": "2023-11-07T05:31:56Z"
}
]
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}Authorizations
Organization-scoped API key. Create one in the BuildingSwell app under Organization settings, API keys.
Query Parameters
Columns to overwrite when the row already exists. Repeat the parameter for each column: a single comma-separated value is read as one column name and fails at the database. Without the parameter the request is rejected with 400.
Body
Deliverable the time was logged against.
Person who did the work.
Department the session belongs to.
When the session started, in UTC.
Unique id. Generated on create unless you supply one.
When the session ended, in UTC. null means it is still open.
true when someone has edited the session by hand.
Who last changed the session.
The shift the record was worked against. Break times are local wall-clock, not UTC.
Show child attributes
Show child attributes
System the session came from, for example quickbase.
Sync state for the external system.
"synced"
Free-form key-value store. No key is guaranteed to be present, and a missing key is not the same as a null one. See the resource guide for which paths populate costCode and unionCode.
{
"costCode": "WELD-100",
"unionCode": "LOCAL-7"
}
When the record was created.
When the record last changed.
Response
The upserted work sessions.
Show child attributes
Show child attributes
curl --request PUT \
--url https://{instance}/api/v2/deliverable/work-sessions/bulk \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
[
{
"deliverableId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shopId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"endDate": "2023-11-07T05:31:56Z",
"isEdited": false,
"lastUpdatedBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shiftWorkHours": {
"startTime": "08:00",
"endTime": "17:00",
"breaks": [
{
"startTime": "12:00",
"durationInSec": 1800
}
],
"timezone": "America/New_York"
},
"externalSource": "<string>",
"externalSync": "synced",
"metadata": {
"costCode": "WELD-100",
"unionCode": "LOCAL-7"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
]
'const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
{
deliverableId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
workerId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
shopId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
startDate: '2023-11-07T05:31:56Z',
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
endDate: '2023-11-07T05:31:56Z',
isEdited: false,
lastUpdatedBy: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
shiftWorkHours: {
startTime: '08:00',
endTime: '17:00',
breaks: [{startTime: '12:00', durationInSec: 1800}],
timezone: 'America/New_York'
},
externalSource: '<string>',
externalSync: 'synced',
metadata: {costCode: 'WELD-100', unionCode: 'LOCAL-7'},
createdAt: '2023-11-07T05:31:56Z',
updatedAt: '2023-11-07T05:31:56Z'
}
])
};
fetch('https://{instance}/api/v2/deliverable/work-sessions/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{instance}/api/v2/deliverable/work-sessions/bulk"
payload = [
{
"deliverableId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shopId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"endDate": "2023-11-07T05:31:56Z",
"isEdited": False,
"lastUpdatedBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shiftWorkHours": {
"startTime": "08:00",
"endTime": "17:00",
"breaks": [
{
"startTime": "12:00",
"durationInSec": 1800
}
],
"timezone": "America/New_York"
},
"externalSource": "<string>",
"externalSync": "synced",
"metadata": {
"costCode": "WELD-100",
"unionCode": "LOCAL-7"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
]
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text){
"values": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"organizationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"deliverableId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shopId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"startDate": "2023-11-07T05:31:56Z",
"endDate": "2023-11-07T05:31:56Z",
"isEdited": false,
"lastUpdatedBy": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"shiftWorkHours": {
"startTime": "08:00",
"endTime": "17:00",
"breaks": [
{
"startTime": "12:00",
"durationInSec": 1800
}
],
"timezone": "America/New_York"
},
"breakTimeInSec": 123,
"externalSource": "<string>",
"externalSync": "synced",
"metadata": {
"costCode": "WELD-100",
"unionCode": "LOCAL-7"
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"rawStart": "2023-11-07T05:31:56Z",
"rawEnd": "2023-11-07T05:31:56Z"
}
]
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}{
"error": {
"message": "<string>",
"code": "BAD_REQUEST",
"requestId": "<string>",
"details": [
{
"path": "<string>",
"message": "<string>",
"code": "<string>"
}
],
"missingPermissions": [
"<string>"
]
},
"context": {}
}