> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phonely.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Invoices

> Return invoice data through the frontend billing API surface.

Retrieves billing invoices for a specific customer from Stripe.

### Request

**Method:** `POST`\
**Endpoint:** `/api/get-invoices`\
**Headers:**

* `Content-Type`: `application/json`
* `Origin`: Must match the configured app URL

**Request Body:**

```json theme={null}
{
  "customerId": "string"
}
```

**Parameters:**

* `customerId` (string, required): The Stripe customer ID

### Response

**Success Response (200):**

```json theme={null}
{
  "message": "Invoices retrieved.",
  "invoices": {
    "object": "list",
    "data": [
      {
        "id": "string",
        "object": "invoice",
        "amount_due": number,
        "amount_paid": number,
        "amount_remaining": number,
        "currency": "string",
        "customer": "string",
        "date": number,
        "due_date": number,
        "paid": boolean,
        "status": "string",
        "total": number
      }
    ],
    "has_more": boolean,
    "url": "string"
  }
}
```

**Error Responses:**

* `400 Bad Request`: Customer ID is required
* `403 Forbidden`: Unauthorized origin
* `404 Not Found`: Invoices not found
* `500 Internal Server Error`: Server error

### Example

```bash theme={null}
curl -X POST https://app.phonely.ai/api/get-invoices \
  -H "Content-Type: application/json" \
  -H "Origin: https://app.phonely.ai" \
  -d '{
    "customerId": "cus_xxxxxxxxxxxxxxxxx"
  }'
```

### Notes

* This endpoint requires the request to come from the configured app URL
* Returns Stripe invoice objects with full billing details
* Only accessible from the official Phonely application


## OpenAPI

````yaml POST /get-invoices
openapi: 3.0.1
info:
  title: Phonely API
  description: API for Phonely services including agent management and call summaries
  version: 1.0.0
servers:
  - url: https://app.phonely.ai/api
security: []
paths:
  /get-invoices:
    post:
      summary: Get invoices
      description: Retrieves billing invoices for a specific customer from Stripe.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetInvoicesRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetInvoicesResponse'
        '400':
          description: Customer ID is required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Unauthorized origin
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Invoices not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GetInvoicesRequest:
      type: object
      required:
        - customerId
      properties:
        customerId:
          type: string
          description: Stripe customer ID
    GetInvoicesResponse:
      type: object
      properties:
        message:
          type: string
          description: Response message
        invoices:
          type: object
          description: Stripe invoices object
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error code or identifier
        message:
          type: string
          description: Detailed error message

````