# Update a customer group

URL: https://docs.sparklayer.io/developers/api/core/update-customer-group
Operation: `PATCH /api/v1/customer-groups/{slug}` (operationId `updateCustomerGroup`)
OpenAPI spec: https://docs.sparklayer.io/openapi/core.yaml

Sets the group's `name` and `parent_slug` and returns the full, updated list of groups. If you omit `parent_slug`, the parent is reset to `base`. An unknown slug returns `400` (`resource-id-not-found`) rather than `404`.

`PATCH /api/v1/customer-groups/{slug}`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl -X PATCH "https://app.sparklayer.io/api/v1/customer-groups/eu_gbp" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Europe (GBP) Customers",
  "parent_slug": "base"
}'
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `slug` | string | Yes | The customer group's slug, as returned by **List customer groups** (for example `eu_gbp`). Example: `eu_gbp` |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Example: `jones-climbing` |

### Request body (`application/json`) (required)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | Yes | Length: max 256. |
| `parent_slug` | string | | Length: max 128. |

```json
{
  "name": "Europe (GBP) Customers",
  "parent_slug": "base"
}
```

### Responses

#### 200: Every customer group, including the updated one.

An array. Each item:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `[].slug` | string | Yes | Length: max 128. |
| `[].name` | string | Yes | Length: max 256. |
| `[].parent_slug` | string | | Length: max 128. |

```json
[
  {
    "slug": "eu_gbp",
    "name": "Europe (GBP) Customers",
    "parent_slug": "base"
  }
]
```

#### Other statuses: An error. The body describes the problem: see [Errors](https://docs.sparklayer.io/developers/errors.md).

`application/problem+json`: the standard error body (below).

### Error body

Error responses with a body use this RFC 7807 problem details object. See [Errors](https://docs.sparklayer.io/developers/errors.md) for every status code and which errors to retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string \| null | | |
| `errors` | object[] \| null | | A list of errors related to the call |
| `errors[].code` | string | | Machine-readable error code |
| `errors[].property` | string | | The property the error relates to |
| `errors[].message` | string | | Human readable summary of the error |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://docs.sparklayer.io/api/errors#invalid-api-request-contents",
  "errors": [
    {
      "code": "resource-not-found",
      "property": "stock_location_id",
      "message": "stock_location_id not found"
    }
  ]
}
```
