# Pay invoice

Pays a finalized <a href="https://docs.solidgate.com/billing/invoicing/invoicing-overview/" target="_blank">invoice</a> using a saved <a href="https://docs.solidgate.com/billing/manage-customers/payment-instruments/" target="_blank">payment instrument</a>.

Endpoint: POST /invoices/pay
Version: 2.0.0
Security: bearerAuth

## Request fields (application/json):

  - `channel_id` (string)
    Unique channel identifier. Required when using multi-channel API keys.
    Example: chn_01JYWX6Z5A8P32B6NVH1G9876A

  - `id` (string, required)
    Unique invoice identifier.
    Example: inv_01KPWT0K1PQWEYYRT7J1H3NC85

  - `payment_instrument_id` (string, required)
    Unique payment instrument identifier used to pay the invoice.
    Example: pi_01J1Z2X3Y4W5V6U7T8S9R0

## Response 400 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "VALIDATION"

  - `message` (string, required)
    Message describing the error.
    Example: One or more fields failed validation due to constraints

  - `context` (object, required)
    Additional context about the validation error, including specific constraints.
    Example: {"constraints":{"email":{"type":"TYPE","message":"The 'email' field must be a valid email address"},"age":{"type":"MIN","message":"The 'age' field must be a number greater than or equal to 18"}}}

## Response 401 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "UNAUTHENTICATED"

  - `message` (string, required)
    Message describing the error.
    Example: Credentials are invalid or missing

## Response 403 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "PERMISSION_DENIED"

  - `message` (string, required)
    Message describing the error.
    Example: Permission denied

## Response 404 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "NOT_FOUND"

  - `message` (string, required)
    Message describing the error. The entity varies by endpoint.
    Example: The requested resource could not be found

## Response 422 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "INCOMPATIBLE_STATUS", "OPEN_PAYMENT_LIMIT_REACHED", "INVOICE_OVERDUE", "PAYMENT_INSTRUMENT_NOT_FOUND", "PAYMENT_INSTRUMENT_NOT_ACTIVE"

  - `message` (string, required)
    Message describing the error.
    Example: The request conflicts with the current state

## Response 429 fields (application/json):

  - `code` (string, required)
    Code identifying the error type.
    Enum: "RATE_LIMIT"

  - `message` (string, required)
    Message describing the error.
    Example: Rate limit exhausted

  - `context` (object)
    Additional context about the error.

  - `context.next_try_at` (string)
    Timestamp indicating when to retry the request.
    Example: 2024-12-31T23:59:59.000000Z

