> ## 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 Subscription

> Legacy subscription helper endpoint. This page is excluded from the API-key frontend docs scope.

Retrieves subscription details for a specific Stripe subscription.

### Request

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

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

**Request Body:**

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

**Parameters:**

* `subscriptionId` (string, required): The Stripe subscription ID

### Response

**Success Response (200):**

```json theme={null}
{
  "message": "Subscription retrieved.",
  "subscription": {
    "subscriptionId": "string",
    "customerId": "string",
    "status": "string",
    "currentPeriodStart": number,
    "currentPeriodEnd": number
  }
}
```

**Error Responses:**

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

### Example

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

### Notes

* This endpoint requires the request to come from the configured app URL
* Returns key subscription information including status and billing periods
* Only accessible from the official Phonely application


## OpenAPI

````yaml POST /get-subscription
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-subscription:
    post:
      summary: Get subscription
      description: Retrieves subscription details for a specific Stripe subscription.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetSubscriptionRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetSubscriptionResponse'
        '400':
          description: Subscription 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: Subscription 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:
    GetSubscriptionRequest:
      type: object
      required:
        - subscriptionId
      properties:
        subscriptionId:
          type: string
          description: Stripe subscription ID
    GetSubscriptionResponse:
      type: object
      properties:
        message:
          type: string
          description: Response message
        subscription:
          type: object
          properties:
            subscriptionId:
              type: string
              description: Subscription ID
            customerId:
              type: string
              description: Customer ID
            status:
              type: string
              description: Subscription status
            currentPeriodStart:
              type: number
              description: Current period start timestamp
            currentPeriodEnd:
              type: number
              description: Current period end timestamp
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error code or identifier
        message:
          type: string
          description: Detailed error message

````