Skip to main content
GET
/
:projectId
/
api
/
v7
/
users
/
by-foreign-id
Fetch User by Foreign ID
curl --request GET \
  --url https://api.replyke.com/api/v6/:projectId/api/v7/users/by-foreign-id
{
  "id": "<string>",
  "foreignId": {},
  "projectId": "<string>",
  "name": {},
  "username": {},
  "avatar": {},
  "bio": {},
  "metadata": {},
  "reputation": 123,
  "avatarFile": {},
  "bannerFile": {},
  "createdAt": "<string>"
}
Finds a user within the project by their foreignId — the external identifier you provided when creating or syncing the user. Optionally creates the user if not found (requires service or master token).

Query Parameters

foreignId
string
required
The external identifier from your system.
include
string
Comma-separated list of associations to include. Pass "files" to include the processed avatarFile and bannerFile objects.
createIfNotFound
string
Set to "true" to create the user if they do not exist. Requires a service or master token. Returns 201 on creation, 200 on an existing user.
name
string
Display name to set when creating the user (createIfNotFound only).
username
string
Username to assign when creating the user (createIfNotFound only).
avatar
string
Avatar URL to set when creating the user (createIfNotFound only).
bio
string
Bio text to set when creating the user (createIfNotFound only).
metadata
string
JSON-encoded public metadata to set when creating the user (createIfNotFound only).
secureMetadata
string
JSON-encoded private metadata to set when creating the user (createIfNotFound only).

Response

Returns HTTP 200 (found) or 201 (created) with the user object:
id
string
Unique user ID (UUID).
foreignId
string | null
The foreign ID you provided.
projectId
string
Project this user belongs to.
name
string | null
Display name.
username
string | null
Unique username within the project.
avatar
string | null
Avatar image URL.
bio
string | null
Short bio text.
metadata
object | null
Public custom key-value data.
reputation
number
Reputation score.
avatarFile
object | null
Processed avatar image with variants. Only present when include=files is requested.
bannerFile
object | null
Processed banner image with variants. Only present when include=files is requested.
createdAt
string
ISO timestamp of account creation.
createIfNotFound=true is only permitted with a service or master token. Client tokens receive a 404 if the user does not exist.

Error Responses

{
  "error": "User not found",
  "code": "user/not-found"
}
{
  "error": "...",
  "code": "user/invalid-query"
}

See Also