> For the complete documentation index, see [llms.txt](https://help.openloyalty.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.openloyalty.io/api-reference/custom-field-group/create-a-custom-field-group.md).

# Create a custom field group

Management\
\
Creates a new custom field group for the given entity type. The groupKey is immutable after creation. The total number of active field definitions per store and entity type combination is capped by a configurable aggregate limit (across all groups); the number of groups is not limited on its own.

````json
{"openapi":"3.0.0","info":{"title":"Open Loyalty","version":"0.0.1"},"tags":[{"name":"Custom Field Group","description":"These endpoints allow you to manage custom field groups and their definitions."}],"servers":[{"url":"http://openloyalty.localhost"}],"security":[{"Bearer":[]},{"token":[]}],"components":{"securitySchemes":{"Bearer":{"type":"http","description":"Open Loyalty has the JWT authorization.\nTo learn what a JSON Web Token is and how it works, check out Introduction to JSON Web Tokens <https://jwt.io/introduction/>\n\n### Obtain an access token\n\nSend a request with the parameters username and password\n\n#### Definition\n\n`POST /api/admin/login_check` [Go to definition](#operation/adminLoginCheck)\\\n`POST /api/{storeCode}/member/login_check` [Go to definition](#operation/memberLoginCheck)\n\n#### Example\n\n```bash\ncurl {HOST}/api/admin/login_check\n    -H 'Content-Type: application/json;charset=UTF-8'\n    -H 'Accept: application/json, text/plain, */*'\n    --data-binary '{\"username\":\"admin\",\"password\":\"password\"}'\n```\n\n#### Example Response\n\n```json\n{\n    \"token\":\"eyJhbGciOiJSUzI1NiIsInR5cCI6...\",\n    \"refresh_token\":\"0558f8bb29948c4e54c443f...\"\n}\n```\n\n### Using JSON Web Token\n\nAdd authorization header to each request\\\n`Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...`\\\nYou can now access any API method you want under the /api prefix.\n\n#### Example\n```bash\ncurl {HOST}/api/{storeCode}/analytics/members\n    -H 'Accept: application/json'\n    -H 'Content-type: application/x-www-form-urlencoded'\n    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6...'\n```\n\n### Refresh JSON Web Token\nYou can refresh token using refresh_token that was given during login.\\\nThere are two endpoints\\\nTo refresh admin token `POST /api/token/refresh` [Go to definition](#operation/tokenRefresh)\\\nTo refresh member token `POST /api/{storeCode}/token/refresh` [Go to definition](#operation/tokenRefreshMember)\n","bearerFormat":"JWT","scheme":"bearer"},"token":{"type":"apiKey","name":"X-AUTH-TOKEN","in":"header"}},"parameters":{"storeCode":{"name":"storeCode","in":"path","description":"Store code","required":true,"schema":{"type":"string"}}},"schemas":{"CustomFieldEntityType":{"type":"string","description":"Entity type the custom field is associated with.","enum":["member","direct-campaign","automation-campaign","referral-campaign","leaderboard","challenge","reward","fortune-wheel-reward"]},"CreateCustomFieldGroupRequest":{"type":"object","additionalProperties":false,"required":["groupKey","name"],"properties":{"groupKey":{"type":"string","description":"Immutable machine-readable identifier for the group","maxLength":64},"name":{"type":"string","description":"Human-readable name of the group","maxLength":255},"description":{"type":"string","nullable":true,"description":"Optional description of the group","maxLength":1000},"sortOrder":{"type":"integer","nullable":true,"description":"Display order position"},"definitions":{"type":"array","items":{"$ref":"#/components/schemas/DefinitionRequest"},"description":"Initial field definitions for the group"}}},"DefinitionRequest":{"type":"object","required":["key","name","fieldType"],"properties":{"key":{"type":"string","description":"Immutable machine-readable identifier. Cannot be changed after creation.","maxLength":128},"name":{"type":"string","description":"Human-readable name of the field.","maxLength":255},"description":{"type":"string","nullable":true,"description":"Optional description.","maxLength":1000},"fieldType":{"$ref":"#/components/schemas/CustomFieldType"},"required":{"type":"boolean","description":"Whether this field must be filled in.","default":false},"active":{"type":"boolean","description":"Whether this field is active. Inactive fields reject value writes (400) and\nare omitted from the member-details read response, but remain visible in the\nmanagement definitions list so they can be reactivated.\n","default":true},"sortOrder":{"type":"integer","nullable":true,"description":"Display order position."},"config":{"type":"object","additionalProperties":true,"description":"Field-type-specific configuration. Structure depends on `fieldType`.\nSee `TextFieldConfig`, `IntegerFieldConfig`, `FloatFieldConfig`,\n`BooleanFieldConfig`, `DateFieldConfig`, `DateTimeFieldConfig`, `SelectFieldConfig` for the per-type shapes.\nValidated server-side against the schema selected by the sibling `fieldType`.\n"}}},"CustomFieldType":{"type":"string","description":"Type of the custom field value. Determines the allowed JSON type and the shape\nof `config` on the definition.\n\n| Type            | Value JSON type          | Config required field    |\n|-----------------|--------------------------|--------------------------|\n| `text`          | string                   | `maxLength`              |\n| `integer`       | integer                  | —                        |\n| `float`         | number                   | —                        |\n| `boolean`       | boolean                  | —                        |\n| `date`          | string (YYYY-MM-DD)      | —                        |\n| `datetime`      | string (YYYY-MM-DD HH:mm:ss.SSSSSS) | —             |\n| `single_select` | string                   | `groupOfValuesId`        |\n| `multi_select`  | array of strings         | `groupOfValuesId`        |\n| `object_array`  | array of objects / null  | `objectFields`, `maxItems` |\n","enum":["text","integer","float","boolean","date","datetime","single_select","multi_select","object_array"]},"ExpiredToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"InvalidToken":{"required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}},"type":"object"},"Unauthorized":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}},"responses":{"BadRequest":{"description":"Bad request.","content":{"application/json":{"schema":{"required":["code","message","errors"],"properties":{"code":{"type":"integer"},"message":{"type":"string"},"errors":{"type":"array","items":{"required":["message","parameters","plural","code","path"],"properties":{"message":{"type":"string"},"parameters":{},"plural":{"type":"integer","nullable":true},"code":{"type":"string"},"path":{"type":"string"}},"type":"object"}}},"type":"object"}}}},"AccessDenied":{"description":"Forbidden.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}},"NotFound":{"description":"Not found.","content":{"application/json":{"schema":{"required":["code","message"],"properties":{"code":{"type":"integer"},"message":{"type":"string"}},"type":"object"}}}}}},"paths":{"/api/{storeCode}/custom-field-groups/{entityType}":{"post":{"operationId":"_customFieldGroupCreate","tags":["Custom Field Group"],"summary":"Create a custom field group","description":"<label style=\"background-color: #D4EDBC;padding:5px;\">Management</label><br><br>\nCreates a new custom field group for the given entity type.\nThe groupKey is immutable after creation.\nThe total number of active field definitions per store and entity type combination\nis capped by a configurable aggregate limit (across all groups); the number of groups\nis not limited on its own.\n","parameters":[{"$ref":"#/components/parameters/storeCode"},{"name":"entityType","in":"path","required":true,"description":"Entity type","schema":{"$ref":"#/components/schemas/CustomFieldEntityType"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["customFieldGroup"],"properties":{"customFieldGroup":{"$ref":"#/components/schemas/CreateCustomFieldGroupRequest"}}}}}},"responses":{"201":{"description":"Custom field group created successfully","content":{"application/json":{"schema":{"type":"object","required":["groupKey"],"properties":{"groupKey":{"type":"string","description":"Key of the created custom field group"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ExpiredToken"},{"$ref":"#/components/schemas/InvalidToken"},{"$ref":"#/components/schemas/Unauthorized"}]}}}},"403":{"$ref":"#/components/responses/AccessDenied"},"404":{"$ref":"#/components/responses/NotFound"}}}}}}
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.openloyalty.io/api-reference/custom-field-group/create-a-custom-field-group.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
