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

# Complete a subscription milestone

> Marks some or all of a milestone complete so that it bills. `IMMEDIATELY` raises a standalone invoice and issues it now; `NEXT_INVOICE` adds it to the subscription's next scheduled invoice.



## OpenAPI

````yaml https://api.salesbricks.com/api/v2/openapi.yaml post /subscriptions/{subscription_id}/milestones/{milestone_id}/complete
openapi: 3.0.3
info:
  title: Salesbricks REST API
  version: 2.0.0
  description: API reference for external integrations
servers:
  - url: https://api.salesbricks.com/api/v2
    description: Production
  - url: https://api.staging.salesbricks.com/api/v2
    description: Staging
security:
  - ApiKeyAuth: []
tags:
  - name: Subscriptions
    description: >-
      Operations related to subscription management, including creation,
      updates, and retrieving subscription details. Subscriptions can be
      upgraded to add / remove add-ons by using the POST
      /subscriptions/{subscription_id}/upgrade endpoint and can be recasted for
      replacing the current agreement using the POST
      /subscriptions/{subscription_id}/recast endpoint
  - name: Subscription Milestones
    description: >-
      Operations for listing and completing milestone bricks — bricks billed
      when the work they cover is delivered rather than on the subscription's
      schedule. Completing one either raises a standalone invoice immediately or
      bills on the subscription's next scheduled invoice.
  - name: Customers
    description: >-
      Operations related to customer management, including creation, updates,
      and managing customer person objects.
  - name: Invoices
    description: Operations related to subscription's invoicing details.
  - name: Plans
    description: >-
      Operations related to listing and getting plan details including bricks in
      the plan.
  - name: Payment Methods
    description: Operations related to subscription's payment method.
paths:
  /subscriptions/{subscription_id}/milestones/{milestone_id}/complete:
    post:
      tags:
        - Subscription Milestones
      summary: Complete a subscription milestone
      description: >-
        Marks some or all of a milestone complete so that it bills.
        `IMMEDIATELY` raises a standalone invoice and issues it now;
        `NEXT_INVOICE` adds it to the subscription's next scheduled invoice.
      operationId: completeSubscriptionMilestone
      parameters:
        - in: path
          name: milestone_id
          schema:
            type: string
            pattern: ^([a-zA-Z\d\-]+)$
          required: true
        - in: path
          name: subscription_id
          schema:
            type: string
            pattern: ^([a-zA-Z\d\-]+)$
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscriptionMilestoneCompleteInput'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/SubscriptionMilestoneCompleteInput'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SubscriptionMilestoneCompleteInput'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionMilestoneCompleteOutput'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                BadRequestResponse:
                  value:
                    error:
                      code: ERR_BAD_REQUEST
                      message: >-
                        Bad request — the input payload is malformed, missing
                        required fields, or contains invalid data.
                      details:
                        fields:
                          quantity:
                            - This field is required.
                  summary: Bad Request Response
          description: ''
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                NotFoundResponse:
                  value:
                    error:
                      code: ERR_NOT_FOUND
                      message: >-
                        Milestone not found — no milestone matches the given
                        `milestone_id` on this subscription.
                  summary: Not Found Response
          description: ''
components:
  schemas:
    SubscriptionMilestoneCompleteInput:
      type: object
      description: Input serializer for completing a milestone.
      properties:
        quantity:
          type: integer
          minimum: 1
          description: >-
            How much of the milestone to complete. May not take the completed
            total past the milestone's `total_quantity`.
        bill_on:
          enum:
            - IMMEDIATELY
            - NEXT_INVOICE
          type: string
          x-spec-enum-id: 34039f628d127abc
          description: >-
            When the completion bills. `IMMEDIATELY` raises a standalone invoice
            for the milestone and issues it now. `NEXT_INVOICE` adds it to the
            subscription's next scheduled invoice, and is rejected when there is
            no invoice left to defer onto.


            * `IMMEDIATELY` - Immediately

            * `NEXT_INVOICE` - Next invoice
        issued_at:
          type: string
          format: date
          nullable: true
          description: >-
            Issue date for the new invoice. Defaults to today; a future date
            leaves the invoice to be issued by the scheduled sweep. Only valid
            with `bill_on: IMMEDIATELY`.
        due_at:
          type: string
          format: date
          nullable: true
          description: >-
            Due date for the new invoice. Defaults to the order's payment terms,
            and may not precede `issued_at`. Only valid when `bill_on` is
            `IMMEDIATELY`.
        service_date:
          type: string
          format: date
          nullable: true
          description: >-
            The date the work was delivered. The new invoice's service period
            starts and ends on this day — it is a single date, not a range.
            Defaults to today, and may be backdated independently of
            `issued_at`. Only valid when `bill_on` is `IMMEDIATELY`.
      required:
        - bill_on
        - quantity
    SubscriptionMilestoneCompleteOutput:
      type: object
      description: Output serializer for a milestone completion.
      properties:
        completion:
          allOf:
            - $ref: '#/components/schemas/MilestoneCompletion'
          description: The completion that was recorded.
        milestone:
          allOf:
            - $ref: '#/components/schemas/SubscriptionMilestone'
          description: The milestone's state after the completion.
      required:
        - completion
        - milestone
    ErrorResponse:
      type: object
      description: >-
        Standardizes API error responses with a consistent structure containing
        error code and message.
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
    MilestoneCompletion:
      type: object
      description: One recorded completion of a milestone.
      properties:
        id:
          type: string
          format: uuid
          description: ID of the completion record.
        quantity:
          type: integer
          description: How much of the milestone this completion billed.
        invoice_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            The invoice this completion is billed on. Null when the invoice was
            regenerated and the completion is waiting to be reattached.
        completed_at:
          type: string
          format: date-time
          description: When the milestone was marked complete.
      required:
        - completed_at
        - id
        - invoice_id
        - quantity
    SubscriptionMilestone:
      type: object
      description: The state of a single milestone on a subscription.
      properties:
        milestone_id:
          type: string
          format: uuid
          description: >-
            ID of the milestone. Pass this to `POST
            /subscriptions/{subscription_id}/milestones/{milestone_id}/complete`.
        brick_id:
          type: string
          format: uuid
          nullable: true
          description: >-
            The underlying brick. Not unique across milestones — a multi-phase
            order carries the same brick in more than one phase.
        brick_name:
          type: string
          description: Name of the brick, or its per-order custom name where set.
        order_id:
          type: string
          format: uuid
          description: The order in the subscription chain that carries this milestone.
        phase_position:
          type: integer
          description: 0-based position of the order phase carrying this milestone.
        phase_name:
          type: string
          nullable: true
          description: Name of the order phase carrying this milestone, where it has one.
        total_quantity:
          type: integer
          description: >-
            The quantity that has to be completed. Included units, and on an
            upgrade the previously contracted quantity, are already netted off.
        completed_quantity:
          type: integer
          description: >-
            How much has been completed so far. Completions billed on a voided
            invoice do not count, so voiding reverts a milestone to incomplete.
        completions:
          type: array
          items:
            $ref: '#/components/schemas/MilestoneCompletion'
          description: Every completion recorded against this milestone, oldest first.
      required:
        - brick_id
        - brick_name
        - completed_quantity
        - completions
        - milestone_id
        - order_id
        - phase_name
        - phase_position
        - total_quantity
    Error:
      type: object
      description: >-
        Represents individual error details with a standardized code and
        descriptive message.
      properties:
        code:
          enum:
            - ERR_NOT_FOUND
            - ERR_BAD_REQUEST
            - ERR_SERVER_ERROR
          type: string
          x-spec-enum-id: dc5a5d6feae1b697
          description: >-
            Error code indicating the type of error: NOT_FOUND for missing
            resources, BAD_REQUEST for invalid input, SERVER_ERROR for internal
            server issues


            * `ERR_NOT_FOUND` - ERR_NOT_FOUND

            * `ERR_BAD_REQUEST` - ERR_BAD_REQUEST

            * `ERR_SERVER_ERROR` - ERR_SERVER_ERROR
        message:
          type: string
        error_id:
          type: string
          format: uuid
          description: >-
            Correlation handle for SERVER_ERROR responses — quote this when
            contacting support; it joins to the structured server log line for
            the failure. Not present on 4xx responses.
      required:
        - code
        - message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-SALESBRICKS-KEY
      description: API key for authentication

````

## Related topics

- [List all subscription milestones](/api-reference/subscription-milestones/list-all-subscription-milestones.md)
- [Creating a Brick](/quickstart-guide/products-plans-bricks/creating-a-brick.md)
- [Starting a Subscription](/api-reference/getting-started/starting-a-subscription.md)
