Skip to content

Create custom field definition

Request

Create a new custom field for the tenant. Key must be unique within tenant+entityType.

Security
authJWT
Bodyapplication/jsonrequired
entityTypestringrequired

Entity type this field applies to

Enum:"user""business""campaign""redemption"
keystringrequired

Unique key within tenant+entityType (camelCase)

labelstringrequired

Human-readable label for form display

descriptionobject

Help text / description

fieldTypestring

Field type: text, email, phone, number, date, boolean, url, select, multiselect

Default:"text"
Enum:"text""email""phone""number""date""boolean""url""select""multiselect"
selectOptionsArray of objects

For select/multiselect types: static options array

selectOptionsSourceobject

For select/multiselect types: dynamic options from entity

validationobject

Validation rules for the field

sortOrdernumber

Display order (lower = first)

Default:0
translationsobject

Per-locale translations keyed by locale (e.g. "de", "ar-sa"). Translatable fields: label, description, option.*.

Example:
{ "de": { "label": "..." }, "fr": null }
curl -i -X POST \
  https://docs.pers.ninja/_mock/swagger/custom-field-definitions \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "entityType": "user",
    "key": "string",
    "label": "string",
    "description": {},
    "fieldType": "text",
    "selectOptions": [
      {
        "value": "string",
        "label": "string"
      }
    ],
    "selectOptionsSource": {},
    "validation": {},
    "sortOrder": 0,
    "translations": {
      "de": {
        "label": "..."
      },
      "fr": null
    }
  }'

Responses

Field created

Bodyapplication/json
idstringrequired

Unique identifier (UUID)

tenantIdstringrequired

Tenant ID

entityTypestringrequired

Entity type this field applies to

Enum:"user""business""campaign""redemption"
keystringrequired

Unique key within tenant+entityType (camelCase)

labelstringrequired

Human-readable label for form display

descriptionobject

Help text / description

fieldTypestringrequired

Field type: text, email, phone, number, date, boolean, url, select, multiselect

Default:"text"
Enum:"text""email""phone""number""date""boolean""url""select""multiselect"
selectOptionsArray of objects

For select/multiselect types: static options array

selectOptionsSourceobject

For select/multiselect types: dynamic options from entity

validationobject

Validation rules for the field

translationsobject

Per-locale translations of label, description and select option labels (option.<value>), keyed by locale. Only returned with include=translations.

sortOrdernumberrequired

Display order (lower = first)

Default:0
isCustomobjectread-onlyrequired

Marker to distinguish from built-in fields. Custom fields are stored in user.customData

Default:true
createdAtstring, (date-time)required

Creation timestamp

updatedAtstring, (date-time)required

Last update timestamp

Response
{ "id": "string", "tenantId": "string", "entityType": "user", "key": "string", "label": "string", "description": {}, "fieldType": "text", "selectOptions": [ { … } ], "selectOptionsSource": {}, "validation": {}, "translations": { "property1": { … }, "property2": { … } }, "sortOrder": 0, "isCustom": true, "createdAt": "2019-08-24T14:15:22Z", "updatedAt": "2019-08-24T14:15:22Z" }