# Retrieve an invoice (/docs/api-reference/billing/get-invoice)

One invoice with its lines.

`GET https://api.coss.com/v1/billing/invoices/{id}`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Path parameters

- `id` (string, required): The invoice's id.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.billing.invoices.get("inv_01k7c8m4q2f3e9v6t5r1n0p8yz");
```

HTTP:

```sh
curl -X GET "https://api.coss.com/v1/billing/invoices/inv_01k7c8m4q2f3e9v6t5r1n0p8yz" \
  -H "Authorization: Bearer $COSS_API_KEY"
```

Python:

```python
from coss import Coss

client = Coss()  # api_key= or COSS_API_KEY

client.billing.invoices.get(
    id="inv_01k7c8m4q2f3e9v6t5r1n0p8yz",
)
```

Go:

```go
import (
	"context"

	billing "github.com/cosscom/coss-go/billing"
	cossclient "github.com/cosscom/coss-go/client"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

request := &billing.GetInvoicesRequest{
    ID: "inv_01k7c8m4q2f3e9v6t5r1n0p8yz",
}
client.Billing.Invoices.Get(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.billing.invoices.get(id: "inv_01k7c8m4q2f3e9v6t5r1n0p8yz")
```

PHP:

```php
<?php

use Coss\Coss;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->billing->invoices->get(
    'inv_01k7c8m4q2f3e9v6t5r1n0p8yz',
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.billing.invoices.requests.GetInvoicesRequest;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.billing().invoices().get(
    "inv_01k7c8m4q2f3e9v6t5r1n0p8yz",
    GetInvoicesRequest
        .builder()
        .build()
);
```

.NET:

```csharp
using Coss;
using Coss.Billing;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Billing.Invoices.GetAsync(
    new GetInvoicesRequest { Id = "inv_01k7c8m4q2f3e9v6t5r1n0p8yz" }
);
```

## Response 200

The invoice.

- `object` ("invoice", required)
- `id` (string, required)
- `number` (string | null, required): The invoice number. `null` until it's finalized.
- `kind` ("period" | "plan_change" | "one_off" | "final" | "threshold", required): `period`: a billing month. `plan_change`: a change of plan. `one_off`: a single charge. `final`: the last invoice of an account. `threshold`: usage charged early, taken off the month's invoice.
- `status` ("open" | "paid" | "void" | "uncollectible", required): `open`: not paid yet. `paid`: settled. `void`: canceled. `uncollectible`: written off.
- `currency` ("usd", required): Always `usd`.
- `period` (object, required): What period it covers.
  - `start` (string, required, date-time): When the period starts (inclusive).
  - `end` (string, required, date-time): When the period ends (exclusive).
- `subtotal` (integer, required): An amount in cents (USD).
- `discount` (integer, required): An amount in cents (USD).
- `credit` (integer, required): An amount in cents (USD).
- `tax` (integer, required): An amount in cents (USD).
- `total` (integer, required): An amount in cents (USD).
- `amount_paid` (integer, required): An amount in cents (USD).
- `amount_due` (integer, required): An amount in cents (USD).
- `collection_method` ("charge_automatically" | "send_invoice", required): `charge_automatically`: charged to the payment method. `send_invoice`: paid by `due_at`.
- `due_at` (string | null, required, date-time): When payment is due. `null`: not set.
- `finalized_at` (string | null, required, date-time): When it was finalized. `null`: not yet.
- `paid_at` (string | null, required, date-time): When it was paid. `null`: not paid.
- `voided_at` (string | null, required, date-time): When it was voided. `null`: it wasn't.
- `hosted_url` (string | null, required): A page to view (and pay) the invoice.
- `pdf_url` (string | null, required): The invoice as a PDF. `null`: not available.
- `lines` (object[], required)
  - `object` ("invoice_line", required)
  - `id` (string, required)
  - `kind` ("plan_fee" | "proration" | "usage" | "credit" | "discount" | "commitment_fee" | "commitment_shortfall" | "add_on" | "adjustment" | "write_off", required): What it's for: `plan_fee`, `proration`, `usage`, `credit`, `discount`, `commitment_fee`, `commitment_shortfall`, `add_on`, `adjustment` or `write_off`.
  - `description` (string, required): The line as it reads on the invoice.
  - `meter` (string | null, required, one of "email.recipients", "email.dedicated_ip", "email.attachment_data", "email.received", "email.received_data", "email.inboxes", "sms.segments", "sms.received_segments", "sms.numbers", "sms.registrations", "sign.completed_requests", "risk.phone_checks", "risk.assessments", "risk.content_checks", "verify.verifications", "verify.sms", "forms.submissions", "forms.file_uploads", "scheduling.bookings", "scheduling.hosts", "hooks.messages", null): The meter of a `usage` line. `null` for other lines.
  - `dimension` (string | null, required): What the meter is split by, such as `country=US`. `null`: not split.
  - `quantity` (integer | null, required): Units on this line. `null` when it isn't priced by the unit.
  - `included_quantity` (integer | null, required): Units covered by an allowance or committed volume (not charged).
  - `unit_price` (string | null, required): Dollars per unit, e.g. `0.0004`; `null` when the price varies by volume.
  - `amount` (integer, required): An amount in cents (USD).
  - `period` (object, required): What period it covers.
    - `start` (string, required, date-time): When the period starts (inclusive).
    - `end` (string, required, date-time): When the period ends (exclusive).

Example:

```json
{
  "object": "invoice",
  "id": "inv_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "number": "COSS-000042",
  "kind": "period",
  "status": "paid",
  "currency": "usd",
  "period": {
    "start": "2026-10-01T00:00:00.000Z",
    "end": "2026-11-01T00:00:00.000Z"
  },
  "subtotal": 7300,
  "discount": 0,
  "credit": 2500,
  "tax": 0,
  "total": 4800,
  "amount_paid": 4800,
  "amount_due": 0,
  "collection_method": "charge_automatically",
  "due_at": "2026-11-01T00:20:00.000Z",
  "finalized_at": "2026-11-01T00:20:00.000Z",
  "paid_at": "2026-11-01T00:21:00.000Z",
  "voided_at": null,
  "hosted_url": "https://invoice.stripe.com/i/acct_123/test_YWNjdF8x",
  "pdf_url": "https://pay.stripe.com/invoice/acct_123/test_YWNjdF8x/pdf",
  "lines": [
    {
      "object": "invoice_line",
      "id": "invl_01k7c8m4q2f3e9v6t5r1n0p8yz",
      "kind": "usage",
      "description": "Email: 120,000 recipients",
      "meter": "email.recipients",
      "dimension": null,
      "quantity": 120000,
      "included_quantity": 0,
      "unit_price": "0.0004",
      "amount": 4800,
      "period": {
        "start": "2026-10-01T00:00:00.000Z",
        "end": "2026-11-01T00:00:00.000Z"
      }
    }
  ]
}
```

## Errors

- `400`: The `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `404`: No invoice with this id exists in the organization (`not_found`).
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).