@anthropic-ai/sdk
Version:
The official TypeScript library for the Anthropic API
518 lines • 22 kB
text/typescript
import { APIResource } from "../../../core/resource.mjs";
import * as BetaAPI from "../beta.mjs";
import * as ActionURLsAPI from "./action-urls.mjs";
import { ActionURLCreateParams, ActionURLs, BetaUserProfileActionURL, BetaUserProfileEnrollEndUserAction } from "./action-urls.mjs";
import { APIPromise } from "../../../core/api-promise.mjs";
import { PageCursor, type PageCursorParams, PagePromise } from "../../../core/pagination.mjs";
import { RequestOptions } from "../../../internal/request-options.mjs";
export declare class UserProfiles extends APIResource {
actionURLs: ActionURLsAPI.ActionURLs;
/**
* Create User Profile
*
* @example
* ```ts
* const betaUserProfile =
* await client.beta.userProfiles.create();
* ```
*/
create(params: UserProfileCreateParams, options?: RequestOptions): APIPromise<BetaUserProfile>;
/**
* Get User Profile
*
* @example
* ```ts
* const betaUserProfile =
* await client.beta.userProfiles.retrieve(
* 'uprof_011CZkZCu8hGbp5mYRQgUmz9',
* );
* ```
*/
retrieve(userProfileID: string, params?: UserProfileRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<BetaUserProfile>;
/**
* Update User Profile
*
* @example
* ```ts
* const betaUserProfile =
* await client.beta.userProfiles.update(
* 'uprof_011CZkZCu8hGbp5mYRQgUmz9',
* );
* ```
*/
update(userProfileID: string, params: UserProfileUpdateParams, options?: RequestOptions): APIPromise<BetaUserProfile>;
/**
* List User Profiles
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const betaUserProfile of client.beta.userProfiles.list()) {
* // ...
* }
* ```
*/
list(params?: UserProfileListParams | null | undefined, options?: RequestOptions): PagePromise<BetaUserProfilesPageCursor, BetaUserProfile>;
/**
* Delete User Profile
*
* @example
* ```ts
* const betaDeletedUserProfile =
* await client.beta.userProfiles.delete(
* 'uprof_011CZkZCu8hGbp5mYRQgUmz9',
* );
* ```
*/
delete(userProfileID: string, params?: UserProfileDeleteParams | null | undefined, options?: RequestOptions): APIPromise<BetaDeletedUserProfile>;
/**
* Create Enrollment URL
*
* @example
* ```ts
* const betaUserProfileEnrollmentURL =
* await client.beta.userProfiles.createEnrollmentURL(
* 'uprof_011CZkZCu8hGbp5mYRQgUmz9',
* );
* ```
*/
createEnrollmentURL(userProfileID: string, params?: UserProfileCreateEnrollmentURLParams | null | undefined, options?: RequestOptions): APIPromise<BetaUserProfileEnrollmentURL>;
}
export type BetaUserProfilesPageCursor = PageCursor<BetaUserProfile>;
export interface BetaDeletedUserProfile {
/**
* Identifier of the deleted user profile, prefixed `uprof_`.
*/
id: string;
/**
* Object type. Always `user_profile_deleted`.
*/
type: 'user_profile_deleted';
}
/**
* A record of an entity that the platform serves through the API, such as an
* end-user of the platform's product or a company that the platform resells Claude
* access to.
*
* A Messages, Message Batches or token counting request can send a profile's `id`
* in the `anthropic-user-profile-id` header to attribute the request to that
* entity.
*/
export interface BetaUserProfile {
/**
* Unique identifier for this user profile, prefixed `uprof_`.
*/
id: string;
/**
* When this user profile was created, in RFC 3339 format.
*/
created_at: string;
/**
* Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up
* to 512 chars.
*/
metadata: {
[key: string]: string;
};
/**
* Real-world name of the entity this profile represents (company or individual).
* For a company the platform resells Claude access to (`access_type`
* `passthrough`) this is that company's name. `null` until the platform supplies
* one.
*/
name: string | null;
/**
* Trust grants for this profile, keyed by grant name. Key omitted when no grant is
* active or in flight.
*/
trust_grants: {
[key: string]: BetaUserProfileTrustGrant;
};
/**
* Object type. Always `user_profile`.
*/
type: 'user_profile';
/**
* When this user profile was last modified, in RFC 3339 format. It normally also
* updates shortly after Anthropic gives the profile an approval or withdraws one.
* Other changes to the statuses that Anthropic reports do not always update it, so
* read the status itself rather than watching this timestamp.
*/
updated_at: string;
/**
* How the platform uses the API for this entity: `application` (default) or
* `passthrough`. Absent under the legacy `user-profiles-2026-03-24` beta header.
*
* - `application` - The user profile represents an individual end-user of a
* product that the platform builds on the API. New profiles get this value by
* default.
* - `passthrough` - The user profile represents a company that the platform
* resells Claude access to.
*/
access_type?: 'application' | 'passthrough';
/**
* Platform's own identifier for this user. Not enforced unique. Legacy field,
* present only under the `user-profiles-2026-03-24` and `user-profiles-2026-08-18`
* beta headers; without one of them, the value is
* `external_user_details.reference_id`.
*/
external_id?: string | null;
/**
* Details about the entity this profile represents, as the platform states them;
* not verified by Anthropic. Every field is present, `null` until the platform
* supplies a value. Absent under the legacy `user-profiles-2026-03-24` and
* `user-profiles-2026-08-18` beta headers, which serve `reference_id` as the
* top-level `external_id` and, under `user-profiles-2026-08-18`, `onboarded_at` as
* `external_user_onboarded_at`.
*/
external_user_details?: BetaUserProfileExternalUserDetails;
/**
* When the entity this profile represents opened its account with the platform, as
* stated by the platform, in RFC 3339 format (UTC). `null` until the platform
* supplies one. Legacy field, present only under the `user-profiles-2026-08-18`
* beta header; without a legacy header, the value is
* `external_user_details.onboarded_at`.
*/
external_user_onboarded_at?: string | null;
}
/**
* A URL to give to the entity that a user profile represents, so that the entity
* can enroll in a program.
*/
export interface BetaUserProfileEnrollmentURL {
/**
* When this enrollment URL expires, in RFC 3339 format.
*/
expires_at: string;
/**
* Object type. Always `enrollment_url`.
*/
type: 'enrollment_url';
/**
* Enrollment URL to send to the end user. Valid until `expires_at`.
*/
url: string;
}
/**
* Details about the entity this profile represents, as the platform states them.
* Anthropic does not verify them. Every field is present, `null` until the
* platform supplies a value.
*/
export interface BetaUserProfileExternalUserDetails {
/**
* The status of the entity's account on the platform: `active`, `suspended` or
* `blocked`. `null` until the platform supplies one.
*
* - `active` - The platform has neither restricted nor barred the account of the
* entity that the user profile represents.
* - `suspended` - The platform has restricted the account of the entity that the
* user profile represents and may restore it.
* - `blocked` - The platform has barred the account of the entity that the user
* profile represents.
*/
account_status: 'active' | 'suspended' | 'blocked' | null;
/**
* The country the platform associates with the entity, as an ISO 3166-1 alpha-2
* code. `null` until the platform supplies one.
*/
country: string | null;
/**
* The platform-computed hash of the entity's email address. `null` until the
* platform supplies one.
*/
email_hash: string | null;
/**
* What kind of entity the profile represents: `individual`, `business`,
* `non_profit` or `government`. `null` until the platform supplies one.
*/
entity_type: 'individual' | 'business' | 'non_profit' | 'government' | null;
/**
* The platform-computed hash of the entity's name. `null` until the platform
* supplies one.
*/
name_hash: string | null;
/**
* When the entity opened its account with the platform, as stated by the platform,
* in RFC 3339 format (UTC). `null` until the platform supplies one.
*/
onboarded_at: string | null;
/**
* The platform's own reference for the entity. `null` until the platform supplies
* one.
*/
reference_id: string | null;
}
export interface BetaUserProfileExternalUserDetailsParams {
/**
* The status of the entity's account on the platform: `active`, `suspended` or
* `blocked`.
*
* - `active` - The platform has neither restricted nor barred the account of the
* entity that the user profile represents.
* - `suspended` - The platform has restricted the account of the entity that the
* user profile represents and may restore it.
* - `blocked` - The platform has barred the account of the entity that the user
* profile represents.
*/
account_status?: 'active' | 'suspended' | 'blocked' | null;
/**
* The country of the entity (not of the platform), as the platform determines it:
* an ISO 3166-1 alpha-2 code in upper case, for example `US`. Only the form, two
* uppercase ASCII letters, is checked.
*/
country?: string | null;
/**
* A hash of the entity's email address, computed by the platform. Anthropic treats
* it as an opaque string and does not prescribe the hash function. 1 to 255
* characters.
*/
email_hash?: string | null;
/**
* What kind of entity the profile represents: `individual`, `business`,
* `non_profit` or `government`.
*/
entity_type?: 'individual' | 'business' | 'non_profit' | 'government' | null;
/**
* A hash of the entity's name, computed by the platform. Anthropic treats it as an
* opaque string and does not prescribe the hash function. 1 to 255 characters.
*/
name_hash?: string | null;
/**
* When the entity opened its account with the platform, in RFC 3339 format: for an
* `application` profile, when the end-user signed up; for a `passthrough` profile,
* when the company became the platform's customer. Must be a complete timestamp no
* more than 1 minute in the future.
*/
onboarded_at?: string;
/**
* The platform's own reference for the entity, for example the key of the
* end-user's row in the platform's database. Not interpreted by Anthropic and not
* enforced unique. 1 to 255 characters.
*/
reference_id?: string | null;
}
/**
* The status of one trust grant on a user profile, listed in the profile's
* `trust_grants` map under the grant's name.
*/
export interface BetaUserProfileTrustGrant {
/**
* Status of the trust grant.
*/
status: 'active' | 'pending' | 'rejected';
}
export interface UserProfileCreateParams {
/**
* Body param: How the platform uses the API for this entity. `application`
* (default): the profile represents an individual end-user of the platform's
* product. `passthrough`: the profile identifies a company the platform resells
* Claude access to.
*
* - `application` - The user profile represents an individual end-user of a
* product that the platform builds on the API. New profiles get this value by
* default.
* - `passthrough` - The user profile represents a company that the platform
* resells Claude access to.
*/
access_type?: 'application' | 'passthrough';
/**
* Body param: Platform's own identifier for this user. Not enforced unique.
* Maximum 255 characters. Legacy field, accepted only under the
* `user-profiles-2026-03-24` and `user-profiles-2026-08-18` beta headers; without
* one of them, send `external_user_details.reference_id`.
*/
external_id?: string | null;
/**
* Body param: Details about the entity this profile represents, as the platform
* states them. Every field is optional. Not accepted under the legacy
* `user-profiles-2026-03-24` and `user-profiles-2026-08-18` beta headers, which
* take the top-level `external_id` (and, under `user-profiles-2026-08-18`,
* `external_user_onboarded_at`) instead.
*/
external_user_details?: BetaUserProfileExternalUserDetailsParams;
/**
* Body param: When the entity this profile represents opened its account with the
* platform, in RFC 3339 format: for an `application` profile, when the end-user
* signed up; for a `passthrough` profile, when the company became the platform's
* customer. Must be a complete timestamp no more than 1 minute in the future.
* Optional. Legacy field, accepted only under the `user-profiles-2026-08-18` beta
* header; without a legacy header, send `external_user_details.onboarded_at`.
*/
external_user_onboarded_at?: string;
/**
* Body param: Free-form key-value data to attach to this user profile. Maximum 16
* keys, with keys up to 64 characters and values up to 512 characters. Values must
* be non-empty strings.
*/
metadata?: {
[key: string]: string;
};
/**
* Body param: Optional for all profiles. Real-world name of the entity this
* profile represents (company or individual); for a company the platform resells
* Claude access to (`access_type` `passthrough`), that company's name where known.
* Maximum 255 characters.
*/
name?: string | null;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
/**
* Header param: Optional header to select the Workspace for this request. The
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
*
* Only needed for credentials that can act on more than one Workspace. A
* credential that belongs to a specific Workspace may omit it; if sent, it must
* match that Workspace.
*/
workspace_id?: string;
}
export interface UserProfileRetrieveParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
/**
* Optional header to select the Workspace for this request. The value is a
* Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
*
* Only needed for credentials that can act on more than one Workspace. A
* credential that belongs to a specific Workspace may omit it; if sent, it must
* match that Workspace.
*/
workspace_id?: string;
}
export interface UserProfileUpdateParams {
/**
* Body param: If present, replaces the stored access type. Omit to leave
* unchanged.
*
* - `application` - The user profile represents an individual end-user of a
* product that the platform builds on the API. New profiles get this value by
* default.
* - `passthrough` - The user profile represents a company that the platform
* resells Claude access to.
*/
access_type?: 'application' | 'passthrough' | null;
/**
* Body param: If present, replaces the stored external_id. Omit to leave
* unchanged. Maximum 255 characters. Legacy field, accepted only under the
* `user-profiles-2026-03-24` and `user-profiles-2026-08-18` beta headers; without
* one of them, send `external_user_details.reference_id`.
*/
external_id?: string | null;
/**
* Body param: Details about the entity this profile represents, as the platform
* states them. Each field sent replaces the stored value; omit a field to leave it
* unchanged. Once set, a value cannot be cleared and `null` is rejected. Not
* accepted under the legacy `user-profiles-2026-03-24` and
* `user-profiles-2026-08-18` beta headers.
*/
external_user_details?: BetaUserProfileExternalUserDetailsParams;
/**
* Body param: If present, replaces the stored account creation time. Omit to leave
* unchanged; once set, the value cannot be cleared and `null` is rejected. Must be
* a complete RFC 3339 timestamp no more than 1 minute in the future. Legacy field,
* accepted only under the `user-profiles-2026-08-18` beta header; without a legacy
* header, send `external_user_details.onboarded_at`.
*/
external_user_onboarded_at?: string;
/**
* Body param: Key-value pairs to merge into the stored metadata. Keys provided
* overwrite existing values. To remove a key, set its value to an empty string.
* Keys not provided are left unchanged. Maximum 16 keys, with keys up to 64
* characters and values up to 512 characters.
*/
metadata?: {
[key: string]: string;
};
/**
* Body param: If present, replaces the stored name. Omit to leave unchanged.
* Maximum 255 characters.
*/
name?: string | null;
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
/**
* Header param: Optional header to select the Workspace for this request. The
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
*
* Only needed for credentials that can act on more than one Workspace. A
* credential that belongs to a specific Workspace may omit it; if sent, it must
* match that Workspace.
*/
workspace_id?: string;
}
export interface UserProfileListParams extends PageCursorParams {
/**
* Query param: The sort direction, applied to the field that `order_by` selects.
* Defaults to `desc`.
*
* - `asc` - Oldest first when `order_by` is `created_at`, or names in ascending
* order when `order_by` is `name`.
* - `desc` - Newest first when `order_by` is `created_at`, or names in descending
* order when `order_by` is `name`. This is the default.
*/
order?: 'asc' | 'desc';
/**
* Query param: The field to sort user profiles by, in the direction that `order`
* sets. Defaults to `created_at`.
*
* - `created_at` - Sort by when each user profile was created. This is the
* default.
* - `name` - Sort by `name`, ignoring the case of ASCII letters. Profiles without
* a name come last in either direction.
*/
order_by?: 'created_at' | 'name';
/**
* Header param: Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
/**
* Header param: Optional header to select the Workspace for this request. The
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
*
* Only needed for credentials that can act on more than one Workspace. A
* credential that belongs to a specific Workspace may omit it; if sent, it must
* match that Workspace.
*/
workspace_id?: string;
}
export interface UserProfileDeleteParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
/**
* Optional header to select the Workspace for this request. The value is a
* Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
*
* Only needed for credentials that can act on more than one Workspace. A
* credential that belongs to a specific Workspace may omit it; if sent, it must
* match that Workspace.
*/
workspace_id?: string;
}
export interface UserProfileCreateEnrollmentURLParams {
/**
* Optional header to specify the beta version(s) you want to use.
*/
betas?: Array<BetaAPI.AnthropicBeta>;
/**
* Optional header to select the Workspace for this request. The value is a
* Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
*
* Only needed for credentials that can act on more than one Workspace. A
* credential that belongs to a specific Workspace may omit it; if sent, it must
* match that Workspace.
*/
workspace_id?: string;
}
export declare namespace UserProfiles {
export { type BetaDeletedUserProfile as BetaDeletedUserProfile, type BetaUserProfile as BetaUserProfile, type BetaUserProfileEnrollmentURL as BetaUserProfileEnrollmentURL, type BetaUserProfileExternalUserDetails as BetaUserProfileExternalUserDetails, type BetaUserProfileExternalUserDetailsParams as BetaUserProfileExternalUserDetailsParams, type BetaUserProfileTrustGrant as BetaUserProfileTrustGrant, type BetaUserProfilesPageCursor as BetaUserProfilesPageCursor, type UserProfileCreateParams as UserProfileCreateParams, type UserProfileRetrieveParams as UserProfileRetrieveParams, type UserProfileUpdateParams as UserProfileUpdateParams, type UserProfileListParams as UserProfileListParams, type UserProfileDeleteParams as UserProfileDeleteParams, type UserProfileCreateEnrollmentURLParams as UserProfileCreateEnrollmentURLParams, };
export { ActionURLs as ActionURLs, type BetaUserProfileActionURL as BetaUserProfileActionURL, type BetaUserProfileEnrollEndUserAction as BetaUserProfileEnrollEndUserAction, type ActionURLCreateParams as ActionURLCreateParams, };
}
//# sourceMappingURL=user-profiles.d.mts.map