> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ユーザーの請求先組織を設定

> 最大100人のユーザーの請求先組織を設定します。

変更されるのは、送信されたユーザーの請求先組織のみです。無効な割り当てが含まれていても、有効な割り当てはまとめて保存されるため、
`200`レスポンスにも失敗が含まれる場合があります。必ず`failed`をチェックしてください。
エラーレスポンスが返された場合は、何も保存されていません。割り当てを再送信すると、
ユーザーの現在の請求先組織が上書きされ、監査ログに新たなエントリが記録されます。

1回のリクエストで、最大100人のユーザーの[請求先組織](https://docs.devin.ai/ja/admin/billing/org-acu-limits#billing-organization-attribution)を設定します。変更されるのはリクエストで指定したユーザーのみで、エンタープライズ内のほかのユーザーには影響しません。ユーザーを1人ずつ設定する場合は、ベータ版の[ユーザー設定エンドポイント](https://docs.devin.ai/ja/admin/billing/legacy-user-acu-limits#user-endpoints)でも `billing_org_id` を指定できます。

## 部分成功

同じリクエスト内に無効な行が含まれていても、有効な割り当てはまとめて保存されます。そのため、`200` レスポンスにも失敗が含まれる場合があります。必ず `failed` を確認してください。各項目には、ユーザー、リクエストされた組織、および `reason` が含まれます。これらのユーザーの請求先組織は変更されていないため、該当する行を修正して再送信してください。

| `reason` | 意味 |
| - | - |
| `user_not_found` | ユーザーがエンタープライズのメンバーではありません (直接のメンバーでも、アイデンティティプロバイダーのグループ経由のメンバーでもありません) 。 |
| `org_not_found` | 組織がエンタープライズに属していません。 |
| `user_not_org_member` | 組織がエンタープライズのプライマリ組織ではなく、かつユーザーがその組織のメンバーではありません。 |

`reason` の値は今後追加される可能性があるため、未知の値はエラーではなく失敗として扱ってください。

エラーレスポンス (`4xx` または `5xx`) が返された場合、リクエストの内容は一切保存されていません。割り当てが含まれていないリクエスト、割り当てが 100 件を超えるリクエスト、または同じ `user_id` が複数回含まれるリクエストは、`422` で拒否されます。

割り当てを再送信すると、ユーザーの現在の請求先組織が上書きされ、監査ログに新たな項目が記録されます。そのため、繰り返し呼び出しても問題はありませんが、影響がまったくないわけではありません。

## 権限

エンタープライズレベルで `ManageBilling` と `ViewOrganizations` の両方の権限を持つ[サービスユーザー](https://docs.devin.ai/ja/api-reference/v3/service-users/members-service-users.md)または[個人用アクセストークン](https://docs.devin.ai/ja/api-reference/personal-access-tokens.md)が必要です。なお、`ManageOrganizations` には `ViewOrganizations` が含まれるため、`ManageOrganizations` を持っていれば `ViewOrganizations` の要件も満たされます。


## OpenAPI

````yaml ja/v3-openapi.yaml PUT /v3/enterprise/members/users/billing-orgs
openapi: 3.1.0
info:
  description: Service User 認証および RBAC に対応した Devin v3 API
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3/enterprise/members/users/billing-orgs:
    put:
      tags:
        - user-billing-orgs
      summary: ユーザーの請求先組織を設定
      description: |-
        最大100人のユーザーの請求先組織を設定します。

        変更されるのは、送信されたユーザーの請求先組織のみです。無効な割り当てが含まれていても、有効な割り当てはまとめて保存されるため、
        `200`レスポンスにも失敗が含まれる場合があります。必ず`failed`をチェックしてください。
        エラーレスポンスが返された場合は、何も保存されていません。割り当てを再送信すると、
        ユーザーの現在の請求先組織が上書きされ、監査ログに新たなエントリが記録されます。
      operationId: >-
        handle_update_user_billing_orgs_v3_enterprise_members_users_billing_orgs_put
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserBillingOrgsUpdateRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserBillingOrgsUpdateResponse'
          description: 成功レスポンス
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 認証されていません
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: アクセスが禁止されています
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 見つかりません
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 競合
        '410':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 削除済み
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 処理できないコンテンツ
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: リクエスト過多
components:
  schemas:
    UserBillingOrgsUpdateRequest:
      properties:
        assignments:
          description: 各ユーザーに設定する請求先組織。同じユーザーを複数回指定することはできません。
          items:
            $ref: '#/components/schemas/UserBillingOrgAssignmentRequest'
          maxItems: 100
          minItems: 1
          title: Assignments
          type: array
      required:
        - assignments
      title: UserBillingOrgsUpdateRequest
      type: object
    UserBillingOrgsUpdateResponse:
      properties:
        assigned:
          description: 適用された割り当て。
          items:
            $ref: '#/components/schemas/UserBillingOrgAssignmentResponse'
          title: Assigned
          type: array
        failed:
          description: スキップされた割り当てとその理由。これらのユーザーの請求先組織は変更されていません。
          items:
            $ref: '#/components/schemas/UserBillingOrgFailureResponse'
          title: Failed
          type: array
      required:
        - assigned
        - failed
      title: UserBillingOrgsUpdateResponse
      type: object
    ProblemDetail:
      description: >-
        v3 API 用の RFC 9457 application/problem+json エラーボディ。


        detail は後方互換性のため、レガシーな {"detail": ...}
        ボディから引き継がれます。その他のメンバーは追加式です。errors にはフィールドレベルのバリデーションエラーが含まれます（422
        の場合のみ）。
      properties:
        detail:
          anyOf:
            - type: string
            - type: 'null'
          description: この事象に固有の、人が読める説明。
          title: Detail
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          description: ブロックされた操作の拒否理由を示す機械可読コード（例："user_frozen"、"migrated_session"）。
          title: Error Code
        errors:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          description: フィールド単位のバリデーションエラー（422 レスポンスのみ）。
          title: Errors
        instance:
          anyOf:
            - type: string
            - type: 'null'
          description: この発生箇所の URI 参照（リクエストパス）。
          title: Instance
        status:
          description: HTTP ステータスコード。
          title: Status
          type: integer
        title:
          description: 問題タイプを人が読める短い要約。
          title: Title
          type: string
        type:
          default: about:blank
          description: 問題タイプを識別する URI 参照。
          title: Type
          type: string
      required:
        - title
        - status
      title: ProblemDetail
      type: object
    UserBillingOrgAssignmentRequest:
      properties:
        billing_org_id:
          description: ユーザーのDevin DesktopおよびCLIの使用量の請求先となる組織。
          title: Billing Org Id
          type: string
        user_id:
          description: エンタープライズユーザーのID。
          title: User Id
          type: string
      required:
        - user_id
        - billing_org_id
      title: UserBillingOrgAssignmentRequest
      type: object
    UserBillingOrgAssignmentResponse:
      properties:
        billing_org_id:
          description: ユーザーのDevin DesktopおよびCLIの使用量について、現在の請求先となっている組織。
          title: Billing Org Id
          type: string
        user_id:
          description: エンタープライズユーザーのID。
          title: User Id
          type: string
      required:
        - user_id
        - billing_org_id
      title: UserBillingOrgAssignmentResponse
      type: object
    UserBillingOrgFailureResponse:
      properties:
        billing_org_id:
          description: リクエストで指定された請求先組織のID。
          title: Billing Org Id
          type: string
        reason:
          $ref: '#/components/schemas/UserBillingOrgFailureReason'
          description: >-
            割り当てがスキップされた理由。エンタープライズのプライマリ組織以外を指定する場合、ユーザーはその組織のメンバーである必要があります。新しい理由が追加される可能性があるため、未知の値にも対応してください。
        user_id:
          description: 更新されなかったユーザーのID。
          title: User Id
          type: string
      required:
        - user_id
        - billing_org_id
        - reason
      title: UserBillingOrgFailureResponse
      type: object
    UserBillingOrgFailureReason:
      enum:
        - user_not_found
        - org_not_found
        - user_not_org_member
      title: UserBillingOrgFailureReason
      type: string
  securitySchemes:
    bearerAuth:
      description: 'サービスユーザーの認証情報（接頭辞: cog_）'
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.