Create user profiles and attribute requests
Create a user profile for each end customer and send its ID on every request for them. A safety restriction or ban can then apply to that one end customer.
User profiles tell Anthropic which of your end customers each API request is for. That way, a safety enforcement action, such as a restriction or a ban, can apply to one end customer instead of your whole organization. If you aren’t sure that you need user profiles, see How user profiles work.
If you write the code that serves your end customers, you create a user profile for each one with POST /v1/user_profiles. You keep the opaque uprof_ ID it returns and send it on every request you make for them.
If you use Claude through a cloud platform, that platform determines which organization holds your user profiles and how you send their IDs. Read Use user profiles on a cloud platform before you create your first user profile.
Before you begin
You need the following:
- An organization for end-customer traffic: Keep it separate from the one for your own usage. Separate workspaces in the same organization aren’t enough. Only the organization for end-customer traffic needs user profiles. To create another organization on the Claude API, see “How to create a new organization” in Create and manage Workspaces in the Claude Console.
- Credentials for that organization: To create and manage user profiles, use a workload identity federation or OAuth token with the
workspace:developerscope, or an API key. A workload identity federation token is a short-lived Anthropic token that you get in exchange for one from your own identity provider. If the credential belongs to a person, they need the developer, admin, or owner role in the organization, because a workspace role isn’t enough. If it belongs to a service account, the developer or admin role in the organization or the workspace works. To send user profile IDs, any credential from that organization that can call the Messages API works. You don’t need an Admin API key. - On a Microsoft Foundry deployment hosted on Anthropic, a linked organization: Anthropic has to link the organization that holds your Foundry resource to the one that holds your user profiles. Until then, your Foundry requests can’t carry user profile IDs. See If you use Microsoft Foundry.
Decide who gets a user profile
Each end customer gets one user profile, so a company gets a single one rather than one for each person in it. Send its ID on every request you make for anyone at the company. To also tell Anthropic which person a request comes from, see Identify one person within a company.
The access_type you set depends on whether the end customer uses your product or buys API access from you, such as through your gateway:
| The end customer | access_type |
|---|---|
| Uses your product | application (the default, set when you leave access_type out) |
| Is a company that buys API access from you | passthrough (not the default, so you have to send it) |
Your own usage doesn’t need a user profile.
Don’t create a user profile for a workspace. A user profile belongs to your whole organization, so its ID works on requests through any workspace in the organization. The exception is a workspace that has a different user profile attached. You can’t replace or remove that attachment.
Create a user profile for each end customer
Create one user profile for each end customer before the first request that you send with its ID. Onboarding is a common place to do it. Because POST /v1/user_profiles isn’t idempotent, every call creates a new user profile, even when reference_id (your own ID for the end customer) matches an existing one. Store the ID it returns and reuse it.
If you already have end customers without user profiles, see the guidance on registering an existing customer base later in this section.
What to tell Anthropic about an end customer
Every field is optional, except that an end customer who buys API access from you needs access_type set to passthrough. Besides access_type, you can send name, metadata, and these fields in external_user_details: entity_type, country, reference_id, onboarded_at, account_status, name_hash, and email_hash. For each field’s type, format, and length limit, see the Create a user profilePreview with links to the API reference available — press Tab until focus enters the card, Escape to return. reference.
Follow these rules as you fill them in:
- Names: If you send
name, use the end customer’s real-world name. For a company, that’s its legal name, if you know it. - Names you can’t share: Leave out
nameand sendexternal_user_details.name_hashinstead. - Email addresses: Send
external_user_details.email_hash, because a user profile has no field for the address itself. - Hashes: Compute the hashes yourself with a function you choose. They let Anthropic see which of your user profiles share a name or email address. Because only values computed the same way match, use the same function for every user profile and handle case and whitespace the same way.
- Country:
countryis the end customer’s country, not yours. - Your own ID:
reference_idtakes your own stable identifier for the end customer, and it doesn’t have to be unique. - Health information: Don’t include protected health information (PHI) in a user profile, because the user profiles API isn’t a HIPAA-eligible service.
For more, see What a user profile contains and how Anthropic uses it.
Send the create request
The cURL samples on this page send an access token from ANTHROPIC_AUTH_TOKEN, such as a workload identity federation token. Set that variable only in the shell where you run them, because it takes precedence over federation environment variables and federation profiles.
This example creates a user profile for a company that buys API access from you, so it sets access_type to passthrough. For an application user profile, leave access_type out.
client = anthropic.Anthropic()
profile = client.user_profiles.create(
name="Acme Analytics, Inc.",
access_type="passthrough",
external_user_details={"reference_id": "cust-8f2a1c", "country": "US"},
)
print(profile.id)You get the new user profile back, abridged here:
{
"type": "user_profile",
"id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
"name": "Acme Analytics, Inc.",
"access_type": "passthrough",
"external_user_details": {
"reference_id": "cust-8f2a1c",
"onboarded_at": null,
"account_status": null,
"entity_type": null,
"country": "US",
"name_hash": null,
"email_hash": null
},
"metadata": {},
"programs": {
"cyber": null
},
"enforcement_status": "unrestricted",
"enforcement_actions": [],
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
}Store the id on your customer record and have your service instances read it from there, rather than each creating its own user profile. It’s also the ID you use to retrieve, update, or delete the user profile later.
Anthropic sets the following fields itself, so leave them out of your request:
programs: The end customer’s status in each Anthropic program, such as the Cyber Verification Program. Attribution doesn’t use this field. For what its values mean, see which programs apply to a user profile.enforcement_statusandenforcement_actions: Restrictions or bans that Anthropic has open on the end customer. See Check whether Anthropic has restricted or banned a user profile.
Register an existing customer base
An organization can hold any number of user profiles, but creating them is rate limited. Before you register an existing customer base in bulk, contact your Anthropic account team.
Attribute each request
Send the user profile’s uprof_ ID, not your own ID for the end customer, in the anthropic-user-profile-id header on every request you make for them. The SDK and the ant CLI add the header for you when you set user_profile_id.
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude"}],
user_profile_id=profile_id,
)
print(message)Send the header the same way on token counting, Message Batches, and OpenAI SDK compatibility requests. A batch’s header applies to every request in it, so put only one end customer’s requests in each batch.
On Amazon Bedrock, the ID goes in the request body instead, and only on the models that accept a user profile ID. To find where the ID goes on each cloud platform, see Use user profiles on a cloud platform.
Here’s how the API handles the ID:
- No ID: Anthropic counts the request as your own usage.
- A malformed ID or one your organization can’t use: The Claude API rejects the request with a
400. See If a request returns a400. - An ID on a batch: When you create the batch, the API checks only the ID’s format, unless the workspace has a user profile attached. See If you send a batch.
To bill a user profile’s requests to that customer’s own Claude organization, see Linked billing.
Identify one person within a company
A company’s user profile identifies the company, not the person a request comes from. If a request comes from one person you can identify, also set metadata.user_idPreview with links to the API reference available — press Tab until focus enters the card, Escape to return. on the Messages request to an identifier for them. That field sits in the request’s own metadata object, not in the user profile’s metadata field. The identifier is optional.
Rules and special cases
If a workspace has a user profile attached
Once a workspace has a user profile attached, every inference request through it must carry that user profile’s ID. The API rejects a request with a different ID or none. You attach a user profile by setting user_profile_id in Create WorkspacePreview with links to the API reference available — press Tab until focus enters the card, Escape to return. or Update WorkspacePreview with links to the API reference available — press Tab until focus enters the card, Escape to return.. Only deleting the user profile clears the attachment.
If a request returns a 400
The Claude API and Claude Platform on AWS check the ID on every request. So do Claude Models on Google Cloud (Anthropic managed) and Microsoft Foundry deployments hosted on Anthropic. If the check fails, they return a 400 error of type invalid_request_error. The check fails in cases such as these:
- The ID is malformed.
- The ID belongs to another organization, including one of yours on another platform, such as Claude Platform on AWS.
- The request goes to a Microsoft Foundry deployment hosted on Anthropic before Anthropic links the organization that holds your Foundry resource to the organization that created the user profile.
For Claude Models on Google Cloud (Google managed) and Amazon Bedrock, see How each platform checks the ID.
If you send a batch
Unless the workspace has a user profile attached, creating a message batch checks only the ID’s format, not whether the ID belongs to your organization. If a well-formed ID doesn’t belong to the organization that sends the batch, the batch is still created. Each request in it then fails with an errored result that contains an invalid_request_error.
Was this page helpful?