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

# Assign a company bill to an organisation

> Assign a bill waiting in the company's inbox to one of that company's organisations. The bill becomes an ordinary bill for that organisation, keeping the same identifier, and supplier matching and duplicate detection run against it for the first time. The move is atomic: it either becomes that organisation's bill or stays in the inbox. If two people assign the same bill at once, exactly one succeeds and the other receives a conflict.

**Authentication.** An API key (`x-dolfin-api-key`) **or** a JWT Bearer token. When your credential grants access to more than one client, select one with the `x-dolfin-client-id` header.



## OpenAPI

````yaml post /v1/companies/{companyId}/bills/{billId}/assign
openapi: 3.1.1
info:
  title: Dolfin API
  description: >-
    Dolfin API for AR & AP. Each operation documents its accepted credentials
    under **Authentication** — typically an `x-dolfin-api-key` header (with
    `x-dolfin-organisation-id`) or a JWT Bearer token.
  version: v1
servers:
  - url: https://api.dolfinai.co
    description: Production
security: []
tags:
  - name: Users
  - name: TaxRates
  - name: Suppliers
  - name: Supplier Credit Notes
  - name: Bills
  - name: Payables
  - name: RecurringInvoices
  - name: Receivables
  - name: Purchase Orders
  - name: Products
  - name: Payments
  - name: Invoices
  - name: Organisations
  - name: Clients
  - name: MCP
  - name: Matching
  - name: Invoice Reminders
  - name: Industries
  - name: Gmail
  - name: Delivery Notes
  - name: Customers
  - name: Currencies
  - name: Credit Notes
  - name: Companies
  - name: BankPayments
  - name: Bank details
  - name: Auth
  - name: ApprovalPolicies
  - name: Agent
paths:
  /v1/companies/{companyId}/bills/{billId}/assign:
    post:
      tags:
        - Companies
      summary: Assign a company bill to an organisation
      description: >-
        Assign a bill waiting in the company's inbox to one of that company's
        organisations. The bill becomes an ordinary bill for that organisation,
        keeping the same identifier, and supplier matching and duplicate
        detection run against it for the first time. The move is atomic: it
        either becomes that organisation's bill or stays in the inbox. If two
        people assign the same bill at once, exactly one succeeds and the other
        receives a conflict.


        **Authentication.** An API key (`x-dolfin-api-key`) **or** a JWT Bearer
        token. When your credential grants access to more than one client,
        select one with the `x-dolfin-client-id` header.
      parameters:
        - name: companyId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: billId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: x-dolfin-client-id
          in: header
          description: >-
            Target client. Required when your credential grants access to more
            than one client; omit when it resolves a single client.
          schema:
            type: string
            format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AssignCompanyBillRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompanyBillAssignedResponse'
        '400':
          description: Company.MissingClientId — client ID is required
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: >-
            Module.NotEntitled — the client's plan does not include the module
            this endpoint requires
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: >-
            CompanyInboxBill.NotFound — the company bill does not exist or
            belongs to a different client


            CompanyInboxBill.OrganisationNotInCompany — the target organisation
            is not part of this company
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '409':
          description: >-
            CompanyInboxBill.NotAwaitingOrganisation — the bill is not awaiting
            routing — it is still extracting, was discarded, or has already been
            routed


            Request.Conflict — another change to the same record landed first;
            retry the request
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '500':
          description: Request.Failed — the command failed while being processed
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '504':
          description: >-
            Gateway Timeout


            Request.Timeout — the command did not complete in time; it may still
            be applied
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
      security:
        - ApiKey: []
        - Bearer: []
components:
  schemas:
    AssignCompanyBillRequest:
      required:
        - organisationId
      type: object
      properties:
        organisationId:
          type: string
          description: >-
            The organisation to assign this bill to. It must be one of this
            company's organisations — see GET
            /companies/{companyId}/organisations.
          format: uuid
    CompanyBillAssignedResponse:
      type: object
      properties:
        billId:
          type: string
          description: >-
            The bill's identifier — unchanged by the assignment. Retrieve it
            from GET /bills/{billId} from now on.
          format: uuid
        organisationId:
          type: string
          format: uuid
    ProblemDetails:
      type: object
      properties:
        type:
          type:
            - 'null'
            - string
        title:
          type:
            - 'null'
            - string
        status:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - 'null'
            - integer
            - string
          format: int32
        detail:
          type:
            - 'null'
            - string
        instance:
          type:
            - 'null'
            - string
  securitySchemes:
    ApiKey:
      type: apiKey
      description: >-
        An API key issued to your client. It carries the client's scope;
        org-scoped calls also require the `x-dolfin-organisation-id` header.
        Keys are created and revoked by a client administrator.
      name: x-dolfin-api-key
      in: header
    Bearer:
      type: http
      description: >-
        A session JWT obtained via the OAuth flow (`POST /auth/codes` → `POST
        /auth/exchange`). Its claims carry the caller's organisation and/or
        client scope.
      scheme: bearer
      bearerFormat: JWT

````