Create User
Register one trader in the community that owns your API key, and store their broker customer ID in the same call.
- Method
- POST
- Path
https://api.returning.ai / v1/ users - Permission
- createUser
- Retries
- No Idempotency-Key; read back before retrying
When to use this
- A trader signs up on your platform and needs a loyalty account straight away.
- You sign traders in with your own login (OAuth or single sign-on), so they never get a separate password.
- You want the broker customer ID attached from the start, so activity data matches the right trader.
Authentication#
- Header
Authorization: Bearer <API_KEY>- Permission
- createUserShown in the dashboard as “Create User”
The API key decides which community the trader joins, so never send a communityId. Keep the key on your server, and never place an API key, broker credential or login token in customFields.
Request#
Headers#
Body#
Required fields are firstname, lastname, username and accessLevel. For traders who sign in through your platform, omit password and confirmPassword and set joinServer to true.
Trader.Rule1-64 chars
Eg"Sample"
Rule1-64 chars
Eg"Trader"
_ or .; no @.Rule2-32 chars; ^[a-zA-Z0-9][a-zA-Z0-9._]*[a-zA-Z0-9]$
Eg"sample_trader"
username.RuleMax 50 chars
Eg"Sample Trader"
RuleEmail format
Eg"trader@example.com"
1.Rule0-99999
Eg1
true for traders who sign in through your platform.RuleDefault false
Egtrue
Rule8-20 chars, one number, one special character, no spaces, not equal to username
Eg"StrongPass1!"
password and must match it.RuleMust equal password
Eg"StrongPass1!"
false for traders who sign in through your platform.RuleDefault false
Egfalse
false for traders who sign in through your platform.RuleDefault false
Egfalse
sendEmail is true.Eg"0"
Rule^\d+$
Eg"080374893013"
RuleSupported country name
Eg"Thailand"
externalId is not configured.Eg[{"fieldIdorName": "customerid", "value": "<brokerCustomerId>"}]
fieldIdOrName.RuleSend this or fieldIdOrName
Eg"customerid"
fieldIdorName.RuleAlias; send one of the two
Eg"customerid"
false, 0 and an empty multi-line string are kept.RuleMatches the field's type
Eg"<brokerCustomerId>"
RuleNeeds an active identifier field
Eg"<brokerCustomerId>"
Eg"<referrerReferralValue>"
curl --request POST \
--url https://api.returning.ai/v1/users \
--header 'Authorization: Bearer <API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"firstname": "Sample",
"lastname": "Trader",
"username": "sample_trader",
"displayname": "Sample Trader",
"email": "trader@example.com",
"accessLevel": 1,
"joinServer": true,
"sendEmail": false,
"emailPassword": false,
"externalId": "<brokerCustomerId>"
}'
Response#
A 200 means the trader and their community membership are saved. Save data.userId, then confirm the trader with Get User Data. Email, referral tracking and analytics follow after the response and never turn a saved trader into an error.
Rulesuccess
RuleUSER_CREATED
Eg"User created successfully"
Eg{ ... }
RuleDecimal digits
Eg"3247779"
Eg"sample_trader"
RuleEmail format
Eg"trader@example.com"
Eg"66f000000000000000000001"
Eg"customerid"
Eg"<brokerCustomerId>"
true when a new trader was saved.Egtrue
{
"status": "success",
"code": "USER_CREATED",
"message": "User created successfully",
"data": {
"userId": "3247779",
"username": "sample_trader",
"email": "trader@example.com",
"communityMemberId": "66f000000000000000000001",
"identifierKey": "customerid",
"externalId": "<brokerCustomerId>",
"created": true
}
}
Errors#
401 and 403 responses carry the code in meta.code. A body that fails validation returns 400 with a detail object naming each field, and no code or data. Every other error carries its code in code, and for coded 400 and 409 errors data.created is false. No 400 or 409 saves a trader.
Fix the request08
accessLevel or a username with a character other than letters, numbers, _ and .. There is no code or data; detail names each field. Nothing was saved.PASSWORD_MISMATCHFix the requestpassword and confirmPassword differ. Send matching values.PASSWORD_MATCHES_USERNAMEFix the requestEXTERNAL_IDENTIFIER_REQUIREDFix the requestexternalId or the identifier in customFields.EXTERNAL_IDENTIFIER_CONFLICTFix the requestexternalId and the identifier in customFields disagree. Send one value.INVALID_CUSTOM_FIELDSFix the requesterrorFields, and keep valid false, 0 and empty values.AUTHENTICATION_REQUIREDFix the requestAuthorization: Bearer <API_KEY> with a current key.API_KEY_PERMISSION_DENIEDFix the requestcreateUser. Add the permission in Settings > Integration > API Keys.Fix the data04
DUPLICATE_EMAILFix the dataDUPLICATE_USERNAMEFix the dataDUPLICATE_EXTERNAL_IDFix the dataEXTERNAL_IDENTIFIER_NOT_CONFIGUREDFix the datacustomFields, or set up the field first.Retry with backoff01
USER_CREATE_FAILEDRetry with backoffDo not retry01
USER_CREATION_RECONCILIATION_REQUIREDDo not retrydata.userId and your identifier.{
"status": "fail",
"code": "DUPLICATE_EMAIL",
"message": "Email already exists",
"data": {
"created": false
}
}