class

Anthropic::BetaUserProfiles

Inherits Reference < Object

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)
Source

Instance methods

create(external_id : String | Nil = nil, metadata : Hash(String, String) | Nil = nil) : BetaUserProfile

Create a new user profile.

Source
create_enrollment_url(user_profile_id : String) : BetaUserProfileEnrollmentURL

Create an enrollment URL for the given user profile.

Send the returned URL to the end user so they can complete enrollment.

Source
list(limit : Int32 = 20, order : String | Nil = nil, page : String | Nil = nil) : BetaUserProfileListResponse

List user profiles with optional pagination.

order may be "asc" or "desc".

Source
retrieve(user_profile_id : String) : BetaUserProfile

Retrieve a user profile by ID.

Source
update(user_profile_id : String, external_id : String | Nil = nil, metadata : Hash(String, 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.

Source