> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Shifts by Name

> Call this API to run a fuzzy search on shift names and get the names and IDs of matching shifts.

Call this API to run a fuzzy search for shifts by name. The response includes the shift names and IDs.

## Request

| **Basic Information** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/shift/search](https://api.dingtalk.io/topapi/attendance/shift/search) |
| HTTP Method | POST |
| Supported app types | appType-Internal app　appType-Third-party enterprise app |
| Required permissions | qyapi\_attendance\_group\_read (attendance group read permission) |

### Query Parameters

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| access\_token | String | Yes | 6d1bxxxx | The app credential used to call this API.   - Internal app: Call the [Get the access\_token of an internal app](https://help.dingtalk.io/open/development/obtain-orgapp-token) API to obtain it. - Third-party enterprise app: Call the Get the access\_token of a third-party enterprise API to obtain it. |

### Request Body

| Name | Type | Required | Example | Description |
| - | - | - | - | - |
| op\_user\_id | String | Yes | manager4220 | The userId of the operator. |
| shift\_name | String | Yes | A | The shift name. |

### Request Example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/shift/search" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=ab85bxxxx739d5' \
-d 'op_user_id=dd_dd' \
-d 'shift_name=Regular%20Day%20Shift'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/shift/search");
OapiAttendanceShiftSearchRequest req = new OapiAttendanceShiftSearchRequest();
req.setOpUserId("dd_dd");
req.setShiftName("Regular Day Shift");
OapiAttendanceShiftSearchResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiAttendanceShiftSearchRequest("https://api.dingtalk.io/topapi/attendance/shift/search")

req.op_user_id="dd_dd"
req.shift_name="Regular Day Shift"
try:
	resp= req.getResponse(access_token)
	print(resp)
except Exception,e:
	print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiAttendanceShiftSearchRequest;
$req->setOpUserId("dd_dd");
$req->setShiftName("Regular Day Shift");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/shift/search");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/shift/search");
OapiAttendanceShiftSearchRequest req = new OapiAttendanceShiftSearchRequest();
req.OpUserId = "dd_dd";
req.ShiftName = "Regular Day Shift";
OapiAttendanceShiftSearchResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response Body

| Name | Type | Example | Description |
| - | - | - | - |
| result | TopMinimalismShiftVO\[] | | The query results. |
| name | String | Regular Day Shift | The shift name. |
| id | Number | 677995086 | The shift ID. |
| success | Boolean | true | Indicates whether the call succeeded.   - **true**: Success - **false**: Failed |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The return code message. |
| request\_id | String | 4wsw01tcq1h4 | The request ID. |

### Response Body Example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "errmsg":"ok",
  "result": [
    {
      "id": 677995086,
      "name": "Regular Day Shift"
    }
  ],
  "success": true,
  "request_id": "4wsw01tcq1h4"
}
```

### Error Codes

If the call returns an error, find a solution based on the error message in the [Global Error Codes](https://help.dingtalk.io/open/development/server-api-error-codes-1.md) document.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.