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

# get subscription

> Get subscription with the active phase for a customer



## OpenAPI

````yaml /openapi.json post /v1/subscriptions/get
openapi: 3.0.3
info:
  title: Unprice API
  version: 1.0.0
servers:
  - url: https://api.unprice.dev
    description: Production
  - url: http://localhost:8787
    description: Development
  - url: https://preview-api.unprice.dev
    description: Preview
security:
  - bearerAuth: []
paths:
  /v1/subscriptions/get:
    post:
      tags:
        - subscriptions
      summary: get subscription
      description: Get subscription with the active phase for a customer
      operationId: subscriptions.get
      requestBody:
        description: Body of the request
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customerId:
                  type: string
                  description: The customer ID
                  example: cus_1H7KQFLr7RepUyQBKdnvY
                projectId:
                  type: string
                  description: The project ID
                  example: prj_1H7KQFLr7RepUyQBKdnvY
              required:
                - customerId
      responses:
        '200':
          description: The result of the get subscription
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    maxLength: 36
                  projectId:
                    type: string
                    maxLength: 36
                  createdAtM:
                    type: number
                  updatedAtM:
                    type: number
                  customerId:
                    type: string
                    maxLength: 36
                  status:
                    type: string
                    enum:
                      - active
                      - trialing
                      - pending_payment
                      - pending_activation
                      - canceled
                      - expired
                      - past_due
                  active:
                    type: boolean
                  planSlug:
                    type: string
                    minLength: 1
                  currentCycleStartAt:
                    type: number
                  currentCycleEndAt:
                    type: number
                  renewAt:
                    type: number
                    nullable: true
                  endAt:
                    type: number
                    nullable: true
                  timezone:
                    type: string
                    minLength: 1
                  metadata:
                    type: object
                    nullable: true
                    properties:
                      reason:
                        type: string
                        enum:
                          - payment_failed
                          - invoice_voided
                          - payment_pending
                          - payment_method_not_found
                          - policy_violation
                          - pending_cancellation
                          - invoice_failed
                          - invoice_pending
                          - payment_received
                          - pending_change
                          - pending_expiration
                          - trial_ended
                          - user_requested
                          - admin_requested
                          - ending
                          - renewed
                          - cancelled
                          - auto_renew_disabled
                          - customer_signout
                          - generate_billing_periods_failed
                        description: Reason for the subscription status
                      note:
                        type: string
                        description: Note about status in the subscription
                      dates:
                        type: object
                        properties:
                          lastChangeAt:
                            type: number
                            description: Date of the last change
                          cancelAt:
                            type: number
                            description: Date of the cancellation
                        description: Important dates for the subscription
                  project:
                    type: object
                    properties:
                      enabled:
                        type: boolean
                    required:
                      - enabled
                  customer:
                    type: object
                    properties:
                      active:
                        type: boolean
                    required:
                      - active
                  activePhase:
                    type: object
                    properties:
                      id:
                        type: string
                        maxLength: 36
                      projectId:
                        type: string
                        maxLength: 36
                      createdAtM:
                        type: number
                      updatedAtM:
                        type: number
                      subscriptionId:
                        type: string
                        maxLength: 36
                      planVersionId:
                        type: string
                        minLength: 1
                      paymentMethodId:
                        type: string
                        nullable: true
                      paymentProvider:
                        type: string
                        enum:
                          - stripe
                          - square
                          - sandbox
                      creditLinePolicy:
                        type: string
                        enum:
                          - capped
                          - uncapped
                        default: uncapped
                      creditLineAmount:
                        type: integer
                        nullable: true
                        minimum: 0
                      trialUnits:
                        type: integer
                        nullable: true
                        minimum: 0
                        default: 0
                      billingAnchor:
                        type: number
                      trialEndsAt:
                        type: number
                        nullable: true
                      startAt:
                        type: number
                      endAt:
                        type: number
                        nullable: true
                      metadata:
                        type: object
                        nullable: true
                        properties:
                          note:
                            type: string
                            description: Note about the subscription phase
                          reason:
                            type: string
                            enum:
                              - payment_failed
                              - invoice_voided
                              - payment_pending
                              - payment_method_not_found
                              - policy_violation
                              - pending_cancellation
                              - invoice_failed
                              - invoice_pending
                              - payment_received
                              - pending_change
                              - pending_expiration
                              - trial_ended
                              - user_requested
                              - admin_requested
                              - ending
                              - renewed
                              - cancelled
                              - auto_renew_disabled
                              - customer_signout
                              - generate_billing_periods_failed
                            description: Reason for the subscription phase
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              maxLength: 36
                            projectId:
                              type: string
                              maxLength: 36
                            createdAtM:
                              type: number
                            updatedAtM:
                              type: number
                            units:
                              type: number
                              nullable: true
                            featurePlanVersionId:
                              type: string
                              maxLength: 36
                            subscriptionPhaseId:
                              type: string
                              maxLength: 36
                            subscriptionId:
                              type: string
                              maxLength: 36
                          required:
                            - id
                            - projectId
                            - createdAtM
                            - updatedAtM
                            - units
                            - featurePlanVersionId
                            - subscriptionPhaseId
                            - subscriptionId
                      planVersion:
                        type: object
                        properties:
                          id:
                            type: string
                            maxLength: 36
                          projectId:
                            type: string
                            maxLength: 36
                          createdAtM:
                            type: number
                          updatedAtM:
                            type: number
                          planId:
                            type: string
                            maxLength: 36
                          description:
                            type: string
                          latest:
                            type: boolean
                            nullable: true
                          title:
                            type: string
                            maxLength: 50
                          tags:
                            type: array
                            nullable: true
                            items:
                              type: string
                            description: >-
                              Array of tags for categorizing and filtering plan
                              versions. Examples: ['popular', 'recommended',
                              'enterprise', 'startup']
                          active:
                            type: boolean
                            nullable: true
                          status:
                            type: string
                            nullable: true
                            enum:
                              - draft
                              - published
                          publishedAt:
                            type: number
                            nullable: true
                          publishedBy:
                            type: string
                            nullable: true
                            maxLength: 36
                          archived:
                            type: boolean
                            nullable: true
                          archivedAt:
                            type: number
                            nullable: true
                          archivedBy:
                            type: string
                            nullable: true
                            maxLength: 36
                          paymentProvider:
                            type: string
                            enum:
                              - stripe
                              - square
                              - sandbox
                          dueBehaviour:
                            type: string
                            enum:
                              - cancel
                              - downgrade
                          currency:
                            type: string
                            enum:
                              - USD
                              - EUR
                            description: >-
                              ISO 4217 currency code for this plan version.
                              Examples: 'USD', 'EUR'. Each plan version is tied
                              to a single currency
                          billingConfig:
                            type: object
                            properties:
                              name:
                                type: string
                                minLength: 1
                              billingInterval:
                                type: string
                                enum:
                                  - month
                                  - year
                                  - week
                                  - day
                                  - minute
                                  - onetime
                              billingIntervalCount:
                                type: integer
                                minimum: 1
                                maximum: 60
                              billingAnchor:
                                anyOf:
                                  - type: integer
                                    minimum: 1
                                    maximum: 31
                                    description: >-
                                      Days of the month. Pick a number between 1
                                      and 31, if the month has less days, it
                                      will be the last day of the month
                                  - type: string
                                    enum:
                                      - dayOfCreation
                                    description: >-
                                      the day of the creation of the
                                      subscription as the billing anchor
                              planType:
                                type: string
                                enum:
                                  - recurring
                                  - onetime
                            required:
                              - name
                              - billingInterval
                              - billingIntervalCount
                              - billingAnchor
                              - planType
                            description: The billing configuration for the plan version
                          whenToBill:
                            type: string
                            enum:
                              - pay_in_advance
                              - pay_in_arrear
                          gracePeriod:
                            type: number
                          collectionMethod:
                            type: string
                            enum:
                              - charge_automatically
                              - send_invoice
                          trialUnits:
                            type: number
                          autoRenew:
                            type: boolean
                          metadata:
                            type: object
                            nullable: true
                            properties:
                              externalId:
                                type: string
                                description: >-
                                  External identifier for integrating with
                                  third-party systems (e.g., Stripe price ID).
                                  Useful for syncing plan versions with external
                                  billing providers
                            description: >-
                              Plan version metadata containing external
                              integration identifiers
                          paymentMethodRequired:
                            type: boolean
                          version:
                            type: number
                        required:
                          - id
                          - projectId
                          - createdAtM
                          - updatedAtM
                          - planId
                          - description
                          - latest
                          - title
                          - tags
                          - active
                          - status
                          - publishedAt
                          - publishedBy
                          - archived
                          - archivedAt
                          - archivedBy
                          - paymentProvider
                          - dueBehaviour
                          - currency
                          - billingConfig
                          - whenToBill
                          - gracePeriod
                          - collectionMethod
                          - trialUnits
                          - autoRenew
                          - metadata
                          - paymentMethodRequired
                          - version
                        description: >-
                          Schema for reading/selecting plan version data from
                          the database
                    required:
                      - id
                      - projectId
                      - subscriptionId
                      - planVersionId
                      - paymentMethodId
                      - paymentProvider
                      - creditLineAmount
                      - billingAnchor
                      - trialEndsAt
                      - startAt
                      - endAt
                      - planVersion
                required:
                  - id
                  - projectId
                  - createdAtM
                  - updatedAtM
                  - customerId
                  - status
                  - active
                  - planSlug
                  - currentCycleStartAt
                  - currentCycleEndAt
                  - renewAt
                  - endAt
                  - timezone
                  - metadata
                  - project
                  - customer
        '400':
          description: >-
            The server cannot or will not process the request due to something
            that is perceived to be a client error (e.g., malformed request
            syntax, invalid request message framing, or deceptive request
            routing).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrBadRequest'
        '401':
          description: >-
            Although the HTTP standard specifies "unauthorized", semantically
            this response means "unauthenticated". That is, the client must
            authenticate itself to get the requested response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrUnauthorized'
        '403':
          description: >-
            The client does not have access rights to the content; that is, it
            is unauthorized, so the server is refusing to give the requested
            resource. Unlike 401 Unauthorized, the client's identity is known to
            the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrForbidden'
        '404':
          description: >-
            The server cannot find the requested resource. In the browser, this
            means the URL is not recognized. In an API, this can also mean that
            the endpoint is valid but the resource itself does not exist.
            Servers may also send this response instead of 403 Forbidden to hide
            the existence of a resource from an unauthorized client. This
            response code is probably the most well known due to its frequent
            occurrence on the web.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrNotFound'
        '409':
          description: >-
            This response is sent when a request conflicts with the current
            state of the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrConflict'
        '412':
          description: >-
            The requested operation cannot be completed because certain
            conditions were not met. This typically occurs when a required
            resource state or version check fails.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrPreconditionFailed'
        '429':
          description: >-
            The user has sent too many requests in a given amount of time ("rate
            limiting")
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrTooManyRequests'
        '500':
          description: >-
            The server has encountered a situation it does not know how to
            handle.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrInternalServerError'
components:
  schemas:
    ErrBadRequest:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - BAD_REQUEST
              description: A machine readable error code.
              example: BAD_REQUEST
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/BAD_REQUEST
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrUnauthorized:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - UNAUTHORIZED
              description: A machine readable error code.
              example: UNAUTHORIZED
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/UNAUTHORIZED
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrForbidden:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - FORBIDDEN
              description: A machine readable error code.
              example: FORBIDDEN
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/FORBIDDEN
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrNotFound:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - NOT_FOUND
              description: A machine readable error code.
              example: NOT_FOUND
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/NOT_FOUND
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrConflict:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - CONFLICT
              description: A machine readable error code.
              example: CONFLICT
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: https://docs.unprice.dev/api-reference/errors/code/CONFLICT
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrPreconditionFailed:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - PRECONDITION_FAILED
              description: A machine readable error code.
              example: PRECONDITION_FAILED
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: >-
                https://docs.unprice.dev/api-reference/errors/code/PRECONDITION_FAILED
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrTooManyRequests:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - TOO_MANY_REQUESTS
              description: A machine readable error code.
              example: TOO_MANY_REQUESTS
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: >-
                https://docs.unprice.dev/api-reference/errors/code/TOO_MANY_REQUESTS
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
    ErrInternalServerError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - INTERNAL_SERVER_ERROR
              description: A machine readable error code.
              example: INTERNAL_SERVER_ERROR
            docs:
              type: string
              description: >-
                A link to our documentation with more details about this error
                code
              example: >-
                https://docs.unprice.dev/api-reference/errors/code/INTERNAL_SERVER_ERROR
            message:
              type: string
              description: A human readable explanation of what went wrong
            requestId:
              type: string
              description: Please always include the requestId in your error report
              example: req_1234
          required:
            - code
            - docs
            - message
            - requestId
      required:
        - error
  securitySchemes:
    bearerAuth:
      bearerFormat: root key
      type: http
      scheme: bearer
      x-speakeasy-example: UNPRICE_API_KEY

````