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

# Apply credit to an invoice

> Puts the credit balance on an open proforma in the same currency, as
much as its amount before VAT allows; VAT is worked out on what is
left. Credit can't be taken off an invoice this way. A proforma the
credit covers in full is paid at once. Needs `billing.pay`. The answer
is the whole invoice for a token that also has `billing.view`, and
otherwise its `id`, `type`, `status`, `currency`, `credit` and
`amount_due`.



## OpenAPI

````yaml /api-reference/console/openapi.json post /invoices/{invoice}/credit
openapi: 3.1.2
info:
  title: PerfGrid API
  version: 1.0.0
  description: >-
    The PerfGrid customer API. A member creates a token for one billing account
    under *API tokens* in the panel; it can do what both the token's permissions
    and the member's own permissions allow, the same as the panel.


    Send it as `Authorization: Bearer pgapi_...`. Each token may make 120
    requests a minute, of which 30 change something; a `429` response says when
    to try again (`Retry-After`). Ids are the ULIDs the API returns; amounts are
    decimal strings next to their currency; lists are newest first and paged
    with `cursor` (`meta.next_cursor`). Messages are in English, or Danish with
    `Accept-Language: da`.


    The same tokens work with the MCP server at `/mcp` for AI assistants.
servers:
  - url: https://console.perfgrid.com/api/v1
security:
  - http: []
tags:
  - name: Account
  - name: Invoices
  - name: Services
  - name: Domains
  - name: Support
paths:
  /invoices/{invoice}/credit:
    post:
      tags:
        - Invoices
      summary: Apply credit to an invoice
      description: |-
        Puts the credit balance on an open proforma in the same currency, as
        much as its amount before VAT allows; VAT is worked out on what is
        left. Credit can't be taken off an invoice this way. A proforma the
        credit covers in full is paid at once. Needs `billing.pay`. The answer
        is the whole invoice for a token that also has `billing.view`, and
        otherwise its `id`, `type`, `status`, `currency`, `credit` and
        `amount_due`.
      operationId: v1.invoices.credit
      parameters:
        - name: invoice
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: '`InvoiceResource`'
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          id:
                            type: string
                          type:
                            type: string
                            enum:
                              - invoice
                              - proforma
                          status:
                            type: string
                            enum:
                              - unpaid
                              - paid
                              - canceled
                              - held
                          currency:
                            type: string
                          credit:
                            type: string
                          amount_due:
                            type: string
                        required:
                          - id
                          - type
                          - status
                          - currency
                          - credit
                          - amount_due
                    required:
                      - data
                  - type: object
                    properties:
                      data:
                        allOf:
                          - $ref: '#/components/schemas/InvoiceResource'
                          - type: object
                            required:
                              - lines
                              - tax_totals
                              - payments
                              - credit_notes
                    required:
                      - data
        '403':
          $ref: '#/components/responses/AuthorizationException'
components:
  schemas:
    InvoiceResource:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - invoice
            - proforma
        status:
          type: string
          enum:
            - unpaid
            - paid
            - canceled
            - held
        is_overdue:
          type: boolean
        reference:
          type: string
        number:
          type:
            - string
            - 'null'
        proforma_number:
          type: string
        currency:
          type: string
        net:
          type:
            - string
            - 'null'
        credit:
          type:
            - string
            - 'null'
        subtotal:
          type:
            - string
            - 'null'
        tax:
          type:
            - string
            - 'null'
        total:
          type:
            - string
            - 'null'
        paid:
          type:
            - string
            - 'null'
        amount_due:
          type:
            - string
            - 'null'
        payment_in_progress:
          type: boolean
        issue_date:
          type:
            - string
            - 'null'
        due_date:
          type:
            - string
            - 'null'
        tax_point_date:
          type:
            - string
            - 'null'
        paid_at:
          type:
            - string
            - 'null'
        canceled_at:
          type:
            - string
            - 'null'
        eur:
          type:
            - object
            - 'null'
          properties:
            rate:
              type:
                - string
                - 'null'
            rate_date:
              type:
                - string
                - 'null'
            subtotal:
              type:
                - string
                - 'null'
            tax:
              type:
                - string
                - 'null'
            total:
              type:
                - string
                - 'null'
          required:
            - rate
            - rate_date
            - subtotal
            - tax
            - total
        notes:
          type:
            - string
            - 'null'
        lines:
          type: array
          items:
            type: object
            properties:
              description:
                type: string
              details:
                type:
                  - string
                  - 'null'
              period_start:
                type:
                  - string
                  - 'null'
              period_end:
                type:
                  - string
                  - 'null'
              quantity:
                type: string
              unit_price:
                type:
                  - string
                  - 'null'
              discount:
                type:
                  - string
                  - 'null'
              net:
                type:
                  - string
                  - 'null'
              tax_scheme:
                type: string
                enum:
                  - domestic
                  - oss
                  - reverse_charge
                  - outside_eu
              tax_country:
                type:
                  - string
                  - 'null'
              tax_rate:
                type: string
            required:
              - description
              - details
              - period_start
              - period_end
              - quantity
              - unit_price
              - discount
              - net
              - tax_scheme
              - tax_country
              - tax_rate
        tax_totals:
          type: array
          items:
            type: object
            properties:
              tax_scheme:
                type: string
                enum:
                  - domestic
                  - oss
                  - reverse_charge
                  - outside_eu
              tax_country:
                type:
                  - string
                  - 'null'
              tax_rate:
                type: string
              taxable:
                type:
                  - string
                  - 'null'
              tax:
                type:
                  - string
                  - 'null'
            required:
              - tax_scheme
              - tax_country
              - tax_rate
              - taxable
              - tax
        payments:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              method:
                type: string
                enum:
                  - bank_transfer
                  - card
                  - ideal
                  - other
              amount:
                type:
                  - string
                  - 'null'
              paid_at:
                type:
                  - string
                  - 'null'
            required:
              - id
              - method
              - amount
              - paid_at
        credit_notes:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              number:
                type: string
              total:
                type:
                  - string
                  - 'null'
              issue_date:
                type:
                  - string
                  - 'null'
            required:
              - id
              - number
              - total
              - issue_date
        links:
          type: object
          properties:
            pdf:
              type: string
          required:
            - pdf
      required:
        - id
        - type
        - status
        - is_overdue
        - reference
        - number
        - proforma_number
        - currency
        - net
        - credit
        - subtotal
        - tax
        - total
        - paid
        - amount_due
        - payment_in_progress
        - issue_date
        - due_date
        - tax_point_date
        - paid_at
        - canceled_at
        - eur
        - notes
        - links
      title: InvoiceResource
  responses:
    AuthorizationException:
      description: Authorization error
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
                description: Error overview.
            required:
              - message
  securitySchemes:
    http:
      type: http
      description: >-
        An API token from *API tokens* in the console, sent as `Authorization:
        Bearer pgapi_...`. It works for one billing account, and its permissions
        decide which endpoints it may call.
      scheme: bearer

````

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