Follow Discord
Sweep 20 Nov 2026 · 19:55Z Build v2.1.330 547 read Stable v2.1.323 Latest v2.1.330 Next v2.1.330 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

copy from platform.claude.com after you register your OAuth app. changedmanage-claude/oauth-apps/organization-billing-connections

Nearest release: v2.1.327, published 2 hours after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+1,839added
Lines−0removed
From line — no hunk to open at
First seen 17 Nov 2026 this site's first read of the page
Recorded edits4to this page, all time

## Eligible customers and endpoints ### Which credits can pay ## Setup process ### Step 1: Create the app ### Step 2: Set up client authentication ### Step 3: Set up your back end’s identity ### Which user profile to link #### A user profile for each person ## Link each customer ### Step 4: Create a user profile for the customer ### Step 5: Create a pushed authorization request URL ### Step 6: Send your user to the Claude approval page ### Step 7: The user approves ### Step 8: Handle the callback and save the connection ### Test as a customer ### If linking doesn’t complete #### Your redirect URI receives `error=access_denied` #### Your app receives `user_profile_already_linked` #### Your redirect URI receives nothing #### The code exchange returns `unauthorized_client` ### Publish your app ## Update calls to Claude ### Your customer pays ### You pay ## OAuth tokens for each connection ### Set up your app ### Scopes for a billing connection ### Store the tokens ### Call Claude with a connection’s access token ### Refresh the tokens ### Run an agent in a sandbox ### Link a customer again ### Turn off operator-only authentication ### OAuth token snippet initialization ## Managing your connections ### Viewing customers in Console ### Monitoring each customer’s usage ### Unlinking a customer ### Linking a customer to a different Claude organization ## Expected errors ### Causes of `user_profile_not_billable` ## Your customer’s view ### Linking ### After linking ### Emails about linking and unlinking ### Spend caps #### While your app is in testing ### Supporting your customers ## Code snippet initialization

The whole hunk

1839 lines, new page
/
lines

A whole new page. There's nothing to diff it against, so here is what it says.

---
title: Linked billing
url: https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections
description: Let your customers link their Claude Platform organization to your app with OAuth, and bill Claude usage to the customer's organization.
---

<Warning>
  Claude Platform OAuth is a Beta Service: prerelease software provided under your agreement with Anthropic, such as the [Commercial Terms of Service](https://www.anthropic.com/legal/commercial-terms), and the [Service Specific Terms](https://www.anthropic.com/legal/service-specific-terms). Endpoints, parameters, and behavior can change during the beta. It might not be suitable for production use.
</Warning>

Linked billing lets your customers pay for the Claude usage in your app through their own Claude organization. A customer links their Claude organization to your app once. The API calls this link a connection. After the customer has linked, you choose on each Claude API request whether the customer or you pays. The customer can unlink your app at any time. If a request you mark for the customer can’t be billed to them, the Claude API refuses it rather than billing you.

This guide is for developers whose app users are primarily Claude Platform customers. You add a “Link your Claude organization” button to your app. Your user clicks it, signs in to Claude, and approves your app to bill their Claude organization for the Claude API requests the customer directs you to make. Your app then adds a [`billing_policy`](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#step-3-update-calls-to-claude) field to the requests that the customer pays for.

## Eligible customers and endpoints

**Eligible customers:** A customer can be billed this way only if their Claude Platform organization pays Anthropic directly for its API usage. Prepaid credits and invoiced billing both count. Organizations billed through a cloud marketplace (AWS, Google Cloud, or Azure) can’t be billed through this integration. The same is true of organizations that have only a Claude subscription plan. Requests for them are refused with 403 `user_profile_not_billable`.

Requests run in your organization, so your rate limits, model access, service tier, data retention, and encryption keys apply. Your customer’s own data arrangements don’t apply to these requests, including [zero data retention (ZDR)](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#zero-data-retention-zdr-scope), a business associate agreement (BAA), and customer-managed encryption keys (CMEK). Don’t link customers that need HIPAA, FERPA, or CMEK coverage for this usage.

**Supported endpoints:** `billing_policy` is supported on:

* `/v1/messages`
  * Known limitation: a request that bills your customer (`bill_to: "user_profile"`) can’t use [billable code execution features](https://platform.claude.com/docs/en/about-claude/pricing#code-execution-tool) (the API returns a 400), so send those requests with `bill_to: "self"` or without `billing_policy`.
* `/v1/chat/completions`
* `/v1/messages/count_tokens` accepts the `billing_policy` field and ignores it, so you can count tokens on the exact body you’re about to send.

[Message Batches](https://platform.claude.com/docs/en/build-with-claude/batch-processing) (`/v1/messages/batches`) doesn’t currently support billing your customer. Send the requests in a batch with `bill_to: "self"` or without `billing_policy`, and they’re billed to you as usual. A request in a batch that sets `bill_to: "user_profile"` is refused: its result is `errored` with an `invalid_request_error`, neither you nor your customer is billed for it, and the batch’s other requests run as usual.

To ask for support on another endpoint, contact your Anthropic account team.

### Which credits can pay

Not all credit can pay for a request that a platform bills to a customer. What can pay depends on the organization that’s billed: the customer if you bill a customer, or your organization if a platform bills you.

Credit bought in the Claude Console for that organization can pay for these requests. If that organization has invoiced billing, it’s invoiced for these requests.

Some promotional credits from Anthropic can’t pay for these requests. These include the monthly API credits that come with Claude Max, Ultra, and Team plans. Credits from Anthropic’s partner, VC, and startup programs aren’t eligible to pay for these requests.

When nothing on that organization’s account can pay for a request, the Claude API can refuse it with a 402. The response doesn’t say whether a lack of credit or a spend limit caused the refusal. See [Expected errors](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#expected-errors).

## Setup process

You do these three steps once. They register your app with Anthropic. After them, [Which user profile to link](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#which-user-profile-to-link) explains a rule that you need before you create user profiles.

### Step 1: Create the app

Create the OAuth app in the Claude Console. It is the registration that identifies your product to Anthropic: it ties your redirect URI to a client ID, and its name is what your user sees on the approval page.

A member of your organization with the Admin role opens the [OAuth apps](https://platform.claude.com/settings/oauth-apps) page in the Console and clicks **Create**. Enter your app’s name and redirect URI (the address in your app that the browser returns to after the approval). Under **What the app can do**, select **Bill and link to organizations**.

The new app’s page opens. Copy the client ID that the Console shows for the app. Your app sends it in Step 5 when it requests an approval page, in Step 6 when it redirects the browser, and in Step 8 when it exchanges the code, so that Anthropic knows which app is asking. The client ID is public. On the **Appearance** tab, set your app’s name, homepage, and logo URL.

On the **Settings** tab, **Who can link** reads **Test users only** for a new app, which starts in testing. After you [publish your app](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#publish-your-app) and it is live, the setting reads **Any Claude user**.

<Note>
  An organization can register several OAuth apps, for example one for production and one for testing. Each app has its own connections: a customer who links your test app is not linked to your production app. Keep Linked billing on one production app for the life of your integration.
</Note>

### Step 2: Set up client authentication

Set up how your back end proves to `auth.claude.com` that its requests come from your app. This takes the place of a client secret: Anthropic does not issue client secrets for OAuth apps.

On the app’s **Client authentication** tab, select your **Identity provider** (the issuer that signs your back end’s tokens). To add one, click **Register a new issuer**. Then set a **Subject pattern**, or claim conditions under **Advanced match options**, that those tokens must match. After you save, the tab shows the expected audience. Your client assertion’s `aud` claim must be exactly that value.

<Note>
  Your app authenticates to the PAR, token, and revocation endpoints with a variation of the `private_key_jwt` method (RFC 7523): with each request, your back end sends a client assertion, a JWT that your identity provider issues. `auth.claude.com` checks the token’s signature with the keys registered for that issuer, and checks it against the subject or claim conditions you set here. For the claims a client assertion must contain, see [Client assertion claims](https://platform.claude.com/docs/en/manage-claude/oauth-apps/oauth-reference#client-assertion-claims).
</Note>

### Step 3: Set up your back end’s identity

Your back end needs an identity of its own to call the Claude API. Create two things:

* **A service account.** This is a non-human account in your Claude organization. Your back end authenticates as this account when it calls the Claude API.
* **A second federation rule.** Like the rule for the app’s client authentication in Step 2, it lets your back end authenticate with tokens from your own identity provider.

To set them up in the Claude Console, follow the [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) guide.

Then, on the app’s **Client authentication** tab, select that service account as the app’s operator service account. Only that service account is authorized to send inference requests and attribute billing to the linked user profiles. A service account can be the operator of only one OAuth app.

By default, any authenticated request as that service account can bill every linked customer, by setting the user profile header and `bill_to` in the Messages API. To obtain authentication tokens constrained only to a specific connection, see [OAuth tokens for each connection](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#oauth-tokens-for-each-connection). Before you link customers, [set a workspace](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#settings-for-a-connections-oauth-tokens) for your app. Step 8 returns such a token for each customer, and requires the app to specify a default workspace in your organization against which inference runs. If you want refresh tokens for each connection, also turn on **Offline access** for your app. Then request `offline_access` in the authorization flow, in Step 5, before you link customers.

### Which user profile to link

A user profile is a record in your own Claude organization that represents one of your customers. Each request that bills the customer includes the profile’s ID, so that Anthropic knows which customer to bill. For the rest of what profiles do, see [User profiles for end-customer attribution](https://platform.claude.com/docs/en/manage-claude/user-profiles).

Settle which user profile stands for each customer before you link your first customer. Within one app, connections are one to one:

* A customer’s Claude organization can be linked to only one of your user profiles.
* A user profile can be linked to only one Claude organization.

The customer’s Claude organization is the one that the user selects when they approve your app. To learn how a customer’s teams use Claude organizations, ask the customer. To apply the one-to-one rule to your customer records:

* **Several teams of one customer share a Claude organization:** Use one user profile for all of the teams.
* **Each team has its own Claude organization:** Create a user profile for each organization.

Any active user profile in your organization can be linked, as long as the one-to-one rule holds. Linking doesn’t change the profile, its ID, or its usage history. If you link a second user profile to a Claude organization that is already linked, the approval is refused: see [`user_profile_already_linked`](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#user-profile-already-linked).

#### A user profile for each person

You might already have a user profile for each person who uses your product. Several of those people might work for the same customer. In that case, Anthropic recommends that you create one more user profile for the customer’s Claude organization and link that profile.

The profile ID to send depends on who pays for the request:

* **Requests that you bill to the customer:** Send the ID of the customer’s profile. To also identify the person on a `/v1/messages` request, set [`metadata.user_id`](https://platform.claude.com/docs/en/api/messages/create) to an identifier for that person. This identifier is optional and helps Anthropic detect misuse by one person. Use an opaque value, not a name, an email address, or a phone number.
* **Requests that you pay for:** You can keep sending the person’s own profile ID.

## Link each customer

You do Steps 4 to 8 for each customer that links their organization. The following Python code snippets require the Anthropic SDK and some standard imports; see [Code snippet initialization](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#code-snippet-initialization). The examples in other languages and the CLI take their credentials from the environment. Ensure `ANTHROPIC_API_KEY` is not set, because your app needs to authenticate with Workload Identity Federation.

Add a “Link your Claude organization” button where your customers manage billing or integrations in your product (for the button’s HTML, colors, and logo, see [Branding samples](https://platform.claude.com/docs/en/manage-claude/oauth-apps/branding-samples#buttons)). Tell them that to link, they must have the Admin or Billing role in their Claude organization.

To go through the steps yourself first, see [Test as a customer](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#test-as-a-customer).

<Frame>
  ![Sequence diagram of Steps 5 to 8: the approval request, the user's approval, and the exchange for a connection ID](https://platform.claude.com/docs/images/oauth-apps-billing-connection-flow.svg)
</Frame>

### Step 4: Create a user profile for the customer

Create one user profile for each customer’s Claude organization, and store the profile’s ID against the customer’s record in your product.

If you already have a user profile for this customer’s Claude organization, skip this step and use that profile’s ID. To decide which profile that is, see [Which user profile to link](https://platform.claude.com/docs/en/manage-claude/oauth-apps/organization-billing-connections#which-user-profile-to-link).

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/user_profiles \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -H "anthropic-version: 2026-10-21" \
    -H "content-type: application/json" \
    -d '{
      "name": "Example Customer Inc.",
      "external_user_details": {"reference_id": "your-customer-id-123"}
    }'
  ```

  ```bash CLI
  ant user-profiles create \
    --name "Example Customer Inc." \
    --external-user-details.reference-id your-customer-id-123
  ```

  ```python Python
  def create_user_profile(name: str, customer_id: str) -> str:
      profile = client.user_profiles.create(
          name=name,
          external_user_details={"reference_id": customer_id},
      )
      return profile.id  # "uprof_..."


  user_profile_id = create_user_profile("Example Customer Inc.", "your-customer-id-123")
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const profile = await client.userProfiles.create({
    name: "Example Customer Inc.",
    external_user_details: { reference_id: "your-customer-id-123" }
  });

  console.log(profile.id); // "uprof_..."
  ```

  ```csharp C#
  AnthropicClient client = new();

  var profile = await client.UserProfiles.Create(
      new()
      {
          Name = "Example Customer Inc.",
          ExternalUserDetails = new() { ReferenceID = "your-customer-id-123" },
      }
  );

  Console.WriteLine(profile.ID);
  ```

  ```go Go
  client := anthropic.NewClient()

  profile, err := client.UserProfiles.New(context.Background(), anthropic.UserProfileNewParams{
  	Name: anthropic.String("Example Customer Inc."),
  	ExternalUserDetails: anthropic.UserProfileExternalUserDetailsParams{
  		ReferenceID: anthropic.String("your-customer-id-123"),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }

  fmt.Println(profile.ID)
  ```

  ```java Java
  import com.anthropic.models.userprofiles.UserProfileCreateParams;
  import com.anthropic.models.userprofiles.UserProfileExternalUserDetailsParams;

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      var params = UserProfileCreateParams.builder()
          .name("Example Customer Inc.")
          .externalUserDetails(UserProfileExternalUserDetailsParams.builder()
              .referenceId("your-customer-id-123")
              .build())
          .build();
      var profile = client.userProfiles().create(params);

      IO.println(profile.id());
  }
  ```

  ```php PHP
  $client = new Client();

  $profile = $client->userProfiles->create(
      name: 'Example Customer Inc.',
      externalUserDetails: ['referenceID' => 'your-customer-id-123'],
  );

  echo $profile->id, PHP_EOL;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  profile = client.user_profiles.create(
    name: "Example Customer Inc.",
    external_user_details: { reference_id: "your-customer-id-123" }
  )

  puts(profile.id)
  ```
</CodeGroup>

If your organization resells API access, also send `"access_type": "passthrough"` when you create this profile. These samples leave `access_type` out, which creates an `application` profile. For the two types, see [Decide who gets a profile](https://platform.claude.com/docs/en/manage-claude/user-profiles#decide-who-gets-a-profile).

The response contains the profile’s `id`, for example `uprof_01HV9Z`.

<Note>
  Every create request makes a new profile, even with the same `reference_id` (your own ID for the customer), so reuse the stored ID instead of creating a profile on every connection attempt.
</Note>

### Step 5: Create a pushed authorization request URL

Create a pushed authorization request that references the customer’s user profile from Step 4. The response gives you a `request_uri`. In the next step, you use it to redirect your user to the approval page.

Before it sends the request, your back end creates two random values and stores them against the browser session and the customer record. It uses both again in Step 8:

* A `state` value, which lets you check that the browser that comes back to your app is the one that started this request.
* A PKCE code verifier, a secret that only your back end knows. The request carries a hash of it (the code challenge), and Step 8 sends the verifier itself, so that only your back end can use the code that comes back.

<CodeGroup exclude="shell:CLI, typescript, csharp, go, java, php, ruby">
  ```bash cURL
  curl https://auth.claude.com/v1/oauth/par \
    -H "content-type: application/json" \
    -d '{
      "response_type": "code",
      "client_id": "YOUR_CLIENT_ID",
      "redirect_uri": "https://app.example.com/claude/billing/callback",
      "scope": "billing:attribution",
      "connection_type": "organization_shared",
      "connection_auth_target": "platform",
      "user_profile_id": "uprof_01HV9Z",
      "state": "RANDOM_STATE",
      "code_challenge": "BASE64URL_SHA256_OF_VERIFIER",
      "code_challenge_method": "S256",
      "client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
      "client_assertion": "YOUR_CLIENT_ASSERTION_JWT"
    }'
  ```

  ```python Python
  def push_authorization_request(user_profile_id: str) -> dict:
      state = secrets.token_urlsafe(32)
      code_verifier = secrets.token_urlsafe(64)
      code_challenge = create_s256_code_challenge(code_verifier)

      response = httpx.post(
          f"{AUTH}/v1/oauth/par",
          json={
              "response_type": "code",
              "client_id": CLIENT_ID,
              "redirect_uri": REDIRECT_URI,
              "scope": "billing:attribution",
              "connection_type": "organization_shared",
              "connection_auth_target": "platform",
              "user_profile_id": user_profile_id,
              "state": state,
              "code_challenge": code_challenge,
              "code_challenge_method": "S256",
              "client_assertion_type": JWT_BEARER,
              "client_assertion": client_assertion(),
          },
      )
      response.raise_for_status()  # on an error, do not redirect the browser

Cut at 300 lines. The page has the rest.

Feedback