# Pick Shift

## Endpoint

| Environment | URL |
| --- | --- |
| Production | `https://online-gateway.ghn.vn/shiip/public-api/v2/shift/date` |
| Staging | `https://dev-online-gateway.ghn.vn/shiip/public-api/v2/shift/date` |

**Method**: `GET`

## Headers

| Header | Required | Description |
| --- | --- | --- |
| `Token` | Yes | Shop token (issued by GHN) — [get a token](https://developer.ghn.vn/en/docs/token/get-token.md) |

## Parameters

This endpoint takes **no parameters** — no body, no query string.

## Request Example

```bash
curl -X GET https://dev-online-gateway.ghn.vn/shiip/public-api/v2/shift/date \
  -H "Token: 5c1d8a9e-2f4b-11ed-..."
```

## Response

### Success (HTTP 200)

_Captured from a real Staging-environment call._

```json
{
  "code": 200,
  "message": "Success",
  "data": [
    {
      "id": 2,
      "title": "Ca lấy 15-07-2026 (12h00 - 18h00)",
      "from_time": 43200,
      "to_time": 64800
    },
    {
      "id": 3,
      "title": "Ca lấy 16-07-2026 (7h00 - 12h00)",
      "from_time": 111600,
      "to_time": 129600
    },
    {
      "id": 4,
      "title": "Ca lấy 16-07-2026 (12h00 - 18h00)",
      "from_time": 129600,
      "to_time": 151200
    }
  ]
}
```

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | Int | HTTP code (`200` on success) |
| `message` | String | Result message (`Success`) |
| `data` | Object[] | Available pickup shifts |
| `data[].id` | Int | Shift ID — pass it as `pick_shift` when creating an order. IDs are generated per date, **not a fixed enum**: always fetch the current list and never hard-code them |
| `data[].title` | String | Shift label (returned in Vietnamese): pickup date + time window |
| `data[].from_time` | Int | Shift start, in seconds from 00:00 of today (e.g. `43200` is 12:00 today; values above `86400` fall on later days) |
| `data[].to_time` | Int | Shift end, same unit and reference as `from_time` |

### Error — missing token (HTTP 401)

_Captured from a real Staging-environment call._

```json
{
  "code": 401,
  "message": "Authorization header is required!",
  "data": null
}
```

## Error Codes

| Condition | HTTP | Meaning |
| --- | --- | --- |
| `Authorization header is required!` | 401 | The `Token` header is missing |
| IP not allowed | 401 | Your account has an IP whitelist and the request came from another IP |
| `SERVER_ERROR_COMMON` | 500 | Internal error |
