# Link Invoice to Appointment

Links an external Stripe invoice to an appointment.

This endpoint finds or creates a Hero invoice record from a Stripe invoice ID,
then links it to the specified appointment.

Endpoint: POST /v1/invoicing/invoices/link
Version: 1.0.0
Security: apiKeyAuth, practiceGroupId

## Security:

  - `apiKeyAuth` (unknown)
    apiKey in header x-api-key

  - `practiceGroupId` (unknown)
    apiKey in header x-practice-group-id

## Request fields (application/json):

  - `stripe_invoice_id` (string, required)

  - `appointment_id` (string, required)

  - `issuer_id` (string, required)

## Response 200:

  - `200` (unknown)
    Invoice linked successfully

## Response 200 fields (application/json):

  - `id` (string)

  - `stripe_id` (string, required)

  - `status` (string)

  - `subtotal` (number)

  - `amount_due` (number)

  - `customer_id` (string)

  - `patient_record_id` (string)

  - `appointment_id` (string)

  - `created_at` (string)

  - `updated_at` (string)

## Response 400:

  - `400` (unknown)
    Bad request

## Response 400 fields (application/json):

  - `error` (boolean, required)
    Example: true

  - `statusCode` (number, required)
    Example: 400

  - `message` (array, required)

  - `message.code` (string, required)
    Example: invalid_type

  - `message.expected` (string, required)
    Example: string

  - `message.path` (array, required)
    Example: ["patient_id"]

  - `message.message` (string, required)
    Example: Required

## Response 401:

  - `401` (unknown)
    Unauthorised

## Response 404:

  - `404` (unknown)
    Stripe invoice or appointment not found

## Response 429:

  - `429` (unknown)
    Too Many Requests

## Response 500:

  - `500` (unknown)
    Unknown error

