# Update an invoice item

`PUT /invoices/{id}/items/{itemId}`

> This is a subset of the full specification, limited to the `PUT /invoices/{id}/items/{itemId}` operation.
>
> You can find the full specification here: /_bundle/docs/dev-docs/api/index.yaml

```yaml
openapi: 3.1.1
info:
  version: latest
  title: Core APIs
  contact:
    name: Rebilly API Support
    url: https://www.rebilly.com/contact/
    email: integrations@rebilly.com
  license:
    name: Rebilly
    url: https://www.rebilly.com/api-license/
  termsOfService: https://www.rebilly.com/terms-of-use/
  x-logo:
    url: https://rebilly-core.redoc.ly/rb_apiLogo.svg
    backgroundColor: '#0044d4'
  description: This is a subset of the full specification, limited to the `PUT /invoices/{id}/items/{itemId}` operation.
  x-metadata:
    description: The most common APIs used to automate common workflows.
    redocly_category: API Reference
servers:
  - url: https://api-sandbox.rebilly.com/organizations/{organizationId}
    description: Sandbox server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
  - url: https://api.rebilly.com/organizations/{organizationId}
    description: Live server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
security:
  - SecretApiKey: []
  - JWT: []
tags:
  - name: Invoices
    description: |-
      Use invoices to bill for the goods or services that you provide.
      If your invoice includes subscription items, it also includes the corresponding service periods and prices.
x-tagGroups:
  - name: Orders & Invoices
    tags:
      - Invoices
paths:
  /invoices/{id}/items/{itemId}:
    parameters:
      - $ref: '#/components/parameters/resourceId'
      - name: itemId
        in: path
        description: ID of the invoice item.
        required: true
        schema:
          type: string
    put:
      x-products:
        - Core
      tags:
        - Invoices
      summary: Update an invoice item
      operationId: PutInvoiceItem
      x-sdk-operation-name: updateInvoiceItem
      description: Updates an invoice item.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceItem'
        description: Invoice item resource.
        required: true
      responses:
        '200':
          description: Invoice item updated.
          headers:
            Rate-Limit-Limit:
              $ref: '#/components/headers/Rate-Limit-Limit'
            Rate-Limit-Remaining:
              $ref: '#/components/headers/Rate-Limit-Remaining'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceItem'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      x-codeSamples:
        - lang: PHP
          label: PHP-SDK-2.0
          source: |
            $invoiceItemForm = new Rebilly\Entities\InvoiceItem();
            $invoiceItemForm->setType($invoiceItemForm::TYPE_DEBIT);
            $invoiceItemForm->setUnitPrice(0.99);
            $invoiceItemForm->setQuantity(5);

            try {
                $invoiceItem = $client->invoiceItems()->update($invoiceItemForm, 'invoiceId', 'invoiceItemId');
            } catch (Rebilly\Http\Exception\DataValidationException $e) {
                print_r($e->getValidationErrors());
            }
        - lang: JavaScript
          source: |
            // first set the properties for the new invoice item
            const data = {
                type: 'debit',
                unitPrice: 5
            };

            const invoiceItem = await api.invoices.updateInvoiceItem({id: 'id', itemId: 'itemId', data});
        - lang: PHP
          source: |-
            $service = new \Rebilly\Sdk\Service($client);

            $invoiceItem = \Rebilly\Sdk\Model\InvoiceItem::from([
                'type' => \Rebilly\Sdk\Model\InvoiceItem::TYPE_DEBIT,
                'unitPrice' => 0.99,
                'quantity' => 5,
            ]);

            try {
                $invoiceItem = $service->invoices()->updateInvoiceItem('invoiceId', 'invoiceItemId', $invoiceItem);
            } catch (\Rebilly\Sdk\Exception\DataValidationException $e) {
                print_r($e->getValidationErrors());
            }
components:
  securitySchemes:
    JWT:
      description: |-
        JWT is a short lifetime token that can be assigned a specific expiration time.

        Usage format: `Bearer <JWT>`.
      type: http
      scheme: bearer
      bearerFormat: JWT
    SecretApiKey:
      description: |-
        Never share your secret keys.
        Keep them guarded and secure.

        Use your secret API key only to make requests from the server side.
        To authenticate, provide your secret key in the request header.
      name: REB-APIKEY
      type: apiKey
      in: header
  parameters:
    resourceId:
      name: id
      in: path
      description: ID of the resource.
      required: true
      schema:
        type: string
        maxLength: 50
        pattern: ^[@~\-\.\w]+$
  headers:
    Rate-Limit-Limit:
      description: |-
        Maximum number of requests available at one time for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 500
    Rate-Limit-Remaining:
      description: |-
        Number of requests still available for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 499
    Rate-Limit-Retry-After:
      description: Number of seconds to wait before retrying the request.
      schema:
        type: integer
      example: 1
  schemas:
    CreatedTime:
      type: string
      description: |-
        Date and time when the resource is created.
        This value is set automatically when the resource is created.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Creation Time
    UpdatedTime:
      type: string
      description: |-
        Date and time when the resource is updated.
        This value is set automatically when the resource is updated.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Last Update Time
    BaseProblem:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    Unauthorized:
      allOf:
        - title: Unauthorized
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 401
              maximum: 401
        - $ref: '#/components/schemas/BaseProblem'
    InvalidFields:
      type: array
      description: Invalid field details.
      items:
        type: object
        properties:
          field:
            type: string
            description: |-
              Name of the field.
              Dot notation is used for nested object field names.
          message:
            description: Message field.
            type: string
      example:
        - field: field1
          message: field1 is invalid
        - field: subObject.field2
          message: field2 is invalid
        - field: subObject.field2
          message: another error in the field2
    ValidationError:
      allOf:
        - title: Validation error
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 422
              maximum: 422
        - $ref: '#/components/schemas/BaseProblem'
        - type: object
          properties:
            invalidFields:
              $ref: '#/components/schemas/InvalidFields'
    TooManyRequests:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
          example: about:blank
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
          example: Rate Limit Exceeded
        status:
          type: integer
          description: HTTP status code.
          minimum: 429
          maximum: 429
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
          example: A request cannot be executed because the user has sent too many requests within a certain period of time
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    TaxItem:
      type: object
      required:
        - amount
        - description
      properties:
        amount:
          description: Amount of the tax.
          type: number
          format: double
        description:
          type: string
          description: Description of the tax.
        rate:
          description: Overall sales tax rate which includes state, county, city and district tax.
          type:
            - number
            - 'null'
          format: double
          readOnly: true
        stateAmount:
          description: Amount of sales tax to collect for the state.
          type:
            - number
            - 'null'
          format: double
          example: 0.94
          readOnly: true
        countyAmount:
          description: Amount of sales tax to collect for the county.
          type:
            - number
            - 'null'
          format: double
          example: 0.04
          readOnly: true
        cityAmount:
          description: Amount of sales tax to collect for the city.
          type:
            - number
            - 'null'
          format: double
          example: 0
          readOnly: true
        specialDistrictAmount:
          description: Amount of sales tax to collect for the special district.
          type:
            - number
            - 'null'
          format: double
          example: 0.38
          readOnly: true
        stateRate:
          description: State sales tax rate for given location.
          type:
            - number
            - 'null'
          format: double
          readOnly: true
        countyRate:
          description: County sales tax rate for given location.
          type:
            - number
            - 'null'
          format: double
          readOnly: true
        cityRate:
          description: City sales tax rate for given location.
          type:
            - number
            - 'null'
          format: double
          readOnly: true
        specialDistrictRate:
          description: Special district sales tax rate for given location.
          type:
            - number
            - 'null'
          format: double
          readOnly: true
        jurisdictions:
          description: Jurisdiction names for the invoice.
          type:
            - object
            - 'null'
          readOnly: true
          properties:
            country:
              description: Two-letter ISO country code for the provided location.
              type:
                - string
                - 'null'
              example: US
              readOnly: true
            state:
              description: Postal abbreviated state name for the provided location.
              type:
                - string
                - 'null'
              example: CA
              readOnly: true
            county:
              description: County name for the provided location.
              type:
                - string
                - 'null'
              example: LOS ANGELES
              readOnly: true
            city:
              description: City name for the provided location.
              type:
                - string
                - 'null'
              example: LOS ANGELES
              readOnly: true
    InvoiceItem:
      type: object
      required:
        - type
        - unitPrice
      properties:
        id:
          type: string
          description: ID of the invoice item.
          readOnly: true
          maxLength: 50
          example: ii_0YVFDEQS2KCFTBN9HXWJFY55GV
        type:
          description: Type of invoice item.
          type: string
          x-basic: true
          enum:
            - debit
            - credit
        description:
          description: Description of the invoice item.
          type: string
          maxLength: 1000
        unitPrice:
          description: Unit price of the invoice item.
          type: number
          format: double
        quantity:
          description: Quantity of the invoice item.
          type: integer
        price:
          description: Total price of the invoice item.
          type: number
          format: double
          readOnly: true
        productId:
          type:
            - string
            - 'null'
          description: ID of the product.
          maxLength: 50
          example: prod_0YV7DES3WPC5J8JD8QTVNZBZNZ
        planId:
          type:
            - string
            - 'null'
          description: ID of the plan.
          maxLength: 50
          readOnly: true
          example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
        subscriptionId:
          type:
            - string
            - 'null'
          description: ID of the order.
          maxLength: 50
          readOnly: true
          example: sub_01HRF27SATGE4Z6PBJE6PD8328
        periodStartTime:
          description: Date and time when the billing period starts.
          type:
            - string
            - 'null'
          format: date-time
        periodEndTime:
          description: Date and time when the billing period ends.
          type:
            - string
            - 'null'
          format: date-time
        periodNumber:
          description: |-
            Billing period number that is associated with the invoice item.
            For example, an invoice item for a service is included in billing period number 3.
            The invoice item is only applied to billing period number 3.
          type:
            - integer
            - 'null'
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        tax:
          description: Invoice item tax.
          readOnly: true
          oneOf:
            - $ref: '#/components/schemas/TaxItem'
            - type: 'null'
        _links:
          type: array
          description: Related links.
          readOnly: true
          items:
            type: object
            properties:
              href:
                description: Link URL.
                type: string
              rel:
                description: Type of link.
                type: string
                enum:
                  - self
                  - product
                  - subscription
                  - plan
        _embedded:
          type: object
          description: Embedded objects that are requested by the `expand` query parameter.
          readOnly: true
          properties:
            product:
              type: object
            plan:
              type: object
  responses:
    Unauthorized:
      description: |-
        Unauthorized access.
        Invalid credentials used.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
    ValidationError:
      description: Invalid data sent.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    TooManyRequests:
      description: Request rate limit exceeded.
      headers:
        Rate-Limit-Limit:
          $ref: '#/components/headers/Rate-Limit-Limit'
        Rate-Limit-Remaining:
          description: |-
            Number of requests still available for this rate limit.
            For more information, see [Rate limits](#section/Rate-limits).
          schema:
            type: integer
          example: 0
        Rate-Limit-Retry-After:
          $ref: '#/components/headers/Rate-Limit-Retry-After'
        Retry-After:
          description: Number of seconds to wait before retrying the request.
          schema:
            type: integer
          example: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TooManyRequests'
```
