# Create Shop

> Create a new shop (pickup location) under your account.

## Endpoint

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

**Method**: `POST`

## Headers

| Header | Required | Description |
| --- | --- | --- |
| `Content-Type` | Yes | `application/json` |
| `Token` | Yes | Shop token (issued by GHN) — [get a token](https://developer.ghn.vn/en/docs/token/get-token.md) |
| `ShopId` | Yes | An existing **active** shop of your account. Even though you are creating a new shop, the request is rejected if this shop is inactive or not yours |

## Parameters

- **name** (String): Shop name
- **phone** (String): Shop contact phone. Normalized by GHN; an empty/invalid number is rejected with `PHONE_INVALID`
- **address** (String): Pickup address
- **ward_code** (String): Pickup ward code (from [Get Ward](https://developer.ghn.vn/en/docs/master-data/get-ward.md))
- **district_id** (Int): Pickup district ID (from [Get District](https://developer.ghn.vn/en/docs/master-data/get-district.md))
- **bank_account_id** (Int): Bank account to link to the shop

## Request Example

```bash
curl -X POST https://dev-online-gateway.ghn.vn/shiip/public-api/v2/shop/register \
  -H "Token: 5c1d8a9e-2f4b-11ed-..." \
  -H "ShopId: 92837" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "GHN Shirt Shop - Branch 2",
    "phone": "0987654321",
    "address": "72 Lê Thánh Tôn, P. Bến Nghé, Quận 1, TP. Hồ Chí Minh",
    "ward_code": "20308",
    "district_id": 1444
  }'
```

## Response

### Success (HTTP 200)

```json
{
  "code": 200,
  "message": "Success",
  "data": {
    "shop_id": 200996
  }
}
```

### Response Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | Int | HTTP code (`200` on success) |
| `message` | String | Result message (`Success`) |
| `data.shop_id` | Int | ID of the newly created shop. The owner is always your token's account |

### Error — missing name (HTTP 400)

_Captured from a real Staging-environment call._

```json
{
  "code": 400,
  "message": "Key: 'myRequest.Name' Error:Field validation for 'Name' failed on the 'required' tag",
  "data": null,
  "code_message": "USER_ERR_COMMON",
  "code_message_value": "Sai thông tin đầu vào. Vui lòng thử lại."
}
```

## Error Codes

| code_message | HTTP | When |
| --- | --- | --- |
| `USER_ERR_COMMON` | 400 | Missing `name` or invalid input |
| `PHONE_INVALID` | 400 | Empty or malformed `phone` |
| `WARD_IS_INVALID` | 400 | Invalid `ward_code` / `district_id` |
| `SHOP_NO_ACTIVE` / `CLIENT_NOT_BELONG_OF_SHOP` | 400 | The `ShopId` shop is inactive or not yours |
| `SERVER_ERROR_COMMON` | 500 | Internal error |
