# Bulk Assign Locations to Districts

`POST /api/v1/locations/bulk-district-assignments`

Assigns many locations to districts within a single district group in one request. The group's `index` determines which slot is written (index 0 → `district_id`, otherwise `district_id_2`). Every assigned district must belong to the named district group. Requires the `update` ability and `create` permission on locations.

## Request body

```json
{
    "district_group_id": "e1a4c8b2-7d3f-4b6e-9a2c-8f5d1e3b7a90",
    "assignments": [
        {
            "location": "9b1c8f3e-7a2d-4c5b-8e1a-2f3d4c5b6a7e",
            "district_id": "3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9"
        }
    ]
}
```

## Example request

```bash
curl -X POST "https://app.franchisesee.com/api/v1/locations/bulk-district-assignments" \
  -H "Authorization: Bearer $FRANCHISESEE_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "district_group_id": "e1a4c8b2-7d3f-4b6e-9a2c-8f5d1e3b7a90",
    "assignments": [
        {
            "location": "9b1c8f3e-7a2d-4c5b-8e1a-2f3d4c5b6a7e",
            "district_id": "3f2a1b0c-9d8e-4f7a-b6c5-d4e3f2a1b0c9"
        }
    ]
}'
```

## Responses

### 200 Success

```json
{
    "district_group": "Region",
    "district_column": "district_id",
    "total": 3,
    "success_count": 2,
    "error_count": 1,
    "results": [
        {
            "index": 0,
            "location": "Downtown Austin",
            "district": "Central Texas",
            "status": "success"
        }
    ]
}
```

### 401 Authentication failed or missing.

```json
{
    "message": "Unauthenticated."
}
```

### 403 The token lacks the required ability or the caller is not permitted.

```json
{
    "message": "This API token does not have the 'create' ability."
}
```

### 422 Validation failed.

```json
{
    "message": "The name field is required.",
    "errors": {
        "name": [
            "The name field is required."
        ]
    }
}
```
