{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":584,"path":"api-reference/rest-apis/wsd_shift-api.md","title":"WSD Shift API","bundle":null,"doc_type":null,"release":"australia","body":"\n# WSD Shift API\n\nThe Workplace Service Delivery \\(WSD\\) Shift API provides an endpoint that returns shift time spans for a specified date and time.\n\nTo access this API, the caller must have the sn\\_wsd\\_core.workplace\\_user role and the Workplace Safety Management \\(sn\\_wsd\\_core\\) and Workplace Reservation Management \\(sn\\_wsd\\_rsv\\) plugins must be activated.\n\nThis API runs in the `sn_wsd_rsv` namespace.\n\nFor additional information on Workplace Reservation Management, see [Workplace Reservation Management](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/employee-service-management/workplace-rsv-mgmt-feat.md).\n\n**Parent Topic:**[REST API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-apis/api-rest.md)\n\n## WSD Shift - GET /api/sn\\_wsd\\_rsv/wsd\\_shift/\\{shift\\_id\\}/timespan\n\nReturns the shift time span for a specified date/time and shift.\n\n### URL format\n\nVersioned URL: `/api/sn_wsd_rsv/{api_version}/wsd_shift/{shift_id}/timespan`\n\nDefault URL: `/api/sn_wsd_rsv/wsd_shift/{shift_id}/timespan`\n\n**Note:** Available versions are specified in the [REST API Explorer](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/use-REST-API-Explorer.md). For scripted REST APIs there is additional version information on the [Scripted REST Service form](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_CustomWebServices.md).\n\n### Supported request parameters\n\n<table class=\"rest_api_path_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\napi\\_version\n\n</td><td id=\"version-entry-RESTAPI\">\n\nOptional. Version of the endpoint to access. For example, `v1` or `v2`. Only specify this value to use an endpoint version other than the latest. Data type: String\n\n</td></tr><tr><td>\n\nshift\\_id\n\n</td><td>\n\nSys\\_id of the shift to retrieve the time span for.For additional information on shift-based reservations, see [Enable shift-based reservation](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/employee-service-management/wsd-reservation-setup.md).\n\nData type: String\n\nTable: Shift \\[sn\\_wsd\\_core\\_shift\\]\n\n</td></tr></tbody>\n</table><table class=\"rest_api_query_parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nattempt\\_earlier\\_start\n\n</td><td>\n\nFlag that indicates whether to set an early start time if the specified start value is within the shift's time span.Valid values:\n\n-   true: If the specified shift includes the date/time specified in the **start** parameter, return the specified start date/time as the start of the time span.\n-   false: Return the shift timespan as defined in the associated record.\n\nData type: Boolean\n\nDefault: false\n\n</td></tr><tr><td>\n\nstart\n\n</td><td>\n\nRequired. Date and time of the start of the shift time spans to return.Format: UTC - yyyy-mm-ddThh:mm:ssZ, such as 2022-05-23T08:00:00Z\n\n</td></tr><tr><td>\n\ntimezone\n\n</td><td>\n\nTime zone to use when qualifying the shift time spans, such as ECT or PST. Also returns the shift time spans in this time zone.Format: UTC\n\nData type: String\n\nDefault: User's timezone\n\n</td></tr></tbody>\n</table>|Name|Description|\n|----|-----------|\n|None| |\n\n### Headers\n\nThe following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see [Supported REST API headers](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n<table class=\"rest_api_request_headers\"><thead><tr><th>\n\nHeader\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nAccept\n\n</td><td id=\"accept-reserv-entry\">\n\nData format of the request body. Supported types: **application/json**, **application/xml** or, **text/xml**. Default: **application/json**\n\n</td></tr></tbody>\n</table>|Header|Description|\n|------|-----------|\n|None| |\n\n### Status codes\n\nThe following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see [REST API HTTP response codes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/rest-api-explorer/c_RESTAPI.md).\n\n|Status code|Description|\n|-----------|-----------|\n|200|Successful. The request was successfully processed.|\n|401|Unauthorized. The user credentials are incorrect or have not been passed.|\n|404|Not found. The requested item wasn't found.|\n|500|Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error.|\n\n### Response body parameters\n\n<table><thead><tr><th>\n\nName\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nresult\n\n</td><td>\n\nDetails about the shift timespan that matched the search criteria.Data type: Object\n\n```\n\"result\":{\n  \"end\": \"String\",\n  \"start\": \"String\"\n}\n```\n\n</td></tr><tr><td>\n\nresult.end\n\n</td><td>\n\nEnd date and time of the shift timespan in the specified time zone.Format: UTC: yyyy-mm-ddThh:mm:ssZ, such as 2022-05-23T08:00:00Z\n\nData type: String\n\n</td></tr><tr><td>\n\nresult.start\n\n</td><td>\n\nStart date and time of the shift timespan in the specified time zone.Format: UTC: yyyy-mm-ddThh:mm:ssZ, such as 2022-05-23T08:00:00Z\n\nData type: String\n\n</td></tr></tbody>\n</table>### cURL request\n\nThe following code example shows how to retrieve the timespan of a shift.\n\n```\ncurl \"https://instance.servicenow.com/api/sn_wsd_rsv/wsd_shift/e5d23acfdb42a01097acc9003996193a/timespan?attempt_earlier_start=true&start=2022-05-23T08:00:00Z&timezone=ECT\" \\\n--request GET \\\n--header \"Accept:application/json\" \\\n--user \"username\":\"password\"\n```\n\nReturn results:\n\n```\n{\n  \"result\": {\n    \"start\": \"2022-05-23T08:00:00Z\",\n    \"end\": \"2022-05-23T15:00:00Z\"\n  }\n}\n```\n\n"}}