# Invoices

Invoice data

## GET /{contract}/invoices

> Returns a list of all invoices.

```json
{"openapi":"3.0.0","info":{"title":"IONOS Cloud Billing API","version":"3.9.0"},"tags":[{"name":"invoices","description":"Invoice data"}],"servers":[{"url":"https://api.ionos.com/billing","description":"Production API"}],"security":[{"basicAuth":[]},{"bearerAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic"},"bearerAuth":{"type":"http","scheme":"bearer"}},"parameters":{"ContractParameter":{"name":"contract","in":"path","description":"Contract number","required":true,"schema":{"type":"integer","pattern":"[0-9]{5,10}"}}},"schemas":{"MetaData":{"type":"object","properties":{"contractId":{"type":"integer"},"customerId":{"type":"integer"},"reference":{"type":"string","nullable":true}}}},"responses":{"Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object"}}}},"Forbidden":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object"}}}},"NotFound":{"description":"The contract not found or doesn't belong to the user","content":{"application/json":{"schema":{"type":"object"}}}},"InternalError":{"description":"Unexpected internal server error","content":{"application/json":{"schema":{"type":"object"}}}}}},"paths":{"/{contract}/invoices":{"get":{"tags":["invoices"],"description":"Returns a list of all invoices.","operationId":"invoicesGet","parameters":[{"$ref":"#/components/parameters/ContractParameter"}],"responses":{"200":{"description":"Result data","content":{"application/json":{"schema":{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetaData"},"invoices":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"date":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"amount":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true}}}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}}}}
```

## GET /{contract}/invoices/{id}

> Returns the invoice for a given invoice ID.

```json
{"openapi":"3.0.0","info":{"title":"IONOS Cloud Billing API","version":"3.9.0"},"tags":[{"name":"invoices","description":"Invoice data"}],"servers":[{"url":"https://api.ionos.com/billing","description":"Production API"}],"security":[{"basicAuth":[]},{"bearerAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic"},"bearerAuth":{"type":"http","scheme":"bearer"}},"parameters":{"ContractParameter":{"name":"contract","in":"path","description":"Contract number","required":true,"schema":{"type":"integer","pattern":"[0-9]{5,10}"}},"InvoiceIdParameter":{"name":"id","in":"path","description":"Invoice ID","required":true,"schema":{"type":"string"}},"DateFormatQueryParameter":{"name":"dateformat","in":"query","description":"Vendor date format","required":false,"schema":{"type":"string"}}},"schemas":{"Invoice":{"type":"object","properties":{"metadata":{"type":"object","properties":{"invoiceId":{"type":"string"},"contractId":{"type":"integer"},"customerId":{"type":"integer"},"createdDate":{"type":"string","format":"date-time"},"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"},"postingPeriod":{"type":"string"},"finallyPosted":{"type":"boolean"},"reference":{"type":"string","nullable":true},"resellerRef":{"type":"string","nullable":true,"description":"Reference text or number for the subcontract set by the reseller"}}},"datacenters":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"location":{"type":"string"},"productGroup":{"type":"string","nullable":true,"description":"Product group of the data center"},"meters":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceMeter"}},"rebate":{"type":"object","properties":{"amount":{"$ref":"#/components/schemas/InvoiceTotal"}}}}}},"total":{"$ref":"#/components/schemas/InvoiceTotal"}}},"InvoiceMeter":{"type":"object","properties":{"meterId":{"type":"string"},"meterDesc":{"type":"string"},"productGroup":{"type":"string","nullable":true,"description":"Product group of the price item"},"quantity":{"type":"object","properties":{"quantity":{"type":"number"},"unit":{"type":"string"}}},"rate":{"$ref":"#/components/schemas/InvoiceTotal"},"amount":{"$ref":"#/components/schemas/InvoiceTotal"}}},"InvoiceTotal":{"type":"object","properties":{"quantity":{"type":"number"},"unit":{"type":"string"}}}},"responses":{"Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object"}}}},"Forbidden":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object"}}}},"InternalError":{"description":"Unexpected internal server error","content":{"application/json":{"schema":{"type":"object"}}}}}},"paths":{"/{contract}/invoices/{id}":{"get":{"tags":["invoices"],"description":"Returns the invoice for a given invoice ID.","operationId":"invoicesFindById","parameters":[{"$ref":"#/components/parameters/ContractParameter"},{"$ref":"#/components/parameters/InvoiceIdParameter"},{"$ref":"#/components/parameters/DateFormatQueryParameter"}],"responses":{"200":{"description":"Result data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"Invoice with the ID not found","content":{"application/json":{"schema":{"type":"object"}}}},"409":{"description":"Invoice with the ID doesn't belong to the contract","content":{"application/json":{"schema":{"type":"object"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}}}}
```

## GET /invoices/{period}

> Returns invoices of billing profiles of a use.

```json
{"openapi":"3.0.0","info":{"title":"IONOS Cloud Billing API","version":"3.9.0"},"tags":[{"name":"invoices","description":"Invoice data"}],"servers":[{"url":"https://api.ionos.com/billing","description":"Production API"}],"security":[{"basicAuth":[]},{"bearerAuth":[]}],"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic"},"bearerAuth":{"type":"http","scheme":"bearer"}},"parameters":{"PeriodParameter":{"name":"period","in":"path","description":"Period of interest in format YYYY-MM","required":true,"schema":{"type":"string","pattern":"^(\\d{4}-\\d{2}|null)$"}},"ContractIdQueryParameter":{"name":"contractid","in":"query","description":"Filter out the exact contractID","required":false,"schema":{"type":"string"}},"DateFormatQueryParameter":{"name":"dateformat","in":"query","description":"Vendor date format","required":false,"schema":{"type":"string"}}},"schemas":{"Invoice":{"type":"object","properties":{"metadata":{"type":"object","properties":{"invoiceId":{"type":"string"},"contractId":{"type":"integer"},"customerId":{"type":"integer"},"createdDate":{"type":"string","format":"date-time"},"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"},"postingPeriod":{"type":"string"},"finallyPosted":{"type":"boolean"},"reference":{"type":"string","nullable":true},"resellerRef":{"type":"string","nullable":true,"description":"Reference text or number for the subcontract set by the reseller"}}},"datacenters":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"location":{"type":"string"},"productGroup":{"type":"string","nullable":true,"description":"Product group of the data center"},"meters":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceMeter"}},"rebate":{"type":"object","properties":{"amount":{"$ref":"#/components/schemas/InvoiceTotal"}}}}}},"total":{"$ref":"#/components/schemas/InvoiceTotal"}}},"InvoiceMeter":{"type":"object","properties":{"meterId":{"type":"string"},"meterDesc":{"type":"string"},"productGroup":{"type":"string","nullable":true,"description":"Product group of the price item"},"quantity":{"type":"object","properties":{"quantity":{"type":"number"},"unit":{"type":"string"}}},"rate":{"$ref":"#/components/schemas/InvoiceTotal"},"amount":{"$ref":"#/components/schemas/InvoiceTotal"}}},"InvoiceTotal":{"type":"object","properties":{"quantity":{"type":"number"},"unit":{"type":"string"}}}},"responses":{"Unauthorized":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object"}}}},"Forbidden":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object"}}}},"Unprocessable":{"description":"Wrong period format specified","content":{"application/json":{"schema":{"type":"object"}}}},"InternalError":{"description":"Unexpected internal server error","content":{"application/json":{"schema":{"type":"object"}}}}}},"paths":{"/invoices/{period}":{"get":{"tags":["invoices"],"description":"Returns invoices of billing profiles of a use.","operationId":"invoicesFindByPeriod","parameters":[{"$ref":"#/components/parameters/PeriodParameter"},{"$ref":"#/components/parameters/ContractIdQueryParameter"},{"$ref":"#/components/parameters/DateFormatQueryParameter"}],"responses":{"200":{"description":"Result data","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Invoice"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"413":{"description":"Payload too large","content":{"application/json":{"schema":{"type":"object"}}}},"422":{"$ref":"#/components/responses/Unprocessable"},"500":{"$ref":"#/components/responses/InternalError"}}}}}}
```
