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

# Set billing details

> Save a customer's address, tax IDs, tax exemption and invoice fields on their Stripe customer.

Writes the fields you send to the customer's Stripe customer, creating it first when there is none, and returns the details as Stripe now holds them. [Billing details](https://docs.integrateledger.com/customers/billing-details.md) explains each field and the rules.

* `address` and `invoiceCustomFields` replace the whole value; `null` clears any field; omitted fields stay.
* `taxIds.add` and `taxIds.remove` touch only the IDs they list.
* A refused tax ID (`422 invalid_tax_id`) or address (`422 invalid_address`) changes nothing.

Needs the **Customers** permission at Write.

```bash cURL theme={"system"}
curl "https://api.integrateledger.com/v1/customers/billing-details?customerId=acme" \
  -H "Authorization: Bearer $LEDGER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"address": {"line1": "1 Main St", "city": "Berlin", "postalCode": "10115", "country": "DE"}, "taxIds": {"add": [{"type": "eu_vat", "value": "DE123456789"}]}, "taxExempt": "reverse"}'
```

```json 200 theme={"system"}
{
  "customerId": "acme",
  "billingDetails": {
    "stripeCustomerId": "cus_TbXyZ",
    "name": "Acme GmbH",
    "email": null,
    "address": { "line1": "1 Main St", "line2": null, "city": "Berlin", "state": null, "postalCode": "10115", "country": "DE" },
    "taxIds": [{ "type": "eu_vat", "value": "DE123456789", "verification": { "status": "pending", "verifiedName": null } }],
    "taxExempt": "reverse",
    "taxLocation": "not_collecting",
    "invoiceCustomFields": [],
    "invoiceFooter": null
  }
}
```

```json 422 theme={"system"}
{
  "error": "invalid_tax_id"
}
```


## OpenAPI

````yaml openapi.json POST /v1/customers/billing-details
openapi: 3.1.0
info:
  title: Ledger API
  version: 0.1.0
servers:
  - url: https://api.integrateledger.com
    description: Hosted Ledger API
security: []
paths:
  /v1/customers/billing-details:
    post:
      tags:
        - Customers
      summary: Set a customer's address, tax IDs and invoice fields
      description: >-
        Only the fields sent change. address and invoiceCustomFields replace the
        whole value; null clears a field.
      operationId: setCustomerBillingDetails
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: Your ID for the customer, such as your user ID.
          required: true
          description: Your ID for the customer, such as your user ID.
          name: customerId
          in: query
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillingDetailsInput'
      responses:
        '200':
          description: The customer's billing details, as Stripe holds them
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingDetailsResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '401':
          description: Missing or invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '403':
          $ref: '#/components/responses/InsufficientPermissions'
        '404':
          description: >-
            No such customer (customer_not_found), or its Stripe customer was
            deleted (stripe_customer_not_found)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '422':
          description: >-
            Stripe refused a tax ID (invalid_tax_id) or couldn't locate the
            address for tax (invalid_address). Nothing changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          description: >-
            Unexpected error in Ledger. It has been logged with the request ID;
            retry, or quote request_id when reporting it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalError'
        '502':
          description: >-
            No Stripe connection for this environment or its key is invalid
            (stripe_not_configured), or Stripe unavailable
            (stripe_request_failed; retry)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: >-
            import os

            from integrateledger import ledger


            client = ledger(api_key=os.environ["LEDGER_API_KEY"])

            client.set_customer_billing_details(customer_id="user_123",
            tax_ids={"add": [{"type": "eu_vat", "value": "DE123456789"}]},
            tax_exempt="reverse")
        - lang: bash
          label: cURL
          source: >-
            curl --request POST
            'https://api.integrateledger.com/v1/customers/billing-details?customerId=user_123'
            \
              -H "Authorization: Bearer $LEDGER_API_KEY" \
              -H 'Content-Type: application/json' \
              --data '{"taxIds":{"add":[{"type":"eu_vat","value":"DE123456789"}]},"taxExempt":"reverse"}'
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import ledger from "integrateledger";


            const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? ""
            });

            await client.setCustomerBillingDetails({ customerId: "user_123",
            body: { taxIds: { add: [{ type: "eu_vat", value: "DE123456789" }] },
            taxExempt: "reverse" } });
components:
  schemas:
    BillingDetailsInput:
      type: object
      properties:
        name:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 256
          description: >-
            The name invoices and receipts show. Null clears it. Checkout may
            overwrite it when automatic tax is on.
        email:
          type:
            - string
            - 'null'
          maxLength: 512
          format: email
          description: >-
            Where Stripe sends this customer's receipts and invoices, when your
            Stripe account sends them. Ledger itself never emails invoices. Null
            clears it.
        address:
          type:
            - object
            - 'null'
          properties:
            line1:
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 200
            line2:
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 200
            city:
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 200
            state:
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 200
            postalCode:
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 200
            country:
              type:
                - string
                - 'null'
              pattern: ^[A-Z]{2}$
              description: Two-letter ISO country code, such as DE.
          additionalProperties: false
          description: >-
            The billing address Stripe Tax locates the customer by. Replaces the
            whole address; null clears it.
        taxIds:
          type: object
          properties:
            add:
              type: array
              items:
                $ref: '#/components/schemas/TaxIdInput'
              maxItems: 10
            remove:
              type: array
              items:
                $ref: '#/components/schemas/TaxIdInput'
              maxItems: 10
          additionalProperties: false
          description: >-
            Tax IDs to add and to remove; any others stay. Adding one the
            customer has, or removing one it hasn't, changes nothing. To correct
            one, remove it and add the new value in the same call.
        taxExempt:
          type: string
          enum:
            - none
            - exempt
            - reverse
          description: >-
            none: taxed as usual. exempt: never taxed. reverse: reverse charge,
            which Stripe notes on the invoice.
        invoiceCustomFields:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/InvoiceCustomField'
          maxItems: 4
          description: >-
            Up to 4 name and value pairs printed on every invoice, such as a PO
            number. Replaces the whole list; null clears it.
        invoiceFooter:
          type:
            - string
            - 'null'
          minLength: 1
          maxLength: 5000
          description: Text printed at the foot of every invoice. Null clears it.
      additionalProperties: false
      description: >-
        Billing details saved on the customer's Stripe customer, which is
        created for them. The same fields as POST /v1/customers/billing-details.
    BillingDetailsResponse:
      type: object
      properties:
        customerId:
          type: string
        billingDetails:
          allOf:
            - $ref: '#/components/schemas/BillingDetails'
            - description: >-
                Read from the customer's Stripe customer. Null when the customer
                has no Stripe customer yet.
      required:
        - customerId
        - billingDetails
    CustomerError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        issues:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
            required:
              - path
              - message
          description: >-
            With `invalid_request`: each field that failed validation and why.
            `path` is empty for the body itself, such as an unknown field.
      required:
        - error
    InternalError:
      type: object
      properties:
        error:
          type: string
          example: internal_error
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        request_id:
          type:
            - string
            - 'null'
      required:
        - error
        - request_id
    TaxIdInput:
      type: object
      properties:
        type:
          type: string
          minLength: 1
          maxLength: 40
          description: >-
            Stripe's tax ID type, such as eu_vat, gb_vat or us_ein. Stripe lists
            them in its tax ID docs.
          example: eu_vat
        value:
          type: string
          minLength: 1
          maxLength: 100
          example: DE123456789
      required:
        - type
        - value
      additionalProperties: false
    InvoiceCustomField:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 40
        value:
          type: string
          minLength: 1
          maxLength: 140
      required:
        - name
        - value
      additionalProperties: false
    BillingDetails:
      type: object
      properties:
        stripeCustomerId:
          type: string
        name:
          type:
            - string
            - 'null'
        email:
          type:
            - string
            - 'null'
        address:
          $ref: '#/components/schemas/BillingAddressRead'
        taxIds:
          type: array
          items:
            $ref: '#/components/schemas/TaxId'
        taxExempt:
          type: string
          enum:
            - none
            - exempt
            - reverse
        taxLocation:
          type:
            - string
            - 'null'
          enum:
            - supported
            - not_collecting
            - unrecognized_location
            - failed
            - null
          description: >-
            Whether Stripe Tax can locate the customer: supported (it can tax
            them), not_collecting (located where you aren't registered),
            unrecognized_location (the address isn't enough) or failed. Null
            when Stripe didn't say.
        invoiceCustomFields:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceCustomField'
        invoiceFooter:
          type:
            - string
            - 'null'
      required:
        - stripeCustomerId
        - name
        - email
        - address
        - taxIds
        - taxExempt
        - taxLocation
        - invoiceCustomFields
        - invoiceFooter
      description: The billing details Stripe now holds, when sent.
    InsufficientPermissionsError:
      type: object
      properties:
        error:
          type: string
          example: insufficient_permissions
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        requiredScope:
          type: string
          example: customers:read
      required:
        - error
        - requiredScope
    PayloadTooLargeError:
      type: object
      properties:
        error:
          type: string
          example: payload_too_large
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: rate_limited
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
    BillingAddressRead:
      type:
        - object
        - 'null'
      properties:
        line1:
          type:
            - string
            - 'null'
        line2:
          type:
            - string
            - 'null'
        city:
          type:
            - string
            - 'null'
        state:
          type:
            - string
            - 'null'
        postalCode:
          type:
            - string
            - 'null'
        country:
          type:
            - string
            - 'null'
      required:
        - line1
        - line2
        - city
        - state
        - postalCode
        - country
    TaxId:
      type: object
      properties:
        type:
          type: string
        value:
          type: string
        verification:
          type:
            - object
            - 'null'
          properties:
            status:
              type: string
              enum:
                - pending
                - unavailable
                - unverified
                - verified
            verifiedName:
              type:
                - string
                - 'null'
          required:
            - status
            - verifiedName
          description: >-
            Stripe's check of the ID with the tax authority, for the types
            Stripe verifies (EU VAT, for example). Null for the rest.
      required:
        - type
        - value
        - verification
  responses:
    InsufficientPermissions:
      description: >-
        The API key works but lacks the permission this endpoint needs, named in
        requiredScope. See the API keys guide.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InsufficientPermissionsError'
    PayloadTooLarge:
      description: 'The request body is over the limit: 1 MiB, or 5 MiB for a webhook.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PayloadTooLargeError'
    RateLimited:
      description: >-
        Too many requests. Wait Retry-After seconds, then retry. See the rate
        limits guide.
      headers:
        Retry-After:
          description: Seconds until a request is allowed again
          schema:
            type: integer
        RateLimit-Limit:
          description: 'The burst: requests allowed at once'
          schema:
            type: integer
        RateLimit-Remaining:
          description: Requests left right now
          schema:
            type: integer
        RateLimit-Reset:
          description: Seconds until the full burst is back
          schema:
            type: integer
        RateLimit-Policy:
          description: >-
            The sustained rate per second and the burst, such as
            200;w=1;burst=1000
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````

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