{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/jupiterinvoice-com/json-schema/jupiterinvoice-com-invoice-schema.json",
  "title": "Invoice",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/jupiterinvoice-com-openapi.yml#/components/schemas/Invoice",
  "properties": {
    "created_at": {
      "format": "date-time",
      "readOnly": true,
      "type": "string"
    },
    "currency": {
      "description": "3-letter code. Left out: the account's default currency (USD if none is set).",
      "type": "string"
    },
    "customer_id": {
      "type": [
        "integer",
        "null"
      ]
    },
    "discount": {
      "oneOf": [
        {
          "properties": {
            "type": {
              "const": "percent"
            },
            "value": {
              "type": "number"
            }
          }
        },
        {
          "properties": {
            "type": {
              "const": "flat"
            },
            "value_cents": {
              "type": "integer"
            }
          }
        }
      ],
      "type": "object"
    },
    "due_date": {
      "description": "Left out: the issue date plus the account's default payment terms (30 days if none is set).",
      "format": "date",
      "type": "string"
    },
    "footer_note": {
      "type": "string"
    },
    "id": {
      "description": "Invoice number, e.g. ACME-0001",
      "readOnly": true,
      "type": "string"
    },
    "invoice_number": {
      "description": "Same as id. Use it in /invoices/{invoice_number} URLs.",
      "readOnly": true,
      "type": "string"
    },
    "issue_date": {
      "format": "date",
      "type": "string"
    },
    "line_items": {
      "items": {
        "$ref": "#/$defs/LineItem"
      },
      "type": "array"
    },
    "paid_at": {
      "format": "date-time",
      "readOnly": true,
      "type": "string"
    },
    "po_number": {
      "type": "string"
    },
    "recipient": {
      "$ref": "#/$defs/Recipient"
    },
    "scope_details": {
      "description": "Long-form scope / statement of work shown to the recipient",
      "type": "string"
    },
    "sent_at": {
      "format": "date-time",
      "readOnly": true,
      "type": "string"
    },
    "share_token": {
      "readOnly": true,
      "type": "string"
    },
    "share_url": {
      "readOnly": true,
      "type": "string"
    },
    "status": {
      "enum": [
        "draft",
        "sent",
        "viewed",
        "change_requested",
        "updated",
        "approved",
        "paid",
        "cancelled"
      ],
      "type": "string"
    },
    "subscription_context": {
      "type": "string"
    },
    "subtotal_cents": {
      "readOnly": true,
      "type": "integer"
    },
    "tax": {
      "properties": {
        "amount_cents": {
          "readOnly": true,
          "type": "integer"
        },
        "label": {
          "type": "string"
        },
        "rate": {
          "description": "Percentage, e.g. 20.0 for 20%",
          "type": "number"
        }
      },
      "type": "object"
    },
    "terms_text": {
      "description": "Left out: the account's standard terms text, if it has one.",
      "type": "string"
    },
    "total_cents": {
      "readOnly": true,
      "type": "integer"
    },
    "updated_at": {
      "format": "date-time",
      "readOnly": true,
      "type": "string"
    }
  },
  "required": [
    "line_items"
  ],
  "type": "object",
  "$defs": {
    "Address": {
      "properties": {
        "city": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "line1": {
          "type": "string"
        },
        "line2": {
          "type": "string"
        },
        "line3": {
          "type": "string"
        },
        "postal_code": {
          "type": "string"
        },
        "state": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "LineItem": {
      "properties": {
        "description": {
          "type": "string"
        },
        "discount": {
          "oneOf": [
            {
              "properties": {
                "type": {
                  "const": "percent"
                },
                "value": {
                  "type": "number"
                }
              }
            },
            {
              "properties": {
                "type": {
                  "const": "flat"
                },
                "value_cents": {
                  "type": "integer"
                }
              }
            }
          ],
          "type": "object"
        },
        "line_total_cents": {
          "readOnly": true,
          "type": "integer"
        },
        "note": {
          "description": "Optional per-line detail shown under the line",
          "type": "string"
        },
        "quantity": {
          "default": 1,
          "type": "number"
        },
        "unit_price_cents": {
          "description": "Cents (or smallest currency unit)",
          "type": "integer"
        }
      },
      "required": [
        "description",
        "unit_price_cents"
      ],
      "type": "object"
    },
    "Recipient": {
      "properties": {
        "address": {
          "$ref": "#/$defs/Address"
        },
        "ap": {
          "properties": {
            "email": {
              "format": "email",
              "type": "string"
            },
            "name": {
              "type": "string"
            }
          },
          "type": "object"
        },
        "cc_emails": {
          "items": {
            "format": "email",
            "type": "string"
          },
          "type": "array"
        },
        "company": {
          "type": "string"
        },
        "email": {
          "format": "email",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "tax_id": {
          "type": "string"
        }
      },
      "type": "object"
    }
  }
}