Anthropic::BetaUserProfiles
User Profiles API (beta) for creating and managing per-end-user state.
Access via client.beta.user_profiles.
profile = client.beta.user_profiles.create(
external_id: "user-123",
metadata: {"plan" => "pro"}
)
enrollment = client.beta.user_profiles.create_enrollment_url(profile.id)
puts enrollment.url
# Pass the profile id when creating a message so the API applies
# per-user state like memory.
client.beta.messages.create(
model: Anthropic::Model::CLAUDE_OPUS_4_7,
max_tokens: 1024,
messages: [Anthropic::MessageParam.user("Hi!")],
user_profile_id: profile.id
)
Constants
BETA_HEADER = USER_PROFILES_BETA
Constructors
new(client : Client)
SourceInstance methods
create(external_id : String | Nil = nil, metadata : Hash(String, String) | Nil = nil, access_type : String | Nil = nil, name : String | Nil = nil, external_user_onboarded_at : String | Nil = nil) : BetaUserProfile
Create a new user profile.
Create an enrollment URL for the given user profile.
Send the returned URL to the end user so they can complete enrollment.
list(limit : Int32 = 20, order : String | Nil = nil, order_by : String | Nil = nil, page : String | Nil = nil) : BetaUserProfileListResponse
List user profiles with optional pagination.
order may be "asc" or "desc". order_by selects the sort key
(e.g. "name").
update(user_profile_id : String, external_id : String | Nil = nil, metadata : Hash(String, String) | Nil = nil, access_type : String | Nil = nil, name : String | Nil = nil, external_user_onboarded_at : String | Nil = nil) : BetaUserProfile
Update metadata or external_id for an existing user profile.
To remove a metadata key, set its value to an empty string. Keys not provided are left unchanged.