Create a user field definition
Add a custom user field to your community, such as a KYC status, and get back the key you use to write traders' values.
- Method
- POST
- Path
https://api.returning.ai / v1/ communities/ {communityId}/ user-fields - Permission
- userFields
- Retries
- Idempotency-Key makes retries safe
When to use this
- You want to track a trader attribute from your platform, such as KYC status, account tier or trading volume.
- You are setting up a new integration and its fields don't exist yet.
- You want a typed field that milestones and data workflows can react to when a trader's value changes.
Authentication#
- Header
Authorization: Bearer <API_KEY>- Permission
- userFieldsShown in the dashboard as “User Fields”
Use a Community API key with the userFields permission, and keep it on your server. communityId must be the ID of the community that owns the key.
Behaviour#
The key is cleaned up before it is saved: surrounding spaces are removed, capitals become lowercase and spaces inside become _, so KYC Status is stored as kyc_status. Save data.field from the response, not what you sent. The key can never change; the name, type and default can.
Select-dropdown fields can be created, but their values can't be written with Update a user field value yet.
Request#
Path parameters#
Rule24 hex characters
Eg"66f000000000000000000010"
Headers#
Body#
Send only name, field, type and, optionally, defaultValue; any other property is rejected. A non-null defaultValue must match type exactly:
single-line-text: a string of 1-255 characters with no line breaks.multi-line-text: any string, including an empty one.numerical: a JSON number, not a string.boolean:trueorfalse.date: a real date asYYYY-MM-DD.time:HH:mm:ss, 24-hour.date-time:YYYY-MM-DDTHH:mm:ss, with optional milliseconds and an optionalZor offset such as+08:00.single-select-dropdown: a string or number.multi-select-dropdown: an array of them.
RuleASCII letters, numbers, spaces, - and _
Eg"KYC status"
_ and capitals become lowercase.RuleAfter cleanup: 1-120 chars of a-z, 0-9, _, -
Eg"kycstatus"
Rulesingle-line-text, multi-line-text, numerical, date, time, date-time, boolean, single-select-dropdown, multi-select-dropdown
Eg"single-line-text"
null for none.RuleMatches type; see Request body
curl --request POST \
--url https://api.returning.ai/v1/communities/66f000000000000000000010/user-fields \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: create-field-<unique-id>' \
--data '{
"name": "KYC status",
"field": "kycstatus",
"type": "single-line-text"
}'
Response#
A 201 means the field is saved. Branch on the HTTP status and meta.code, never on message.
Eg{ ... }
Rulesuccess
Rule201
RuleUSER_FIELD_CREATED
attempted normally. failed means open dashboards were not refreshed; the field is still saved.true when this repeats the first response for your Idempotency-Key. Nothing new was created.degraded when the field was saved but a retry with the same key may not replay this response. Treat the field as created.Eg"Create user field api success."
Eg{ ... }
Rule^[0-9a-fA-F]{24}$
Eg"66f000000000000000000510"
Eg"KYC status"
Rulea-z, 0-9, _, -
Eg"kycstatus"
Rulesingle-line-text, multi-line-text, numerical, date, time, date-time, boolean, single-select-dropdown, multi-select-dropdown
Eg"single-line-text"
true for fields you create.{
"meta": {
"status": "success",
"statusCode": 201,
"code": "USER_FIELD_CREATED",
"compatibilityEvent": "attempted"
},
"message": "Create user field api success.",
"data": {
"_id": "66f000000000000000000510",
"name": "KYC status",
"field": "kycstatus",
"type": "single-line-text",
"isCustom": true,
"createdAt": "2026-09-26T08:30:00.000Z",
"updatedAt": "2026-09-26T08:30:00.000Z"
}
}
Errors#
Every JSON error carries its code in meta.code. The exception is a request with no Authorization header and a JSON body: it returns 400 with a non-JSON body instead of 401. A 400 or 409 creates nothing.
Fix the request06
Authorization header was sent. With a JSON body this returns 400 with a non-JSON body (Request body must encrypted), not 401. Send Authorization: Bearer <API_KEY>.INVALID_FIELD_DEFINITIONFix the requestname, field, type or defaultValue broke a rule, or the body has an extra property. detail names the field when it can. Nothing was created.INVALID_IDEMPOTENCY_KEYFix the requestIdempotency-Key must be 1-200 visible ASCII characters with no spaces.AUTHENTICATION_REQUIREDFix the requestAuthorization: Bearer <API_KEY> with a current Community API key.API_KEY_PERMISSION_DENIEDFix the requestuserFields. Add the permission in Settings > Integration > API Keys.API_KEY_COMMUNITY_MISMATCHFix the requestcommunityId is not the community that owns your key. Use your own community's ID.Fix the data04
USER_FIELD_KEY_CONFLICTFix the dataUSER_FIELD_NAME_CONFLICTFix the dataIDEMPOTENCY_KEY_CONFLICTFix the dataIdempotency-Key was already used for a different field. Use a new key for a new field.COMMUNITY_NOT_FOUNDFix the dataRetry with backoff02
USER_FIELD_OPERATION_FAILEDRetry with backoffIDEMPOTENCY_STORE_UNAVAILABLERetry with backoffDo not retry01
IDEMPOTENCY_REQUEST_IN_PROGRESSDo not retry{
"meta": {
"status": "error",
"statusCode": 400,
"code": "INVALID_FIELD_DEFINITION"
},
"message": "Create user field api error.",
"detail": {
"field": [
"field must use ASCII letters, numbers, \"_\", or \"-\" after normalization."
]
},
"solution": "Check the request body and try again."
}