Skip to main content

ProfileService Actions

14 actions registered.

NameDeprecated
checkBioValidity
checkDisplayNameValidity
checkEarlyAccess
checkUsernameAvailability
connectX
createProfile
deleteProfile
disconnectX
getProfile
getXAccount
getXAuthUrl
replaceProfile
searchProfiles
updateProfile

ProfileService:checkBioValidity​

Package: @metamask/profile-controller

Checks whether a bio is valid.

Parameters:

NameDescription
bioThe bio to validate.

Returns: An object with a valid boolean.

Handler signature:

(bio: string) => Promise<FieldValidityResponse>

ProfileService:checkDisplayNameValidity​

Package: @metamask/profile-controller

Checks whether a display name is valid.

Parameters:

NameDescription
displayNameThe display name to validate.

Returns: An object with a valid boolean.

Handler signature:

(displayName: string) => Promise<FieldValidityResponse>

ProfileService:checkEarlyAccess​

Package: @metamask/profile-controller

Checks whether the authenticated profile has early access. The profile is resolved server-side from the verified bearer token.

Returns: An object with a hasAccess boolean.

Handler signature:

() => Promise<EarlyAccessResponse>

ProfileService:checkUsernameAvailability​

Package: @metamask/profile-controller

Checks whether a username is available.

Parameters:

NameDescription
usernameThe username to check.

Returns: Availability details including validity and normalized form.

Handler signature:

(username: string) => Promise<UsernameAvailabilityResponse>

ProfileService:connectX​

Package: @metamask/profile-controller

Completes the X OAuth PKCE flow and links the X account to the profile. The profile is resolved server-side from the verified bearer token.

Parameters:

NameDescription
paramsThe OAuth callback code and state from the X redirect.

Returns: The linked X account data.

Handler signature:

(params: ConnectXParams) => Promise<ConnectXResponse>

ProfileService:createProfile​

Package: @metamask/profile-controller

Creates a new MetaMask profile.

Parameters:

NameDescription
paramsThe profile creation parameters.

Returns: The created profile data.

Handler signature:

(params: CreateProfileParams) => Promise<CreateProfileResponse>

ProfileService:deleteProfile​

Package: @metamask/profile-controller

Deletes a profile by its identifier.

Parameters:

NameDescription
profileIdThe identifier of the profile to delete.

Returns: The result of the mutation.

Handler signature:

(profileId: string) => Promise<void>

ProfileService:disconnectX​

Package: @metamask/profile-controller

Disconnects the X account linked to the authenticated profile. Identity is resolved server-side from the verified bearer token, so the request targets the shared account endpoint rather than a profile-scoped path. A 404 response is treated as success (no X account is linked), making the operation idempotent.

Parameters:

NameDescription
profileIdThe ID of the profile whose cached data should be invalidated after the disconnection. The API resolves the linked X account from the bearer token, not from this value.

Returns: The result of the mutation.

Handler signature:

(profileId: string) => Promise<void>

ProfileService:getProfile​

Package: @metamask/profile-controller

Fetches a profile by its identifier.

Parameters:

NameDescription
profileIdThe profile identifier to fetch.

Returns: The profile data from the API.

Handler signature:

(profileId: string) => Promise<ProfileApiResponse>

ProfileService:getXAccount​

Package: @metamask/profile-controller

Fetches the X account currently linked to the authenticated profile. The profile is resolved server-side from the verified bearer token.

Returns: The linked X account data.

Handler signature:

() => Promise<XAccountResponse>

ProfileService:getXAuthUrl​

Package: @metamask/profile-controller

Fetches the X OAuth PKCE authorization URL and its associated state parameter. The profile is resolved server-side from the verified bearer token.

Returns: An object containing the authorization URL and the state token.

Handler signature:

() => Promise<XAuthUrlResponse>

ProfileService:replaceProfile​

Package: @metamask/profile-controller

Fully replaces an existing profile (PUT).

Parameters:

NameDescription
profileIdThe identifier of the profile to replace.
paramsThe replacement profile data.

Returns: The updated profile data.

Handler signature:

(profileId: string, params: ReplaceProfileParams) => Promise<ProfileApiResponse>

ProfileService:searchProfiles​

Package: @metamask/profile-controller

Searches public profiles by fuzzy-matching usernames and display names. Results are ranked by the API and returned 10 at a time; pass the returned next_cursor back as cursor to fetch the next page. The API caps the total depth per query, after which next_cursor is null.

The search text is sent as typed; the API normalizes it. Responses are cached for 30 seconds, matching the API's Cache-Control header.

Parameters:

NameDescription
paramsThe search parameters.
params.queryThe text to search for (2 to 50 characters after normalization).
params.cursorThe next_cursor from the previous page, if any.

Returns: A page of profile summaries and the cursor for the next page, or null when there are no more results.

Handler signature:

({ query, cursor, }: SearchProfilesParams) => Promise<SearchProfilesResponse>

ProfileService:updateProfile​

Package: @metamask/profile-controller

Partially updates an existing profile (PATCH).

Parameters:

NameDescription
profileIdThe identifier of the profile to update.
paramsThe fields to update.

Returns: The updated profile data.

Handler signature:

(profileId: string, params: UpdateProfileParams) => Promise<ProfileApiResponse>